[asterisk-commits] irroot: branch irroot/t38gateway-trunk r326208 - /team/irroot/t38gateway-trun...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 4 08:38:02 CDT 2011
Author: irroot
Date: Mon Jul 4 08:37:57 2011
New Revision: 326208
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=326208
Log:
Add Noise detection to waitfax to allow determining voice
Modified:
team/irroot/t38gateway-trunk/res/res_fax.c
Modified: team/irroot/t38gateway-trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/res/res_fax.c?view=diff&rev=326208&r1=326207&r2=326208
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax.c Mon Jul 4 08:37:57 2011
@@ -234,6 +234,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>
@@ -3018,10 +3021,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;
@@ -3043,7 +3047,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;
}
@@ -3062,6 +3067,11 @@
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;
+ }
}
}
@@ -3112,6 +3122,7 @@
{
int res = 0;
int timeout = 0;
+ int noiselim = 0;
int ptres = -1;
char *parse;
struct ast_fax_session_details *details;
@@ -3121,6 +3132,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))) {
@@ -3133,6 +3145,10 @@
if (args.timeout) {
timeout = atoi(args.timeout) * 1000;
+ }
+
+ if (args.noise) {
+ noiselim = atoi(args.noise);
}
if (timeout <= 0) {
@@ -3162,7 +3178,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