[Freeswitch-svn] [commit] r10454 - freeswitch/trunk/src

FreeSWITCH SVN anthm at freeswitch.org
Tue Nov 18 18:40:59 PST 2008


Author: anthm
Date: Tue Nov 18 21:40:59 2008
New Revision: 10454

Log:
add hits to tone_detect

Modified:
   freeswitch/trunk/src/switch_ivr_async.c

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Tue Nov 18 21:40:59 2008
@@ -1195,7 +1195,7 @@
 	int total_hits;
 	int hits;
 	int sleep;
-	time_t expires;
+	int expires;
 } switch_tone_detect_t;
 
 typedef struct {
@@ -1217,36 +1217,49 @@
 	case SWITCH_ABC_TYPE_CLOSE:
 		break;
 	case SWITCH_ABC_TYPE_READ_REPLACE:
-		frame = switch_core_media_bug_get_read_replace_frame(bug);
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
 		{
-			
-			if (!frame) {
+			int skip = 0;
+
+			if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
+				frame = switch_core_media_bug_get_read_replace_frame(bug);
+			} else {
 				frame = switch_core_media_bug_get_write_replace_frame(bug);
 			}
 
+
+
 			for (i = 0; i < cont->index; i++) {
-				if (cont->list[i].expires && cont->list[i].expires < switch_timestamp(NULL)) {
-					cont->list[i].hits = 0;
-					cont->list[i].sleep = 0;
-					cont->list[i].expires = 0;
-				}
 
 				if (cont->list[i].sleep) {
 					cont->list[i].sleep--;
-					return SWITCH_TRUE;
+					if (cont->list[i].sleep) {
+						skip = 1;
+					}
 				}
-				if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
-					switch_event_t *event;
 
-					cont->list[i].up = cont->list[i].hits++;
-					cont->list[i].sleep = 25;
-					cont->list[i].expires = switch_timestamp(NULL) + 5;
-					teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
+				if (cont->list[i].expires) {
+					cont->list[i].expires--;
+					if (!cont->list[i].expires) {
+						cont->list[i].hits = 0;
+						cont->list[i].sleep = 0;
+						cont->list[i].expires = 0;
+					}
+				}
+				
+				if (!cont->list[i].up) skip = 1;
+
+				if (skip) return SWITCH_TRUE;
+				
+				if (teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
+					switch_event_t *event;
+					cont->list[i].hits++;
+					
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s HIT %d/%d\n", 
-									  cont->list[i].key, cont->list[i].up, cont->list[i].hits);
+									  cont->list[i].key, cont->list[i].hits, cont->list[i].total_hits);
+					cont->list[i].sleep = 50;
+					cont->list[i].expires = 250;
 					
-
 					if (cont->list[i].hits >= cont->list[i].total_hits) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key);
 						cont->list[i].up = 0;
@@ -1332,7 +1345,6 @@
 				cont->list[i].hits = 0;
 				cont->list[i].sleep = 0;
 				cont->list[i].expires = 0;
-				teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
 				return SWITCH_STATUS_SUCCESS;
 			}
 		}
@@ -1403,7 +1415,7 @@
 			bflags |= SMBF_WRITE_REPLACE;
 		}
 	}
-
+	
 	if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}



More information about the Freeswitch-svn mailing list