[asterisk-commits] oej: branch oej/agave-dtmf-duration-asterisk-conf-1.8 r363318 - in /team/oej/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 24 03:37:43 CDT 2012


Author: oej
Date: Tue Apr 24 03:37:40 2012
New Revision: 363318

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363318
Log:
Patch to be able to set min dtmf duration WITHOUT having to change the source code.

Modified:
    team/oej/agave-dtmf-duration-asterisk-conf-1.8/configs/asterisk.conf.sample
    team/oej/agave-dtmf-duration-asterisk-conf-1.8/include/asterisk/options.h
    team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/asterisk.c
    team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/channel.c

Modified: team/oej/agave-dtmf-duration-asterisk-conf-1.8/configs/asterisk.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/agave-dtmf-duration-asterisk-conf-1.8/configs/asterisk.conf.sample?view=diff&rev=363318&r1=363317&r2=363318
==============================================================================
--- team/oej/agave-dtmf-duration-asterisk-conf-1.8/configs/asterisk.conf.sample (original)
+++ team/oej/agave-dtmf-duration-asterisk-conf-1.8/configs/asterisk.conf.sample Tue Apr 24 03:37:40 2012
@@ -33,6 +33,7 @@
 ;autosystemname = yes		; Automatically set systemname to hostname,
 				; uses 'localhost' on failure, or systemname if
 				; set.
+;mindtmfduration = 80		; Set minimum DTMF duration in ms (default 80 ms)
 ;maxcalls = 10			; Maximum amount of calls allowed.
 ;maxload = 0.9			; Asterisk stops accepting new calls if the
 				; load average exceed this limit.

Modified: team/oej/agave-dtmf-duration-asterisk-conf-1.8/include/asterisk/options.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/agave-dtmf-duration-asterisk-conf-1.8/include/asterisk/options.h?view=diff&rev=363318&r1=363317&r2=363318
==============================================================================
--- team/oej/agave-dtmf-duration-asterisk-conf-1.8/include/asterisk/options.h (original)
+++ team/oej/agave-dtmf-duration-asterisk-conf-1.8/include/asterisk/options.h Tue Apr 24 03:37:40 2012
@@ -153,6 +153,7 @@
 extern int option_maxfiles;		/*!< Max number of open file handles (files, sockets) */
 extern int option_debug;		/*!< Debugging */
 extern int option_maxcalls;		/*!< Maximum number of simultaneous channels */
+extern int option_dtmfminduration;	/*!< Minimum duration of DTMF (channel.c) in ms */
 extern double option_maxload;
 #if defined(HAVE_SYSINFO)
 extern long option_minmemfree;		/*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */

Modified: team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/asterisk.c?view=diff&rev=363318&r1=363317&r2=363318
==============================================================================
--- team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/asterisk.c (original)
+++ team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/asterisk.c Tue Apr 24 03:37:40 2012
@@ -154,6 +154,10 @@
 #define AST_MAX_CONNECTS 128
 #define NUM_MSGS 64
 
+/*! Minimum allowed DTMF digit length - 80ms */
+#define AST_MIN_DTMF_DURATION 80
+
+
 /*! \brief Welcome message when starting a CLI interface */
 #define WELCOME_MESSAGE \
     ast_verbose("Asterisk %s, Copyright (C) 1999 - 2012 Digium, Inc. and others.\n" \
@@ -179,6 +183,7 @@
 double option_maxload;				/*!< Max load avg on system */
 int option_maxcalls;				/*!< Max number of active calls */
 int option_maxfiles;				/*!< Max number of open file handles (files, sockets) */
+int option_dtmfminduration;			/*!< Minimum duration of DTMF. */
 #if defined(HAVE_SYSINFO)
 long option_minmemfree;				/*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */
 #endif
@@ -480,6 +485,7 @@
 	ast_cli(a->fd, "  Internal timing:             %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) ? "Enabled" : "Disabled");
 	ast_cli(a->fd, "  Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");
 	ast_cli(a->fd, "  Generic PLC:                 %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");
+	ast_cli(a->fd, "  Min DTMF duration::          %d\n", option_mindtmfduration);
 
 	ast_cli(a->fd, "\n* Subsystems\n");
 	ast_cli(a->fd, "  -------------\n");
@@ -2960,6 +2966,9 @@
 		unsigned int keydir:1;
 	} found = { 0, 0 };
 
+	/* Set default value */
+	option_dtmfminduration = AST_MIN_DTMF_DURATION;
+
 	if (ast_opt_override_config) {
 		cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
 		if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
@@ -3093,6 +3102,10 @@
 		/* Enable internal timing */
 		} else if (!strcasecmp(v->name, "internal_timing")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INTERNAL_TIMING);
+		} else if (!strcasecmp(v->name, "mindtmfduration")) {
+			if ((sscanf(v->value, "%30d", &option_dtmfminduration) != 1) || (option_dtmfminduration < 0)) {
+				option_dtmfminduration = 80;
+			}
 		} else if (!strcasecmp(v->name, "maxcalls")) {
 			if ((sscanf(v->value, "%30d", &option_maxcalls) != 1) || (option_maxcalls < 0)) {
 				option_maxcalls = 0;

Modified: team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/channel.c?view=diff&rev=363318&r1=363317&r2=363318
==============================================================================
--- team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/channel.c (original)
+++ team/oej/agave-dtmf-duration-asterisk-conf-1.8/main/channel.c Tue Apr 24 03:37:40 2012
@@ -102,9 +102,6 @@
 /*! Default amount of time to use when emulating a digit as a begin and end 
  *  100ms */
 #define AST_DEFAULT_EMULATE_DTMF_DURATION 100
-
-/*! Minimum allowed digit length - 80ms */
-#define AST_MIN_DTMF_DURATION 80
 
 /*! Minimum amount of time between the end of the last digit and the beginning 
  *  of a new one - 45ms */
@@ -4015,10 +4012,10 @@
 					chan->emulate_dtmf_digit = f->subclass.integer;
 					chan->dtmf_tv = ast_tvnow();
 					if (f->len) {
-						if (f->len > AST_MIN_DTMF_DURATION)
+						if (f->len > option_dtmfminduration)
 							chan->emulate_dtmf_duration = f->len;
 						else 
-							chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
+							chan->emulate_dtmf_duration = option_dtmfminduration;
 					} else
 						chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
 					ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
@@ -4048,25 +4045,25 @@
 					 * dtmf emulation to be triggered later
 					 * on.
 					 */
-					if (ast_tvdiff_ms(now, chan->dtmf_tv) < AST_MIN_DTMF_DURATION) {
+					if (ast_tvdiff_ms(now, chan->dtmf_tv) < option_dtmfminduration) {
 						f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
 						ast_log(LOG_DTMF, "DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->subclass.integer, f->len, chan->name);
 					}
 				} else if (!f->len) {
 					ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
-					f->len = AST_MIN_DTMF_DURATION;
+					f->len = option_dtmfminduration;
 				}
-				if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
-					ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
+				if (f->len < option_dtmfminduration && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
+					ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, option_dtmfminduration, chan->name);
 					ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
 					chan->emulate_dtmf_digit = f->subclass.integer;
-					chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
+					chan->emulate_dtmf_duration = option_dtmfminduration - f->len;
 					ast_frfree(f);
 					f = &ast_null_frame;
 				} else {
 					ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
-					if (f->len < AST_MIN_DTMF_DURATION) {
-						f->len = AST_MIN_DTMF_DURATION;
+					if (f->len < option_dtmfminduration) {
+						f->len = option_dtmfminduration;
 					}
 					chan->dtmf_tv = now;
 				}




More information about the asterisk-commits mailing list