[asterisk-commits] irroot: branch irroot/t38gateway-1.8 r329298 - in /team/irroot/t38gateway-1.8...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 22 10:12:51 CDT 2011
Author: irroot
Date: Fri Jul 22 10:12:48 2011
New Revision: 329298
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=329298
Log:
Initial Support for voice/fax Detect
Modified:
team/irroot/t38gateway-1.8/include/asterisk/dsp.h
team/irroot/t38gateway-1.8/main/dsp.c
team/irroot/t38gateway-1.8/res/res_fax.c
Modified: team/irroot/t38gateway-1.8/include/asterisk/dsp.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-1.8/include/asterisk/dsp.h?view=diff&rev=329298&r1=329297&r2=329298
==============================================================================
--- team/irroot/t38gateway-1.8/include/asterisk/dsp.h (original)
+++ team/irroot/t38gateway-1.8/include/asterisk/dsp.h Fri Jul 22 10:12:48 2011
@@ -43,8 +43,9 @@
#define DSP_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
#define DSP_FEATURE_WAITDIALTONE (1 << 20) /*!< Enable dial tone detection */
-#define DSP_FAXMODE_DETECT_CNG (1 << 0)
-#define DSP_FAXMODE_DETECT_CED (1 << 1)
+#define DSP_FAXMODE_DETECT_CNG (1 << 0)
+#define DSP_FAXMODE_DETECT_CED (1 << 1)
+#define DSP_FAXMODE_DETECT_SQUELCH (1 << 2)
#define DSP_FAXMODE_DETECT_ALL (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)
#define DSP_TONE_STATE_SILENCE 0
Modified: team/irroot/t38gateway-1.8/main/dsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-1.8/main/dsp.c?view=diff&rev=329298&r1=329297&r2=329298
==============================================================================
--- team/irroot/t38gateway-1.8/main/dsp.c (original)
+++ team/irroot/t38gateway-1.8/main/dsp.c Fri Jul 22 10:12:48 2011
@@ -475,6 +475,10 @@
{
ast_tone_detect_init(&s->cng_tone_state, FAX_TONE_CNG_FREQ, FAX_TONE_CNG_DURATION, FAX_TONE_CNG_DB);
ast_tone_detect_init(&s->ced_tone_state, FAX_TONE_CED_FREQ, FAX_TONE_CED_DURATION, FAX_TONE_CED_DB);
+ if (s->faxmode & DSP_FAXMODE_DETECT_SQUELCH) {
+ s->cng_tone_state.squelch = 1;
+ s->ced_tone_state.squelch = 1;
+ }
}
static void ast_dtmf_detect_init (dtmf_detect_state_t *s)
@@ -1640,9 +1644,9 @@
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
{
if (dsp->faxmode != faxmode) {
+ dsp->faxmode = faxmode;
ast_fax_detect_init(dsp);
}
- dsp->faxmode = faxmode;
return 0;
}
Modified: team/irroot/t38gateway-1.8/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-1.8/res/res_fax.c?view=diff&rev=329298&r1=329297&r2=329298
==============================================================================
--- team/irroot/t38gateway-1.8/res/res_fax.c (original)
+++ team/irroot/t38gateway-1.8/res/res_fax.c Fri Jul 22 10:12:48 2011
@@ -232,6 +232,9 @@
or a directly specified list of frequencies and durations.</para>
<para>If not specified silence is generated.</para>
</parameter>
+ <parameter name="noise" required="false">
+ <para>Number of ms noise detected before proceeding with the dialplan.</para>
+ </parameter>
</syntax>
<description>
<para>This application sets FAXOPT(status) To SUCCESS | FAILURE | ERROR</para>
@@ -3087,10 +3090,11 @@
* \param chan channel to run fax detect on
* \param timeout maximum time to wait for fax detection
* \return 0 if nothing was detected 1 on CNG detected 2 if T38 negotiation is started -1 on error*/
-static int do_waitfax_exec(struct ast_channel *chan, int timeout)
+static int do_waitfax_exec(struct ast_channel *chan, int timeout, int noiselim)
{
int timeleft = timeout;
int res = 0;
+ int dspnoise = 0;
struct ast_dsp *dsp = NULL;
struct ast_frame *f;
enum ast_t38_state t38state = T38_STATE_UNKNOWN;
@@ -3101,8 +3105,6 @@
orig_read_format = chan->readformat;
switch (chan->readformat) {
case AST_FORMAT_SLINEAR:
- case AST_FORMAT_ALAW:
- case AST_FORMAT_ULAW:
break;
default:
if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
@@ -3112,7 +3114,8 @@
if ((dsp = ast_dsp_new())) {
ast_dsp_set_features(dsp, DSP_FEATURE_FAX_DETECT);
- ast_dsp_set_faxmode(dsp, DSP_FAXMODE_DETECT_CNG);
+ ast_dsp_set_faxmode(dsp, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_SQUELCH);
+ ast_dsp_set_threshold(dsp, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
} else {
return -1;
}
@@ -3129,8 +3132,11 @@
f = ast_dsp_process(chan, dsp, f);
if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == 'f')) {
res = 1;
- ast_dsp_free(dsp);
- dsp = NULL;
+ } else if ((f->frametype == AST_FRAME_VOICE) && (noiselim > 0)) {
+ ast_dsp_noise(dsp, f, &dspnoise);
+ if (dspnoise > noiselim) {
+ break;
+ }
}
}
@@ -3180,7 +3186,8 @@
static int waitfax_exec(struct ast_channel *chan, const char *data)
{
int res = 0;
- int timeout = 0;
+ unsigned int timeout;
+ unsigned int noiselim;
int ptres = -1;
char *parse;
struct ast_fax_session_details *details;
@@ -3190,6 +3197,7 @@
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(timeout);
AST_APP_ARG(tone);
+ AST_APP_ARG(noise);
);
if (!(details = find_or_create_details(chan))) {
@@ -3200,8 +3208,10 @@
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
- if (args.timeout) {
- timeout = atoi(args.timeout) * 1000;
+ if (!ast_strlen_zero(args.timeout) && sscanf(args.timeout, "%u", &timeout) == 1) {
+ timeout = timeout * 1000;
+ } else {
+ timeout = 0;
}
if (timeout <= 0) {
@@ -3210,6 +3220,10 @@
ast_log(LOG_ERROR, "Application WaitFAX requires a valid timeout\n");
ao2_ref(details, -1);
return 0;
+ }
+
+ if (ast_strlen_zero(args.noise) || sscanf(args.noise, "%u", &noiselim) != 1) {
+ noiselim = 0;
}
if (chan->_state != AST_STATE_UP) {
@@ -3231,7 +3245,7 @@
silgen = ast_channel_start_silence_generator(chan);
}
- res = do_waitfax_exec(chan, timeout);
+ res = do_waitfax_exec(chan, timeout, noiselim);
/* stop silgen or tones if present */
if (silgen) {
More information about the asterisk-commits
mailing list