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

Freeswitch SVN anthm at freeswitch.org
Thu Dec 27 17:24:30 EST 2007


Author: anthm
Date: Thu Dec 27 17:24:30 2007
New Revision: 6996

Modified:
   freeswitch/trunk/src/switch_ivr_bridge.c

Log:
adj

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Thu Dec 27 17:24:30 2007
@@ -236,7 +236,8 @@
 {
 	switch_channel_t *channel = NULL;
 	switch_ivr_bridge_data_t *bd;
-
+	switch_channel_state_t state;
+	
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
 
@@ -252,9 +253,11 @@
 	}
 	switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
 
-	if (!switch_channel_test_flag(channel, CF_TRANSFER) && switch_channel_get_state(channel) == CS_LOOPBACK) {
+	state = switch_channel_get_state(channel);
+
+	if (!switch_channel_test_flag(channel, CF_TRANSFER) && state != CS_PARK && state != CS_RING) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-	} 
+	}
 
 	return SWITCH_STATUS_FALSE;
 }
@@ -328,6 +331,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM TRANSMIT\n", switch_channel_get_name(channel));
 	switch_channel_clear_state_handler(channel, NULL);
 
+	switch_channel_clear_flag(channel, CF_TRANSFER);
 
 	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		return SWITCH_STATUS_SUCCESS;
@@ -553,7 +557,8 @@
 	switch_channel_t *caller_channel, *peer_channel;
 	int stream_id = 0;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	
+	switch_channel_state_t state;
+
 	switch_assert(session != NULL);
 	switch_assert(peer_session != NULL);
 
@@ -565,6 +570,9 @@
 	peer_channel = switch_core_session_get_channel(peer_session);
 	switch_assert(peer_channel != NULL);
 
+	switch_channel_clear_flag(caller_channel, CF_TRANSFER);
+	switch_channel_clear_flag(peer_channel, CF_TRANSFER);
+
 	a_leg = switch_core_session_alloc(session, sizeof(*a_leg));
 	b_leg = switch_core_session_alloc(peer_session, sizeof(*b_leg));
 	
@@ -660,6 +668,7 @@
 			if (!switch_channel_test_flag(peer_channel, CF_TRANSFER) && switch_channel_get_state(peer_channel) == CS_LOOPBACK) {
 				switch_channel_set_state(peer_channel, CS_RESET);
 			}
+
 			while (switch_channel_get_state(peer_channel) == CS_LOOPBACK) {
 				switch_yield(1000);
 			}
@@ -682,10 +691,12 @@
 
   done:
 
+	state = switch_channel_get_state(caller_channel);
+	
 	if (!switch_channel_test_flag(caller_channel, CF_TRANSFER)) {
-		if (switch_channel_test_flag(peer_channel, CF_ANSWERED) && 
-			switch_channel_get_state(caller_channel) < CS_HANGUP && 
-			switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
+		if ((state != CS_EXECUTE && state != CS_PARK && state != CS_RING) || 
+			(switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP && 
+			 switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE)))) {
 			switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
 		}
 	}



More information about the Freeswitch-svn mailing list