[Freeswitch-svn] [commit] r10487 - in freeswitch/trunk/src: . include include/private

FreeSWITCH SVN anthm at freeswitch.org
Thu Nov 20 16:09:11 PST 2008


Author: anthm
Date: Thu Nov 20 19:09:11 2008
New Revision: 10487

Log:
code reworking do make current

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_core_codec.c
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_state_machine.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_ivr_originate.c

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Thu Nov 20 19:09:11 2008
@@ -118,6 +118,8 @@
 
 	switch_mutex_t *mutex;
 	switch_mutex_t *resample_mutex;
+	switch_mutex_t *codec_read_mutex;
+	switch_mutex_t *codec_write_mutex;
 	switch_thread_cond_t *cond;
 
 	switch_thread_rwlock_t *rwlock;

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Thu Nov 20 19:09:11 2008
@@ -732,7 +732,7 @@
 CF_ORIGINATOR	= (1 <<  3) - Channel is an originator
 CF_TRANSFER		= (1 <<  4) - Channel is being transfered
 CF_ACCEPT_CNG	= (1 <<  5) - Channel will accept CNG frames
-CF_WAIT_FOR_ME	= (1 <<  6) - Channel wants you to wait
+CF_REDIRECT 	= (1 <<  6) - Channel is being redirected
 CF_BRIDGED		= (1 <<  7) - Channel in a bridge
 CF_HOLD			= (1 <<  8) - Channel is on hold
 CF_SERVICE		= (1 <<  9) - Channel has a service thread
@@ -763,7 +763,7 @@
 	CF_ORIGINATOR = (1 << 3),
 	CF_TRANSFER = (1 << 4),
 	CF_ACCEPT_CNG = (1 << 5),
-	CF_WAIT_FOR_ME = (1 << 6),
+	CF_REDIRECT = (1 << 6),
 	CF_BRIDGED = (1 << 7),
 	CF_HOLD = (1 << 8),
 	CF_SERVICE = (1 << 9),
@@ -787,12 +787,13 @@
 	CF_PROXY_MEDIA = (1 << 27),
 	CF_INNER_BRIDGE = (1 << 28),
 	CF_REQ_MEDIA = (1 << 29),
-	CF_VERBOSE_EVENTS = (1 << 30),
-	CF_MASTER = (1 << 31)
+	CF_VERBOSE_EVENTS = (1 << 30)
 } switch_channel_flag_enum_t;
+
 typedef uint32_t switch_channel_flag_t;
 
 
+
 /*!
   \enum switch_frame_flag_t
   \brief Frame Flags

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Thu Nov 20 19:09:11 2008
@@ -841,7 +841,6 @@
 	switch_clear_flag(channel, CF_TAGGED);
 
 	if (channel->state >= CS_ROUTING) {
-		switch_clear_flag(channel, CF_TRANSFER);
 		switch_channel_presence(channel, "unknown", (char *) state_names[state], NULL);
 	}
 

Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c	(original)
+++ freeswitch/trunk/src/switch_core_codec.c	Thu Nov 20 19:09:11 2008
@@ -46,6 +46,7 @@
 {
 	switch_mutex_t *mutex = NULL;
 
+	switch_mutex_lock(session->codec_read_mutex);
 	if (session->read_codec) mutex = session->read_codec->mutex;
 	if (mutex) switch_mutex_lock(mutex);
 	session->real_read_codec = session->read_codec = NULL;
@@ -54,16 +55,19 @@
 	session->enc_read_frame.codec = session->read_codec;
 	session->enc_write_frame.codec = session->read_codec;
 	if (mutex) switch_mutex_unlock(mutex);
+	switch_mutex_unlock(session->codec_read_mutex);
 }
 
 SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
 {	
 	switch_mutex_t *mutex = NULL;
 
+	switch_mutex_lock(session->codec_write_mutex);
 	if (session->write_codec) mutex = session->write_codec->mutex;
 	if (mutex) switch_mutex_lock(mutex);
 	session->real_write_codec = session->write_codec = NULL;
 	if (mutex) switch_mutex_unlock(mutex);
+	switch_mutex_unlock(session->codec_write_mutex);
 }
 
 
@@ -74,6 +78,8 @@
 	char tmp[30];
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
+	switch_mutex_lock(session->codec_read_mutex);
+
 	if (codec && !codec->implementation) {
 		codec = NULL;
 	}
@@ -128,6 +134,7 @@
 
  end:
 
+	switch_mutex_unlock(session->codec_read_mutex);
 	return status;
 
 }
@@ -192,6 +199,8 @@
 	char tmp[30];
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
+	switch_mutex_lock(session->codec_write_mutex);
+
 	if (!codec || !codec->implementation) {
 		if (session->real_write_codec) {
 			session->write_codec = session->real_write_codec;
@@ -241,6 +250,7 @@
 	}
 
  end:
+	switch_mutex_unlock(session->codec_write_mutex);
 
 	return status;
 }

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Thu Nov 20 19:09:11 2008
@@ -110,10 +110,15 @@
 	switch_assert(session != NULL);
 
 	if (!(session->read_codec && session->read_codec->implementation)) {
+		if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_get_state(session->channel) == CS_HIBERNATE) {
+			*frame = &runtime.dummy_cng_frame;
+			return SWITCH_STATUS_SUCCESS;
+		}
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s has no read codec.\n", switch_channel_get_name(session->channel));
 		return SWITCH_STATUS_FALSE;
 	}
 
+	switch_mutex_lock(session->codec_read_mutex);
 	switch_mutex_lock(session->read_codec->mutex);
 
   top:
@@ -521,7 +526,8 @@
 	}
 
 	switch_mutex_unlock(session->read_codec->mutex);
-	
+	switch_mutex_unlock(session->codec_read_mutex);
+
 	return status;
 }
 
@@ -588,7 +594,8 @@
 	}
 	switch_mutex_lock(session->write_codec->mutex);
 	switch_mutex_lock(frame->codec->mutex);
-	
+	switch_mutex_lock(session->codec_write_mutex);	
+
 	if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
 		need_codec = TRUE;
 		if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
@@ -977,7 +984,8 @@
 
 	switch_mutex_unlock(session->write_codec->mutex);
 	switch_mutex_unlock(frame->codec->mutex);
-	
+	switch_mutex_unlock(session->codec_write_mutex);
+
 	return status;
 }
 

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Thu Nov 20 19:09:11 2008
@@ -747,6 +747,7 @@
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_size_t has;
 
+
 	switch_core_session_set_read_codec(session, NULL);
 
 	/* clear resamplers */
