From: Automerge script Date: Thu, 4 Oct 2012 20:27:21 +0000 (+0000) Subject: Merged revisions 374476,374481 via svnmerge from X-Git-Tag: 10.10.0-digiumphones-rc1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e40066e9193c97c5c925d6025856b10e0174d6e6;p=thirdparty%2Fasterisk.git Merged revisions 374476,374481 via svnmerge from file:///srv/subversion/repos/asterisk/branches/10 ................ r374476 | alecdavis | 2012-10-04 15:05:14 -0500 (Thu, 04 Oct 2012) | 13 lines dsp.c fix incorrect DTMF Digit_Duration. it's always short by 'hits_to_begin*DTMF_GSIZE', or 25.5ms if hitstobegin=2 (issue ASTERISK-16003) Tested by: alecdavis alecdavis (license 585) Review https://reviewboard.asterisk.org/r/2145/ ........ Merged revisions 374475 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ................ r374481 | alecdavis | 2012-10-04 15:17:16 -0500 (Thu, 04 Oct 2012) | 17 lines dsp.c User Configurable DTMF_HITS_TO_BEGIN and DTMF_MISSES_TO_END Instead of a recompile, allow values to be adjusted in dsp.conf For binary distributions allows easy adjustment for wobbly GSM calls, and other reasons. Defaults to DTMF_HITS_TO_BEGIN=2 and DTMF_MISSES_TO_END=3 (closes issue ASTERISK-17493) Tested by: alecdavis alecdavis (license 585) Review https://reviewboard.asterisk.org/r/2144/ ........ Merged revisions 374479 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@374508 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/CHANGES b/CHANGES index b73d0dddf5..5ddbd66148 100644 --- a/CHANGES +++ b/CHANGES @@ -893,8 +893,9 @@ Miscellaneous rate changes during translation are now avoided unless absolutely necessary. * The addition of the res_stun_monitor module for monitoring and reacting to network changes while behind a NAT. - * The DTMF Normal and Reverse Twist acceptance values can be set in dsp.conf. - This allows support for any Administration. Default is AT&T values. + * DTMF: Normal and Reverse Twist acceptance values can be set in dsp.conf. + DTMF Valid/Invalid number of hits/misses can be set in dsp.conf. + These allow support for any Administration. Default is AT&T values. CLI Changes ----------- diff --git a/configs/dsp.conf.sample b/configs/dsp.conf.sample index 95cb9796ef..08c5a5715d 100644 --- a/configs/dsp.conf.sample +++ b/configs/dsp.conf.sample @@ -36,3 +36,8 @@ ;dtmf_reverse_twist=2.51 ;relax_dtmf_normal_twist=6.31 ;relax_dtmf_reverse_twist=3.98 + +;successive number hits/misses of 12.75ms before a digit/nodigit is considered valid +;dtmf_hits_to_begin=2 +;dtmf_misses_to_end=3 + diff --git a/main/dsp.c b/main/dsp.c index 6de9d020c7..072f9c550e 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -210,10 +210,15 @@ enum gsamp_thresh { /* DTMF goertzel size */ #define DTMF_GSIZE 102 -/* How many successive hits needed to consider begin of a digit */ -#define DTMF_HITS_TO_BEGIN 2 -/* How many successive misses needed to consider end of a digit */ -#define DTMF_MISSES_TO_END 3 +/* How many successive hits needed to consider begin of a digit + * IE. Override with dtmf_hits_to_begin=4 in dsp.conf + */ +#define DEF_DTMF_HITS_TO_BEGIN 2 + +/* How many successive misses needed to consider end of a digit + * IE. Override with dtmf_misses_to_end=4 in dsp.conf + */ +#define DEF_DTMF_MISSES_TO_END 3 /*! * \brief The default silence threshold we will use if an alternate @@ -258,8 +263,6 @@ typedef struct { goertzel_state_t row_out[4]; goertzel_state_t col_out[4]; - int hits_to_begin; /* How many successive hits needed to consider begin of a digit */ - int misses_to_end; /* How many successive misses needed to consider end of a digit */ int hits; /* How many successive hits we have seen already */ int misses; /* How many successive misses we have seen already */ int lasthit; @@ -308,6 +311,8 @@ static float dtmf_normal_twist; /* AT&T = 8dB */ static float dtmf_reverse_twist; /* AT&T = 4dB */ static float relax_dtmf_normal_twist; /* AT&T = 8dB */ static float relax_dtmf_reverse_twist; /* AT&T = 6dB */ +static int dtmf_hits_to_begin; /* How many successive hits needed to consider begin of a digit */ +static int dtmf_misses_to_end; /* How many successive misses needed to consider end of a digit */ static inline void goertzel_sample(goertzel_state_t *s, short sample) { @@ -501,9 +506,6 @@ static void ast_dtmf_detect_init (dtmf_detect_state_t *s, unsigned int sample_ra s->current_sample = 0; s->hits = 0; s->misses = 0; - - s->hits_to_begin = DTMF_HITS_TO_BEGIN; - s->misses_to_end = DTMF_MISSES_TO_END; } static void ast_mf_detect_init (mf_detect_state_t *s, unsigned int sample_rate) @@ -793,7 +795,7 @@ static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp /* We are in the middle of a digit already */ if (hit != s->td.dtmf.current_hit) { s->td.dtmf.misses++; - if (s->td.dtmf.misses == s->td.dtmf.misses_to_end) { + if (s->td.dtmf.misses == dtmf_misses_to_end) { /* There were enough misses to consider digit ended */ s->td.dtmf.current_hit = 0; } @@ -814,8 +816,9 @@ static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp } if (hit && hit != s->td.dtmf.current_hit) { s->td.dtmf.hits++; - if (s->td.dtmf.hits == s->td.dtmf.hits_to_begin) { + if (s->td.dtmf.hits == dtmf_hits_to_begin) { store_digit(s, hit); + s->digitlen[s->current_digits - 1] = dtmf_hits_to_begin * DTMF_GSIZE; s->td.dtmf.current_hit = hit; s->td.dtmf.misses = 0; } @@ -1842,6 +1845,8 @@ static int _dsp_init(int reload) dtmf_reverse_twist = DEF_DTMF_REVERSE_TWIST; relax_dtmf_normal_twist = DEF_RELAX_DTMF_NORMAL_TWIST; relax_dtmf_reverse_twist = DEF_RELAX_DTMF_REVERSE_TWIST; + dtmf_hits_to_begin = DEF_DTMF_HITS_TO_BEGIN; + dtmf_misses_to_end = DEF_DTMF_MISSES_TO_END; if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { return 0; @@ -1888,6 +1893,22 @@ static int _dsp_init(int reload) } else { relax_dtmf_reverse_twist = cfg_twist; } + } else if (!strcasecmp(v->name, "dtmf_hits_to_begin")) { + if (sscanf(v->value, "%30d", &cfg_threshold) < 1) { + ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value); + } else if (cfg_threshold < 1) { /* must be 1 or greater */ + ast_log(LOG_WARNING, "Invalid dtmf_hits_to_begin value '%d' specified, using default of %d\n", cfg_threshold, dtmf_hits_to_begin); + } else { + dtmf_hits_to_begin = cfg_threshold; + } + } else if (!strcasecmp(v->name, "dtmf_misses_to_end")) { + if (sscanf(v->value, "%30d", &cfg_threshold) < 1) { + ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value); + } else if (cfg_threshold < 1) { /* must be 1 or greater */ + ast_log(LOG_WARNING, "Invalid dtmf_misses_to_end value '%d' specified, using default of %d\n", cfg_threshold, dtmf_misses_to_end); + } else { + dtmf_misses_to_end = cfg_threshold; + } } } ast_config_destroy(cfg);