Revision
15177
Author
anthm
Date
2009-10-19 14:58:23 -0500 (Mon, 19 Oct 2009)

Log Message

clear up some more display issues and fix resume-media-on-hold sofia option

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_channel.h (15176 => 15177)


--- freeswitch/trunk/src/include/switch_channel.h	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/include/switch_channel.h	2009-10-19 19:58:23 UTC (rev 15177)
@@ -229,6 +229,8 @@
   \returns SWITCH_STATUS_SUCCESS if successful
 */
 
+SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val);
+
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, 
 																	  const char *varname, const char *value, switch_bool_t var_check);
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname,  const char *fmt, ...);

Modified: freeswitch/trunk/src/include/switch_types.h (15176 => 15177)


--- freeswitch/trunk/src/include/switch_types.h	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/include/switch_types.h	2009-10-19 19:58:23 UTC (rev 15177)
@@ -868,6 +868,7 @@
 
 typedef enum {
 	CC_MEDIA_ACK = 1,
+	CC_BYPASS_MEDIA = 1,
 	/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
 	CC_FLAG_MAX
 } switch_channel_cap_t;

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (15176 => 15177)


--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -784,15 +784,12 @@
 
 SWITCH_STANDARD_APP(set_profile_var_function)
 {
-	switch_caller_profile_t *caller_profile;
 	char *name, *val = NULL;
 
-	caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
-
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
 	} else {
-		name = switch_core_strdup(caller_profile->pool, data);
+		name = switch_core_session_strdup(session, data);
 		val = strchr(name, '=');
 
 		if (val) {
@@ -801,66 +798,8 @@
 				val = NULL;
 			}
 		}
-
-		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SET_PROFILE_VAR [%s]=[%s]\n", name, val ? val : "UNDEF");
-
-		if (!strcasecmp(name, "dialplan")) {
-			caller_profile->dialplan = val;
-		}
-		if (!strcasecmp(name, "username")) {
-			caller_profile->username = val;
-		}
-		if (!strcasecmp(name, "caller_id_name")) {
-			caller_profile->caller_id_name = val;
-		}
-		if (!strcasecmp(name, "caller_id_number")) {
-			caller_profile->caller_id_number = val;
-		}
-		if (!strcasecmp(name, "callee_id_name")) {
-			caller_profile->callee_id_name = val;
-		}
-		if (!strcasecmp(name, "callee_id_number")) {
-			caller_profile->callee_id_number = val;
-		}
-		if (val && !strcasecmp(name, "caller_ton")) {
-			caller_profile->caller_ton = (uint8_t) atoi(val);
-		}
-		if (val && !strcasecmp(name, "caller_numplan")) {
-			caller_profile->caller_numplan = (uint8_t) atoi(val);
-		}
-		if (val && !strcasecmp(name, "destination_number_ton")) {
-			caller_profile->destination_number_ton = (uint8_t) atoi(val);
-		}
-		if (val && !strcasecmp(name, "destination_number_numplan")) {
-			caller_profile->destination_number_numplan = (uint8_t) atoi(val);
-		}
-		if (!strcasecmp(name, "ani")) {
-			caller_profile->ani = val;
-		}
-		if (!strcasecmp(name, "aniii")) {
-			caller_profile->aniii = val;
-		}
-		if (!strcasecmp(name, "network_addr")) {
-			caller_profile->network_addr = val;
-		}
-		if (!strcasecmp(name, "rdnis")) {
-			caller_profile->rdnis = val;
-		}
-		if (!strcasecmp(name, "destination_number")) {
-			caller_profile->destination_number = val;
-		}
-		if (!strcasecmp(name, "uuid")) {
-			caller_profile->uuid = val;
-		}
-		if (!strcasecmp(name, "source")) {
-			caller_profile->source = val;
-		}
-		if (!strcasecmp(name, "context")) {
-			caller_profile->context = val;
-		}
-		if (!strcasecmp(name, "chan_name")) {
-			caller_profile->chan_name = val;
-		}
+		
+		switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val);
 	}
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15176 => 15177)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -1232,7 +1232,7 @@
 			switch_channel_clear_flag(channel, CF_PROXY_MODE);
 			sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
 