@@ -1102,6 +1103,8 @@
 
 	switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
 	switch_mutex_init(&session->resample_mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_mutex_init(&session->codec_read_mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_mutex_init(&session->codec_write_mutex, SWITCH_MUTEX_NESTED, session->pool);
 	switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
 	switch_thread_cond_create(&session->cond, session->pool);
 	switch_thread_rwlock_create(&session->rwlock, session->pool);

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Thu Nov 20 19:09:11 2008
@@ -165,7 +165,7 @@
 	}
 
 	if (switch_channel_get_state(session->channel) == CS_EXECUTE) {
-		switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);		
 	}
 }
 
@@ -185,7 +185,6 @@
 {
 	switch_assert(session != NULL);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard PARK\n", switch_channel_get_name(session->channel));
-	switch_channel_clear_flag(session->channel, CF_TRANSFER);
 	switch_core_session_reset(session, SWITCH_TRUE);
 	switch_ivr_park(session, NULL);
 }
@@ -373,6 +372,7 @@
 			int do_extra_handlers = 1;
 
 			switch_channel_set_running_state(session->channel, state);
+			switch_channel_clear_flag(session->channel, CF_TRANSFER);
 
 			switch (state) {
 			case CS_NEW:		/* Just created, Waiting for first instructions */

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Thu Nov 20 19:09:11 2008
@@ -140,7 +140,8 @@
 	switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
 
 	if (!switch_channel_test_flag(chan_b, CF_BRIDGED)) {
-		if (!(switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_get_state(chan_b) == CS_RESET)) {
+		if (!(switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_REDIRECT) 
+			  || switch_channel_get_state(chan_b) == CS_RESET)) {
 			switch_channel_hangup(chan_b, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		}
 		goto end_of_bridge_loop;
@@ -208,11 +209,11 @@
 			goto end_of_bridge_loop;
 		}
 
-		if (switch_channel_test_flag(chan_a, CF_TRANSFER)) {
+		if (switch_channel_test_flag(chan_a, CF_TRANSFER) || switch_channel_test_flag(chan_a, CF_REDIRECT)) {
 			data->clean_exit = 1;
 		}
 
-		if (data->clean_exit || switch_channel_test_flag(chan_b, CF_TRANSFER)) {
+		if (data->clean_exit || switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_REDIRECT)) {
 			switch_channel_clear_flag(chan_a, CF_HOLD);
 			switch_channel_clear_flag(chan_a, CF_SUSPEND);
 			goto end_of_bridge_loop;
@@ -352,8 +353,6 @@
 				if (switch_core_session_write_frame(session_b, read_frame, SWITCH_IO_FLAG_NONE, stream_id) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
 									  "%s ending bridge by request from write function\n", switch_channel_get_name(chan_b));
-									  
-					
 					goto end_of_bridge_loop;
 				}
 			}
@@ -467,7 +466,7 @@
 		switch_ivr_park_session(session);
 	}
 
-	if (!switch_channel_test_flag(channel, CF_TRANSFER) && bd && !bd->clean_exit && state != CS_PARK && 
+	if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && bd && !bd->clean_exit && state != CS_PARK && 
 		state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 	}
@@ -485,6 +484,9 @@
 		}
 	}
 
