[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r328539 - /team/irroot/distrot...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 17 10:51:23 CDT 2011


Author: irroot
Date: Sun Jul 17 10:51:17 2011
New Revision: 328539

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=328539
Log:
Squelch faxtone detect voice

Modified:
    team/irroot/distrotech-customers-1.8/res/res_fax.c

Modified: team/irroot/distrotech-customers-1.8/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/res/res_fax.c?view=diff&rev=328539&r1=328538&r2=328539
==============================================================================
--- team/irroot/distrotech-customers-1.8/res/res_fax.c (original)
+++ team/irroot/distrotech-customers-1.8/res/res_fax.c Sun Jul 17 10:51:17 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;
 	}
@@ -3131,6 +3134,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;
+				}
 			}
 		}
 
@@ -3181,6 +3189,7 @@
 {
 	int res = 0;
 	int timeout = 0;
+	int noiselim = 0;
 	int ptres = -1;
 	char *parse;
 	struct ast_fax_session_details *details;
@@ -3190,6 +3199,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))) {
@@ -3202,6 +3212,10 @@
 
 	if (args.timeout) {
 		timeout = atoi(args.timeout) * 1000;
+	}
+
+	if (args.noise) {
+		noiselim = atoi(args.noise);
 	}
 
 	if (timeout <= 0) {
@@ -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