-			if (!switch_channel_media_ready(channel)) {
+			if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
 				if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
 					const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 
@@ -2989,6 +2989,14 @@
 		switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
 	}
 
+	if ((hval = switch_event_get_header(var_event, "sip_callee_id_name"))) {
+		caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, hval);
+	}
+
+	if ((hval = switch_event_get_header(var_event, "sip_callee_id_number"))) {
+		caller_profile->callee_id_number = switch_core_strdup(caller_profile->pool, hval);
+	}
+
 	if (session) {
 		switch_channel_t *o_channel = switch_core_session_get_channel(session);
 		const char *vval = NULL;
@@ -3005,7 +3013,7 @@
 		switch_ivr_transfer_variable(session, nsession, "sip-force-contact");
 		switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact");
 		switch_ivr_transfer_variable(session, nsession, "sip_cid_type");
-
+		
 		if (switch_core_session_compare(session, nsession)) {
 			/* It's another sofia channel! so lets cache what they use as a pt for telephone event so 
 			   we can keep it the same

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15176 => 15177)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -3113,11 +3113,12 @@
 			caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip);
 		}
 
+		switch_channel_clear_flag(channel, CF_REQ_MEDIA);
+
 		if ((status == 180 || status == 183 || status == 200)) { 
 			const char *x_actually_support;
 
 			switch_channel_set_flag(channel, CF_MEDIA_ACK);
-			switch_channel_clear_flag(channel, CF_REQ_MEDIA);
 
 			if ((x_actually_support = sofia_glue_get_unknown_header(sip, "X-Actually-Support"))) {
 				tech_pvt->x_actually_support_remote = switch_core_session_strdup(session, x_actually_support);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15176 => 15177)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -522,6 +522,7 @@
 	tech_pvt->session = session;
 	tech_pvt->channel = switch_core_session_get_channel(session);
 	switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK);
+	switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA);
 	
 	switch_core_session_set_private(session, tech_pvt);
 

Modified: freeswitch/trunk/src/switch_channel.c (15176 => 15177)


--- freeswitch/trunk/src/switch_channel.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/switch_channel.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -622,6 +622,65 @@
 	return (!switch_strlen_zero(channel->name)) ? channel->name : "N/A";
 }
 
+SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val)
+{
+	char *v;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+	switch_mutex_lock(channel->profile_mutex);
+
+	if (!switch_strlen_zero(val)) {
+		v = switch_core_strdup(channel->caller_profile->pool, val);
+	} else {
+		v = SWITCH_BLANK_STRING;
+	}
+	
+	if (!strcasecmp(name, "dialplan")) {
+		channel->caller_profile->dialplan = v;
+	} else if (!strcasecmp(name, "username")) {
+		channel->caller_profile->username = v;
+	} else if (!strcasecmp(name, "caller_id_name")) {
+		channel->caller_profile->caller_id_name = v;
+	} else if (!strcasecmp(name, "caller_id_number")) {
+		channel->caller_profile->caller_id_number = v;
+	} else if (!strcasecmp(name, "callee_id_name")) {
+		channel->caller_profile->callee_id_name = v;
+	} else if (!strcasecmp(name, "callee_id_number")) {
+		channel->caller_profile->callee_id_number = v;
+	} else if (val && !strcasecmp(name, "caller_ton")) {
+		channel->caller_profile->caller_ton = (uint8_t) atoi(v);
+	} else if (val && !strcasecmp(name, "caller_numplan")) {
+		channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
+	} else if (val && !strcasecmp(name, "destination_number_ton")) {
+		channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
+	} else if (val && !strcasecmp(name, "destination_number_numplan")) {
+		channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
+	} else if (!strcasecmp(name, "ani")) {
+		channel->caller_profile->ani = v;
+	} else if (!strcasecmp(name, "aniii")) {
+		channel->caller_profile->aniii = v;
+	} else if (!strcasecmp(name, "network_addr")) {
+		channel->caller_profile->network_addr = v;
+	} else if (!strcasecmp(name, "rdnis")) {
+		channel->caller_profile->rdnis = v;
+	} else if (!strcasecmp(name, "destination_number")) {
+		channel->caller_profile->destination_number = v;
+	} else if (!strcasecmp(name, "uuid")) {
+		channel->caller_profile->uuid = v;
+	} else if (!strcasecmp(name, "source")) {
+		channel->caller_profile->source = v;
+	} else if (!strcasecmp(name, "context")) {
+		channel->caller_profile->context = v;
+	} else if (!strcasecmp(name, "chan_name")) {
+		channel->caller_profile->chan_name = v;
+	} else {
+		status = SWITCH_STATUS_FALSE;
+	}
+	switch_mutex_unlock(channel->profile_mutex);
+
+	return status;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, 
 																	  const char *varname, const char *value, switch_bool_t var_check)
 {

Modified: freeswitch/trunk/src/switch_core_session.c (15176 => 15177)


--- freeswitch/trunk/src/switch_core_session.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/switch_core_session.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -506,13 +506,21 @@
 			}
 
 			if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
-				switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
-			}
-
-			if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-				switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA);
-				if (switch_channel_test_flag(channel, CF_VIDEO)) {
-					switch_channel_set_flag(peer_channel, CF_VIDEO);
+				if (switch_channel_test_cap(peer_channel, CC_BYPASS_MEDIA)) {
+					switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
+			
+					if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
+						switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA);
+						if (switch_channel_test_flag(channel, CF_VIDEO)) {
+							switch_channel_set_flag(peer_channel, CF_VIDEO);
+						}
+					}
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, 
+									  "%s does not support the proxy feature, disabling.\n", 
+									  switch_channel_get_name(peer_channel));
+					switch_channel_clear_flag(channel, CF_PROXY_MODE);
+					switch_channel_clear_flag(channel, CF_PROXY_MEDIA);
 				}
 			}
 

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (15176 => 15177)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -84,7 +84,7 @@
 	switch_core_session_message_t *msg;
 	switch_caller_profile_t *caller_profile;
 	switch_channel_t *caller_channel;
-	const char *name, *number;
+	const char *name, *number, *p;
 
 	caller_channel = switch_core_session_get_channel(session);
 	caller_profile = switch_channel_get_caller_profile(caller_channel);
@@ -111,6 +111,13 @@
 		}
 	}
 
+	if ((p = strrchr(number, '/'))) {
+		number = p+1;
+	}
+	if ((p = strrchr(name, '/'))) {
+		name = p+1;
+	}
+
 	msg = switch_core_session_alloc(peer_session, sizeof(*msg));
 	MESSAGE_STAMP_FFL(msg);
 	msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
@@ -394,9 +401,9 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(un));
 					goto end_of_bridge_loop;
 				}
-				
-				if (ans_a) ans_b = 1; else ans_a = 1;
 			}
+
+			if (ans_a) ans_b = 1; else ans_a = 1;
 		}
 		
 		if (originator && !sent_update && ans_a && ans_b && switch_channel_media_ack(chan_a) && switch_channel_media_ack(chan_b)) {
@@ -866,6 +873,8 @@
 		switch_channel_set_flag(peer_channel, CF_TRANSFER);
 	}
 
+	switch_ivr_bridge_display(session, peer_session);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/switch_ivr_originate.c (15176 => 15177)


--- freeswitch/trunk/src/switch_ivr_originate.c	2009-10-19 18:55:52 UTC (rev 15176)
+++ freeswitch/trunk/src/switch_ivr_originate.c	2009-10-19 19:58:23 UTC (rev 15177)
@@ -1725,6 +1725,14 @@
 				if (originate_status[i].peer_channel) {
 					const char *vvar;
 					
+					if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_name"))) {
+						switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_name", vvar);
+					}
+
+					if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_number"))) {
+						switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_number", vvar);
+					}
+
 					if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_timeout"))) {
 						int val = atoi(vvar);
 						if (val > 0) {