+	if (switch_channel_get_state(channel) < CS_HANGUP) {
+		switch_channel_set_state(channel, CS_RESET);
+	}
 
 	return SWITCH_STATUS_FALSE;
 }
@@ -526,33 +528,38 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM RESET\n", switch_channel_get_name(channel));
 
-	switch_channel_clear_flag(channel, CF_TRANSFER);
+	switch_channel_clear_flag(channel, CF_REDIRECT);
+
 	switch_channel_clear_flag(channel, CF_ORIGINATING);
 
-	if (switch_channel_test_flag(channel, (uint32_t)CF_MASTER)) {
+	if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		switch_channel_set_state(channel, CS_SOFT_EXECUTE);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t uuid_bridge_on_hibernate(switch_core_session_t *session)
+{
+	switch_channel_set_state(switch_core_session_get_channel(session), CS_RESET);
+	return SWITCH_STATUS_FALSE;
+}
+
 static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *session)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_core_session_t *other_session;
 	const char *other_uuid = NULL;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM TRANSMIT\n", switch_channel_get_name(channel));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM SOFT_EXECUTE\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, (uint32_t)CF_MASTER)) {
+	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	switch_channel_clear_flag(channel, (uint32_t)CF_MASTER);
-
+	switch_channel_clear_flag(channel, CF_ORIGINATOR);
+	
 	if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && (other_session = switch_core_session_locate(other_uuid))) {
 		switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
 		switch_event_t *event;
@@ -575,8 +582,6 @@
 
 		switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE);
 
-		switch_channel_clear_flag(channel, CF_TRANSFER);
-		switch_channel_clear_flag(other_channel, CF_TRANSFER);
 		switch_core_session_reset(session, SWITCH_TRUE);
 
 
@@ -618,7 +623,7 @@
 		switch_ivr_multi_threaded_bridge(session, other_session, NULL, NULL, NULL);
 
 		state = switch_channel_get_state(channel);
-		if (!switch_channel_test_flag(channel, CF_TRANSFER) && state < CS_HANGUP && state != CS_ROUTING && state != CS_PARK) {
+		if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP && state != CS_ROUTING && state != CS_PARK) {
 			switch_channel_set_state(channel, CS_EXECUTE);
 		}
 		switch_core_session_rwunlock(other_session);
@@ -638,8 +643,8 @@
 	/*.on_hangup */ NULL,
 	/*.on_exchange_media */ NULL,
 	/*.on_soft_execute */ uuid_bridge_on_soft_execute,
-	/*.on_consume_media */ NULL,
-	/*.on_hibernate */ NULL,
+	/*.on_consume_media */ uuid_bridge_on_hibernate,
+	/*.on_hibernate */ uuid_bridge_on_hibernate,
 	/*.on_reset */ uuid_bridge_on_reset
 };
 
@@ -649,7 +654,6 @@
 
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
-	switch_channel_clear_flag(channel, CF_TRANSFER);
 
 	switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
 
@@ -785,8 +789,6 @@
 	int inner_bridge = switch_channel_test_flag(caller_channel, CF_INNER_BRIDGE);
 
 	switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
-	switch_channel_clear_flag(caller_channel, CF_TRANSFER);
-	switch_channel_clear_flag(peer_channel, CF_TRANSFER);
 
 	b_leg->session = peer_session;
 	switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid));
