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

Freeswitch SVN anthm at freeswitch.org
Fri Sep 19 15:58:01 EDT 2008


Author: anthm
Date: Fri Sep 19 15:58:01 2008
New Revision: 9603

Modified:
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_rtp.c

Log:
more crazy black magic

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Fri Sep 19 15:58:01 2008
@@ -291,7 +291,8 @@
 	SMF_ECHO_BLEG = (1 << 2),
 	SMF_FORCE = (1 << 3),
 	SMF_LOOP = (1 << 4),
-	SMF_HOLD_BLEG = (1 << 5)
+	SMF_HOLD_BLEG = (1 << 5),
+	SMF_IMMEDIATE = (1 << 6)
 } switch_media_flag_enum_t;
 typedef uint32_t switch_media_flag_t;
 

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Fri Sep 19 15:58:01 2008
@@ -498,6 +498,10 @@
 		}
 	}
 
+	if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+		return SWITCH_STATUS_FALSE;
+	}
+	
 	read_codec = switch_core_session_get_read_codec(session);
 
 	if (!read_codec || !read_codec->implementation) {
@@ -906,9 +910,11 @@
 		if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
 			status = SWITCH_STATUS_SUCCESS;
 			switch_core_session_receive_message(session, &msg);
-
-			switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
-			switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+			
+			if (!(flags & SMF_IMMEDIATE)) {
+				switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+				switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+			}
 
 			if ((flags & SMF_REBRIDGE)
 				&& (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Fri Sep 19 15:58:01 2008
@@ -651,16 +651,21 @@
 	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);
+		const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
+		
+		if (!switch_strlen_zero(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) {
+			
+			switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
 
-		switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
-		switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
-
-		switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
-		switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
+			switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
+			switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
 
-		if (switch_channel_get_state(other_channel) < CS_HANGUP) {
-			switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
+			if (switch_channel_get_state(other_channel) < CS_HANGUP) {
+				switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
+			}
 		}
+		
+		switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
 
 		switch_core_session_rwunlock(other_session);
 	}
@@ -725,13 +730,17 @@
 		switch_channel_event_set_data(caller_channel, event);
 		switch_event_fire(&event);
 	}
-
+	
 	switch_channel_set_state_flag(caller_channel, CF_TRANSFER);
 	switch_channel_set_state_flag(peer_channel, CF_TRANSFER);
 
-
 	switch_channel_set_state(caller_channel, CS_HIBERNATE);
 	switch_channel_set_state(peer_channel, CS_HIBERNATE);
+	
+	if (switch_channel_test_flag(caller_channel, CF_BRIDGED)) {
+		switch_channel_set_flag(caller_channel, CF_TRANSFER);
+		switch_channel_set_flag(peer_channel, CF_TRANSFER);
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -901,6 +910,33 @@
 	return status;
 }
 
+static void cleanup_proxy_mode(switch_core_session_t *session)
+{
+	switch_core_session_t *sbsession;
+
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+
+	if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+		const char *sbv = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
+		
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Restore media to %s\n", switch_channel_get_name(channel));
+		switch_ivr_media(switch_core_session_get_uuid(session), SMF_IMMEDIATE);
+
+		if (!switch_strlen_zero(sbv) && (sbsession = switch_core_session_locate(sbv))) {
+			switch_channel_t *sbchannel = switch_core_session_get_channel(sbsession);
+			switch_channel_hangup(sbchannel, SWITCH_CAUSE_ATTENDED_TRANSFER);
+			switch_core_session_rwunlock(sbsession);
+		}
+	}
+
+	switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
+	switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
+	switch_channel_set_variable(channel, SWITCH_BRIDGE_UUID_VARIABLE, NULL);
+
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid)
 {
 	switch_core_session_t *originator_session, *originatee_session, *swap_session;
@@ -939,6 +975,9 @@
 				}
 			}
 
+			cleanup_proxy_mode(originator_session);
+			cleanup_proxy_mode(originatee_session);
+			
 			/* override transmit state for originator_channel to bridge to originatee_channel 
 			 * install pointer to originatee_session into originator_channel
 			 * set CF_TRANSFER on both channels and change state to CS_SOFT_EXECUTE to
@@ -961,7 +1000,7 @@
 			switch_channel_set_variable(originatee_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originator_session));
 			switch_channel_set_variable(originatee_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(originator_session));
 
-
+			
 			originator_cp = switch_channel_get_caller_profile(originator_channel);
 			originatee_cp = switch_channel_get_caller_profile(originatee_channel);
 

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Fri Sep 19 15:58:01 2008
@@ -1256,7 +1256,7 @@
 			ret = (int) bytes;
 			goto end;
 		}
-
+		
 		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
 			const char *tx_host;
 			const char *old_host;



More information about the Freeswitch-svn mailing list