[svn-commits] oej: trunk r363558 - in /trunk: ./ configs/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Apr 25 04:32:26 CDT 2012


Author: oej
Date: Wed Apr 25 04:32:21 2012
New Revision: 363558

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363558
Log:
Make it possible to change the minimum DTMF duration in asterisk.conf

Asterisk has a setting for the minimum allowed DTMF. If we get shorter
DTMF tones, these will be changed to the minimum on the outbound call
leg. 

(closes issue ASTERISK-19772)

Review: https://reviewboard.asterisk.org/r/1882/
Reported by: oej
Tested by: oej
Patches by: oej

Thanks to the reviewers.

1.8 branch for this patch: agave-dtmf-duration-asterisk-conf-1.8


Modified:
    trunk/CHANGES
    trunk/configs/asterisk.conf.sample
    trunk/include/asterisk/options.h
    trunk/main/asterisk.c
    trunk/main/channel.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=363558&r1=363557&r2=363558
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Apr 25 04:32:21 2012
@@ -27,6 +27,9 @@
    added to any log messages produced by those threads. Log messages can now be
    easily identified as involved with a certain call by looking at their call id.
    This feature can be disabled in logger.conf with the display_callids option.
+ * The minimum DTMF duration can now be configured in asterisk.conf
+   as "mindtmfduration". The default value is (as before) set to 80 ms.
+   (previously it was only available in source code)
 
 CLI Changes
 -------------------

Modified: trunk/configs/asterisk.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/asterisk.conf.sample?view=diff&rev=363558&r1=363557&r2=363558
==============================================================================
--- trunk/configs/asterisk.conf.sample (original)
+++ trunk/configs/asterisk.conf.sample Wed Apr 25 04:32:21 2012
@@ -34,6 +34,9 @@
 ;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)
+				; If we get shorter DTMF messages, these will be
+				; changed to the minimum duration
 ;maxcalls = 10			; Maximum amount of calls allowed.
 ;maxload = 0.9			; Asterisk stops accepting new calls if the
 				; load average exceed this limit.

Modified: trunk/include/asterisk/options.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/options.h?view=diff&rev=363558&r1=363557&r2=363558
==============================================================================
--- trunk/include/asterisk/options.h (original)
+++ trunk/include/asterisk/options.h Wed Apr 25 04:32:21 2012
@@ -157,6 +157,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 unsigned 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: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=363558&r1=363557&r2=363558
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Apr 25 04:32:21 2012
@@ -157,6 +157,10 @@
 #define AST_MAX_CONNECTS 128
 #define NUM_MSGS 64
 
+/*! Default minimum 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" \
@@ -182,6 +186,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) */
+unsigned 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
@@ -487,6 +492,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::          %u\n", option_dtmfminduration);
 
 	ast_cli(a->fd, "\n* Subsystems\n");
 	ast_cli(a->fd, "  -------------\n");
@@ -3057,6 +3063,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)
@@ -3193,6 +3202,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, "%30u", &option_dtmfminduration) != 1) {
+				option_dtmfminduration = AST_MIN_DTMF_DURATION;
+			}
 		} else if (!strcasecmp(v->name, "maxcalls")) {
 			if ((sscanf(v->value, "%30d", &option_maxcalls) != 1) || (option_maxcalls < 0)) {
 				option_maxcalls = 0;

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=363558&r1=363557&r2=363558
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed Apr 25 04:32:21 2012
@@ -103,9 +103,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 */
@@ -3868,10 +3865,10 @@
 					ast_channel_dtmf_digit_to_emulate_set(chan, f->subclass.integer);
 					ast_channel_dtmf_tv_set(chan, &tv);
 					if (f->len) {
-						if (f->len > AST_MIN_DTMF_DURATION)
+						if (f->len > option_dtmfminduration)
 							ast_channel_emulate_dtmf_duration_set(chan, f->len);
 						else
-							ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION);
+							ast_channel_emulate_dtmf_duration_set(chan, option_dtmfminduration);
 					} else
 						ast_channel_emulate_dtmf_duration_set(chan, AST_DEFAULT_EMULATE_DTMF_DURATION);
 					ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
@@ -3895,31 +3892,31 @@
 
 					/* detect tones that were received on
 					 * the wire with durations shorter than
-					 * AST_MIN_DTMF_DURATION and set f->len
+					 * option_dtmfminduration and set f->len
 					 * to the actual duration of the DTMF
 					 * frames on the wire.  This will cause
 					 * dtmf emulation to be triggered later
 					 * on.
 					 */
-					if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_DURATION) {
+					if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) < option_dtmfminduration) {
 						f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
 						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, ast_channel_name(chan));
 					}
 				} else if (!f->len) {
 					ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
-					f->len = AST_MIN_DTMF_DURATION;
+					f->len = option_dtmfminduration;
 				}
-				if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(ast_channel_flags(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, ast_channel_name(chan));
+				if (f->len < option_dtmfminduration && !ast_test_flag(ast_channel_flags(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, ast_channel_name(chan));
 					ast_set_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF);
 					ast_channel_dtmf_digit_to_emulate_set(chan, f->subclass.integer);
-					ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION - f->len);
+					ast_channel_emulate_dtmf_duration_set(chan, 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, ast_channel_name(chan));
-					if (f->len < AST_MIN_DTMF_DURATION) {
-						f->len = AST_MIN_DTMF_DURATION;
+					if (f->len < option_dtmfminduration) {
+						f->len = option_dtmfminduration;
 					}
 					ast_channel_dtmf_tv_set(chan, &now);
 				}




More information about the svn-commits mailing list