[asterisk-commits] tilghman: branch 1.6.2 r264205 - in /branches/1.6.2: ./ main/dsp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 19 11:44:11 CDT 2010


Author: tilghman
Date: Wed May 19 11:44:06 2010
New Revision: 264205

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=264205
Log:
Merged revisions 264204 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r264204 | tilghman | 2010-05-19 11:42:20 -0500 (Wed, 19 May 2010) | 9 lines
  
  Keep track of digit duration, when we're decoding inband to pass DTMF frames.
  
  (closes issue #17235)
   Reported by: frawd
   Patches: 
         new_dtmf_dsp_len.patch uploaded by frawd (license 610)
         20100518__issue17235.diff.txt uploaded by tilghman (license 14)
   Tested by: frawd
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/main/dsp.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/main/dsp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/dsp.c?view=diff&rev=264205&r1=264204&r2=264205
==============================================================================
--- branches/1.6.2/main/dsp.c (original)
+++ branches/1.6.2/main/dsp.c Wed May 19 11:44:06 2010
@@ -274,6 +274,10 @@
 {
 	char digits[MAX_DTMF_DIGITS + 1];
 	int current_digits;
+	/* Store lengths separately, because next digit may begin before last has
+	 * ended (because hits_to_begin may be less than misses_to_end). */
+	int digitlen[MAX_DTMF_DIGITS + 1];
+	int current_len;
 	int detected_digits;
 	int lost_digits;
 
@@ -511,6 +515,7 @@
 static void ast_digit_detect_init(digit_detect_state_t *s, int mf)
 {
 	s->current_digits = 0;
+	s->current_len = 0;
 	s->detected_digits = 0;
 	s->lost_digits = 0;
 	s->digits[0] = '\0';
@@ -630,6 +635,7 @@
 {
 	s->detected_digits++;
 	if (s->current_digits < MAX_DTMF_DIGITS) {
+		s->digitlen[s->current_digits] = 0;
 		s->digits[s->current_digits++] = digit;
 		s->digits[s->current_digits] = '\0';
 	} else {
@@ -733,6 +739,8 @@
 				}
 			} else {
 				s->td.dtmf.misses = 0;
+				/* Current hit was same as last, so increment digit duration */
+				s->digitlen[s->current_len] += DTMF_GSIZE;
 			}
 		}
 
@@ -1395,7 +1403,7 @@
 			digit = dtmf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
 
 		if (dsp->digit_state.current_digits) {
-			int event = 0;
+			int event = 0, event_len = 0;
 			char event_digit = 0;
 
 			if (!dsp->dtmf_began) {
@@ -1412,9 +1420,12 @@
 				if (dsp->features & DSP_FEATURE_DIGIT_DETECT) {
 					event = AST_FRAME_DTMF_END;
 					event_digit = dsp->digit_state.digits[0];
+					event_len = dsp->digit_state.digitlen[0] * 1000 / SAMPLE_RATE;
 				}
-				memmove(dsp->digit_state.digits, dsp->digit_state.digits + 1, dsp->digit_state.current_digits);
+				memmove(&dsp->digit_state.digits[0], &dsp->digit_state.digits[1], dsp->digit_state.current_digits);
 				dsp->digit_state.current_digits--;
+				memmove(&dsp->digit_state.digitlen[0], &dsp->digit_state.digitlen[1], dsp->digit_state.current_len * sizeof(dsp->digit_state.digitlen[0]));
+				dsp->digit_state.current_len--;
 				dsp->dtmf_began = 0;
 
 				if (dsp->features & DSP_FEATURE_BUSY_DETECT) {
@@ -1429,6 +1440,7 @@
 				memset(&dsp->f, 0, sizeof(dsp->f));
 				dsp->f.frametype = event;
 				dsp->f.subclass = event_digit;
+				dsp->f.len = event_len;
 				outf = &dsp->f;
 				goto done;
 			}




More information about the asterisk-commits mailing list