]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make bridge_terminate_key work in bypass media when using info dtmf
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 28 Jan 2010 17:10:23 +0000 (17:10 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 28 Jan 2010 17:10:23 +0000 (17:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16530 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_dptools/mod_dptools.c
src/switch_ivr_bridge.c

index 62fbfb133a189f059d920b0fa4731e5349ed0a61..f148f672a4c359f22b19ebbdaa93631bb175dcac 100644 (file)
@@ -2439,8 +2439,8 @@ SWITCH_STANDARD_APP(audio_bridge_function)
                        if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) {
                                switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
                        }
-
-                       switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, a_key);
+                       
+                       switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
                }
                
                if (peer_session) {
index 45cf3dc6ffcc1969d35886cdf182a340c22105ba..543851c795be9786153bb5efe008b753fe4e62cf 100644 (file)
@@ -803,13 +803,50 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
        return SWITCH_STATUS_FALSE;
 }
 
+static switch_status_t sb_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
+{
+       switch_channel_t *channel = NULL;
+       char *key;
+
+       channel = switch_core_session_get_channel(session);
+       switch_assert(channel != NULL);
+       
+       if ((key = (char *) switch_channel_get_private(channel, "__bridge_term_key")) && dtmf->digit == *key) {
+               const char *uuid;
+               switch_core_session_t *other_session;
+
+               if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+                       switch_channel_set_state(channel, CS_EXECUTE);
+               } else {
+                       if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+                               switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                               switch_channel_set_state(other_channel, CS_EXECUTE);
+                               switch_core_session_rwunlock(other_session);
+                       } else {
+                               return SWITCH_STATUS_SUCCESS;
+                       }
+               }
+               
+               return SWITCH_STATUS_FALSE;
+       }
+       
+       return SWITCH_STATUS_SUCCESS;
+}
+
+
 static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session)
 {
        switch_channel_t *channel = NULL;
+       const char *key;
 
        channel = switch_core_session_get_channel(session);
        switch_assert(channel != NULL);
 
+       if ((key = switch_channel_get_variable(channel, "bridge_terminate_key"))) {
+               switch_channel_set_private(channel, "__bridge_term_key", switch_core_session_strdup(session, key));
+               switch_core_event_hook_add_recv_dtmf(session, sb_on_dtmf);
+       }
+
        switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
 
        return SWITCH_STATUS_SUCCESS;
@@ -826,6 +863,11 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session)
                switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
        }
 
+       if (switch_channel_get_private(channel, "__bridge_term_key")) {
+               switch_core_event_hook_remove_recv_dtmf(session, sb_on_dtmf);
+               switch_channel_set_private(channel, "__bridge_term_key", NULL);
+       }
+
        switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
 
        if (uuid && (other_session = switch_core_session_locate(uuid))) {