@@ -830,7 +832,8 @@
 				if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS) {
 					switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
 					switch_channel_hangup(peer_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
-					if (w_state < CS_HANGUP && w_state != CS_ROUTING && w_state != CS_PARK && !switch_channel_test_flag(caller_channel, CF_TRANSFER) &&
+					if (w_state < CS_HANGUP && w_state != CS_ROUTING && w_state != CS_PARK && 
+						!switch_channel_test_flag(caller_channel, CF_REDIRECT) && !switch_channel_test_flag(caller_channel, CF_TRANSFER) &&
 						w_state != CS_EXECUTE) {
 						const char *ext = switch_channel_get_variable(peer_channel, "original_destination_number");
 						if (!ext) {
@@ -911,10 +914,6 @@
 			
 			switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
 
-			if (!switch_channel_test_flag(peer_channel, CF_TRANSFER) && switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
-				switch_channel_set_state(peer_channel, CS_RESET);
-			}
-
 			while (switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
 				switch_cond_next();
 			}
@@ -943,8 +942,9 @@
 	}
 
 	state = switch_channel_get_state(caller_channel);
-
-	if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !a_leg->clean_exit && !inner_bridge) {
+	
+	if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) 
+		&& !a_leg->clean_exit && !inner_bridge) {
 		if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
 			(switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) {
 			if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
@@ -955,6 +955,11 @@
 		}
 	}
 
+	if (switch_channel_test_flag(caller_channel, CF_REDIRECT)) {
+		switch_channel_set_state(caller_channel, CS_RESET);
+	}
+
+
 	return status;
 }
 
@@ -992,6 +997,7 @@
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_caller_profile_t *cp, *originator_cp, *originatee_cp;
 	char *p;
+	switch_channel_state_t state;
 
 	if ((originator_session = switch_core_session_locate(originator_uuid))) {
 		if ((originatee_session = switch_core_session_locate(originatee_uuid))) {
@@ -1033,14 +1039,11 @@
 			 * originatee_session will fall asleep and originator_session will bridge to it
 			 */
 
-			switch_channel_clear_state_handler(originator_channel, NULL);
-			switch_channel_clear_state_handler(originatee_channel, NULL);
-			switch_channel_set_flag(originator_channel, (uint32_t)CF_MASTER);
-			switch_channel_clear_flag(originatee_channel, (uint32_t)CF_MASTER);
-			switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
-			switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
-			switch_channel_set_variable(originator_channel, SWITCH_UUID_BRIDGE, switch_core_session_get_uuid(originatee_session));
+			switch_channel_set_flag(originator_channel, CF_REDIRECT);
+			switch_channel_set_flag(originatee_channel, CF_REDIRECT);
+			
 
+			switch_channel_set_variable(originator_channel, SWITCH_UUID_BRIDGE, switch_core_session_get_uuid(originatee_session));
 			switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_CHANNEL_VARIABLE, switch_channel_get_name(originatee_channel));
 			switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originatee_session));
 			switch_channel_set_variable(originator_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(originatee_session));
@@ -1089,13 +1092,23 @@
 			switch_channel_set_flag(originator_channel, CF_TRANSFER);
 			switch_channel_set_flag(originatee_channel, CF_TRANSFER);
 
+
 			switch_channel_clear_flag(originator_channel, CF_ORIGINATING);
 			switch_channel_clear_flag(originatee_channel, CF_ORIGINATING);
 
 			/* change the states and let the chips fall where they may */
-			switch_channel_set_state(originator_channel, CS_RESET);
-			switch_channel_set_state(originatee_channel, CS_RESET);
+			switch_channel_clear_state_handler(originator_channel, NULL);
+			switch_channel_clear_state_handler(originatee_channel, NULL);
+			switch_channel_set_state_flag(originator_channel, CF_ORIGINATOR);
+			switch_channel_clear_flag(originatee_channel, CF_ORIGINATOR);
+			switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
+			switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
 
+			state = switch_channel_get_state(originator_channel);
+			switch_channel_set_state(originator_channel, state == CS_HIBERNATE ? CS_CONSUME_MEDIA : CS_HIBERNATE);
+			state = switch_channel_get_state(originatee_channel);
+			switch_channel_set_state(originatee_channel, state == CS_HIBERNATE ? CS_CONSUME_MEDIA : CS_HIBERNATE);
+			
 			status = SWITCH_STATUS_SUCCESS;
 
 			/* release the read locks we have on the channels */

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Thu Nov 20 19:09:11 2008
@@ -231,7 +231,9 @@
 
 		state = switch_channel_get_state(peer_channels[i]);
 		if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) ||
-			switch_channel_test_flag(peer_channels[i], CF_BRIDGED) || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+			switch_channel_test_flag(peer_channels[i], CF_REDIRECT) ||
+			switch_channel_test_flag(peer_channels[i], CF_BRIDGED) || 
+			!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
 			) {
 			(*hups)++;
 		} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) ||
@@ -1453,8 +1455,11 @@
 					continue;
 				}
 
-				if (switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
-					switch_channel_get_state(peer_channels[i]) == CS_RESET || !switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
+				if (switch_channel_test_flag(peer_channels[i], CF_TRANSFER) 
+					|| switch_channel_test_flag(peer_channels[i], CF_REDIRECT) 
+					|| switch_channel_test_flag(peer_channels[i], CF_BRIDGED) ||
+					switch_channel_get_state(peer_channels[i]) == CS_RESET || 
+					!switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)
 					) {
 					continue;
 				}
@@ -1652,6 +1657,7 @@
 					}
 				} else if ((state=switch_channel_get_state(peer_channels[i])) < CS_HANGUP && switch_channel_test_flag(peer_channels[i], CF_ORIGINATING)) {
 					if (!(state == CS_RESET || switch_channel_test_flag(peer_channels[i], CF_TRANSFER) || 
+						  switch_channel_test_flag(peer_channels[i], CF_REDIRECT) ||
 						  switch_channel_test_flag(peer_channels[i], CF_BRIDGED))) {
 						switch_channel_hangup(peer_channels[i], *cause);
 					}



More information about the Freeswitch-svn mailing list