[Freeswitch-svn] [commit] r9896 - in freeswitch/trunk/src: . mod/endpoints/mod_loopback

Freeswitch SVN anthm at freeswitch.org
Wed Oct 8 14:15:01 EDT 2008


Author: anthm
Date: Wed Oct  8 14:15:00 2008
New Revision: 9896

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
   freeswitch/trunk/src/switch_ivr_originate.c

Log:
allow endpoints to realize the originator is ignoring early media and use that feature in mod_loopback to avoid obscure situation

Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	Wed Oct  8 14:15:00 2008
@@ -51,7 +51,8 @@
 	TFLAG_WRITE = (1 << 2),
 	TFLAG_CNG = (1 << 3),
 	TFLAG_BRIDGE = (1 << 4),
-	TFLAG_BOWOUT = (1 << 5)
+	TFLAG_BOWOUT = (1 << 5),
+	TFLAG_NO_EARLY = (1 << 6)
 } TFLAGS;
 
 struct private_object {
@@ -241,6 +242,11 @@
 		switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);
 		switch_set_flag_locked(b_tech_pvt, TFLAG_OUTBOUND);
 	
+		if (switch_test_flag(tech_pvt, TFLAG_NO_EARLY)) {
+			switch_set_flag_locked(b_tech_pvt, TFLAG_NO_EARLY);
+			switch_clear_flag_locked(tech_pvt, TFLAG_NO_EARLY);
+		}
+
 		switch_channel_set_flag(channel, CF_ACCEPT_CNG);	
 		switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");
 
@@ -328,13 +334,17 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
 
 	switch_clear_flag_locked(tech_pvt, TFLAG_LINKED);
+
 	if (tech_pvt->other_tech_pvt) {
 		switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_LINKED);
+		tech_pvt->other_tech_pvt = NULL;
 	}
 	
 	if (tech_pvt->other_session) {
 		switch_channel_hangup(tech_pvt->other_channel, switch_channel_get_cause(channel));
 		switch_core_session_rwunlock(tech_pvt->other_session);
+		tech_pvt->other_channel = NULL;
+		tech_pvt->other_session = NULL;
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -467,6 +477,10 @@
 	if (!switch_test_flag(tech_pvt, TFLAG_LINKED)) {
 		goto end;
 	}
+	
+	if (switch_test_flag(tech_pvt, TFLAG_NO_EARLY)) {
+		switch_set_flag(tech_pvt, TFLAG_CNG);
+	}
 
 	*frame = NULL;
 
@@ -582,13 +596,18 @@
 	
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_ANSWER:
-		if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-			switch_channel_answer(tech_pvt->other_channel);
+		if (tech_pvt->other_channel) {
+			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+				switch_channel_answer(tech_pvt->other_channel);
+				switch_clear_flag(tech_pvt, TFLAG_NO_EARLY);
+			}
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
-		if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-			switch_channel_pre_answer(tech_pvt->other_channel);
+		if (tech_pvt->other_channel) {
+			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+				switch_channel_pre_answer(tech_pvt->other_channel);
+			}
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
@@ -623,12 +642,13 @@
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;
-		
+		const char *var;
+
 		switch_core_session_add_stream(*new_session, NULL);
 
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
 			channel = switch_core_session_get_channel(*new_session);
-			switch_snprintf(name, sizeof(name), "Loopback/%s-a", outbound_profile->destination_number);
+			switch_snprintf(name, sizeof(name), "loopback/%s-a", outbound_profile->destination_number);
 			switch_channel_set_name(channel, name);
 			if (tech_init(tech_pvt, *new_session, session ? switch_core_session_get_read_codec(session) : NULL) != SWITCH_STATUS_SUCCESS) {
 				switch_core_session_destroy(new_session);
@@ -640,6 +660,10 @@
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
 		
+		if ((var = switch_event_get_header(var_event, "originate_early_media")) && !switch_true(var)) {
+			switch_set_flag(tech_pvt, TFLAG_NO_EARLY);
+		}
+
 		if (outbound_profile) {
 			char *dialplan = NULL, *context = NULL;
 

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Wed Oct  8 14:15:00 2008
@@ -685,6 +685,14 @@
 		}
 
 		switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
+
+		if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) || switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)) {
+			ringback_data = NULL;
+		}
+	}
+
+	if (ringback_data) {
+		early_ok = 0;
 	}
 
 	if ((var = switch_event_get_header(var_event, "group_confirm_key"))) {
@@ -957,6 +965,8 @@
 					myflags |= SOF_NO_EFFECTIVE_CID_NAME;
 				}
 
+				switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", early_ok ? "true" : "false");
+				
 
 				if ((reason =
 					 switch_core_session_outgoing_channel(session, var_event, chan_type, new_profile, &new_session, &pool,



More information about the Freeswitch-svn mailing list