Revision
16553
Author
anthm
Date
2010-02-02 10:20:12 -0600 (Tue, 02 Feb 2010)

Log Message

FSCORE-545

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (16552 => 16553)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2010-02-02 15:16:28 UTC (rev 16552)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2010-02-02 16:20:12 UTC (rev 16553)
@@ -733,7 +733,7 @@
 
 		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 @@
 			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 @@
 	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_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))) {