]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSCORE-545
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Feb 2010 16:20:12 +0000 (16:20 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Feb 2010 16:20:12 +0000 (16:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16553 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr_bridge.c

index 543851c795be9786153bb5efe008b753fe4e62cf..57649ccecbd63205339747950acfe9c1ca5906b0 100644 (file)
@@ -733,7 +733,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
 
                switch_channel_set_variable(channel, SWITCH_UUID_BRIDGE, NULL);
 
-               switch_channel_wait_for_state(channel, other_channel, CS_RESET);
+               switch_channel_wait_for_state(other_channel, channel, CS_RESET);
 
                if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) {
                        switch_core_session_rwunlock(other_session);
@@ -745,7 +745,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
                        switch_channel_set_state(other_channel, CS_SOFT_EXECUTE);
                }
 
-               switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE);
+               switch_channel_wait_for_state(other_channel, channel, CS_SOFT_EXECUTE);
 
                switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
 
@@ -833,15 +833,41 @@ static switch_status_t sb_on_dtmf(switch_core_session_t *session, const switch_d
        return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t hanguphook(switch_core_session_t *session)
+{
+       switch_core_session_message_t msg = { 0 };
+       switch_channel_t *channel = NULL;
+
+       channel = switch_core_session_get_channel(session); 
+
+       msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
+       msg.from = __FILE__;
+       msg.string_arg = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
+       
+       switch_core_session_receive_message(session, &msg);
+       switch_core_event_hook_remove_state_change(session, hanguphook);
+
+       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;
+       switch_core_session_message_t msg = { 0 };
 
        channel = switch_core_session_get_channel(session);
        switch_assert(channel != NULL);
 
+       msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
+       msg.from = __FILE__;
+       msg.string_arg = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
+
+       switch_core_event_hook_add_state_change(session, hanguphook);
+
+       switch_core_session_receive_message(session, &msg);
+
        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);
@@ -1180,7 +1206,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
                                switch_xml_t cdr;
                                char *xml_text;
                                
-                               switch_channel_wait_for_state(caller_channel, peer_channel, CS_DESTROY);
+                               switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY);
 
                                if (switch_ivr_generate_xml_cdr(peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
                                        if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) {