[Freeswitch-svn] [commit] r7724 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Fri Feb 22 10:27:41 EST 2008


Author: anthm
Date: Fri Feb 22 10:27:40 2008
New Revision: 7724

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Log:
update

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Feb 22 10:27:40 2008
@@ -966,6 +966,7 @@
 					tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, (char *)msg->pointer_arg);
 					if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 						sofia_glue_tech_patch_sdp(tech_pvt);
+						sofia_glue_tech_proxy_remote_addr(tech_pvt);
 					}
 					nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 								SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Fri Feb 22 10:27:40 2008
@@ -587,3 +587,4 @@
 const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name);
 switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction);
 void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt);
+switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Fri Feb 22 10:27:40 2008
@@ -685,7 +685,9 @@
 	return new_uri;
 }
 
-static switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) {
+switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) 
+{
+	const char *err;
 	char rip[128] = "";
 	char rp[128] = "";
 	char *p, *ip_ptr = NULL, *port_ptr = NULL;
@@ -721,9 +723,29 @@
 		p++;
 	}
 
-	tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, rip);
-	tech_pvt->remote_sdp_audio_port = (switch_port_t) atoi(rp);
+	if (switch_strlen_zero(tech_pvt->remote_sdp_audio_ip) || !tech_pvt->remote_sdp_audio_port) {
+		tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, rip);
+		tech_pvt->remote_sdp_audio_port = (switch_port_t) atoi(rp);
+	}
+
+	if (!strcmp(tech_pvt->remote_sdp_audio_ip, rip) && atoi(rp) == tech_pvt->remote_sdp_audio_port) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote address:port [%s:%d] has not changed.\n", 
+						  tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
+		return SWITCH_STATUS_SUCCESS;
+	}
 
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
+		if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, &err) !=
+			SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n",
+							  tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
+			/* Reactivate the NAT buster flag. */
+			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+		}
+	}
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -738,16 +760,17 @@
 		return;
 	}
 
-	if (!switch_strlen_zero(tech_pvt->orig_local_sdp_str)) {
-		return;
-	}
-
 	len = strlen(tech_pvt->local_sdp_str) + 256;
 	
 	if ((p = (char *)switch_stristr("c=IN IP4 ", tech_pvt->local_sdp_str))) {
 		ip_ptr = p + 9;
 	}
 
+	if (!strncmp(ip_ptr, "0.0.0.0", 7) || switch_stristr("sendonly", tech_pvt->local_sdp_str)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Skip patch on hold SDP\n");
+		return;
+	}
+
 	if ((p = (char *)switch_stristr("m=audio ", tech_pvt->local_sdp_str))) {
 		port_ptr = p + 8;
 	}
@@ -797,7 +820,7 @@
 		*q++ = *p++;
 	}
 	
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Patched SDP\n%s\n%s\n", 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Patched SDP\n---\n%s\n+++\n%s\n", 
 					  switch_channel_get_name(tech_pvt->channel), tech_pvt->orig_local_sdp_str, tech_pvt->local_sdp_str);
 }
 
@@ -1034,6 +1057,9 @@
 	}
 
 	if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
+			sofia_glue_tech_proxy_remote_addr(tech_pvt);
+		}
 		sofia_glue_tech_patch_sdp(tech_pvt);
 	}
 



More information about the Freeswitch-svn mailing list