[Freeswitch-svn] [commit] r5341 - in freeswitch/trunk: conf src/mod/applications/mod_soundtouch

Freeswitch SVN anthm at freeswitch.org
Wed Jun 13 11:19:17 EDT 2007


Author: anthm
Date: Wed Jun 13 11:19:16 2007
New Revision: 5341

Modified:
   freeswitch/trunk/conf/default_context.xml
   freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp

Log:
update

Modified: freeswitch/trunk/conf/default_context.xml
==============================================================================
--- freeswitch/trunk/conf/default_context.xml	(original)
+++ freeswitch/trunk/conf/default_context.xml	Wed Jun 13 11:19:16 2007
@@ -28,6 +28,7 @@
 	   a.k.a. by the dtmf of the A leg.
 	   if it were 'recv' then it would be parsed when the dtmf was 
 	   received *from* the b leg so it could control itself.
+	   The optional keywords "read" and "write" will also change the stream replaced
       -->
       <action application="set" data="bridge_pre_execute_bleg_data=send -4s"/>
       <action application="bridge" data="sofia/$${domain}/foo"/>

Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	(original)
+++ freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	Wed Jun 13 11:19:16 2007
@@ -46,6 +46,7 @@
     SoundTouch *st;
     switch_core_session_t *session;
     int send;
+    int read;
     float pitch;
     float octaves;
     float semi;
@@ -208,6 +209,7 @@
 	case SWITCH_ABC_TYPE_READ:
 	case SWITCH_ABC_TYPE_WRITE:
         break;
+	case SWITCH_ABC_TYPE_READ_REPLACE:
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
         {
             switch_frame_t *frame;
@@ -215,7 +217,12 @@
             assert(sth != NULL);
             assert(sth->st != NULL);
 
-            frame = switch_core_media_bug_get_write_replace_frame(bug);
+            if (sth->read) {
+                frame = switch_core_media_bug_get_read_replace_frame(bug);
+            } else {
+                frame = switch_core_media_bug_get_write_replace_frame(bug);
+            }
+
             sth->st->putSamples((SAMPLETYPE *)frame->data, frame->samples);
 
             if (sth->st->numSamples() >= frame->samples * 2) {
@@ -224,9 +231,12 @@
             } else {
                 memset(frame->data, 0, frame->datalen);
             }
-            
-            switch_core_media_bug_set_write_replace_frame(bug, frame);
-            
+
+            if (sth->read) {
+                switch_core_media_bug_set_read_replace_frame(bug, frame);
+            } else {
+                switch_core_media_bug_set_write_replace_frame(bug, frame);
+            }
             
         }
 	default:
@@ -258,14 +268,15 @@
 
 	if (data && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
-        if (!strcasecmp(argv[0], "send") && argc >= 1) {
-            sth->send = 1;
-        } else {
-            sth->send = 0;
-        }
-        
-        for(x = 1; x < argc; x++) {
-            if (strchr(argv[x], 'p')) {
+        sth->send = 0;
+        sth->read = 0;
+        sth->pitch = 1;
+        for(x = 0; x < argc; x++) {
+            if (!strncasecmp(argv[x], "send", 4)) {
+                sth->send = 1;
+            } else if (!strncasecmp(argv[x], "read", 4)) {
+                sth->read = 1;
+            } else if (strchr(argv[x], 'p')) {
                 if ((sth->pitch = atof(argv[x]) < 0)) {
                     sth->pitch = 0;
                 }
@@ -286,7 +297,8 @@
 
     sth->session = session;
 
-	if ((status = switch_core_media_bug_add(session, soundtouch_callback, sth, 0, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+	if ((status = switch_core_media_bug_add(session, soundtouch_callback, sth, 0, 
+                                            sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure!\n");
 		return;
 	}



More information about the Freeswitch-svn mailing list