[Freeswitch-svn] [commit] r13561 - freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN brian at freeswitch.org
Tue Jun 2 17:14:44 PDT 2009


Author: brian
Date: Tue Jun  2 19:14:44 2009
New Revision: 13561

Log:
 adding nat mapping and unmapping for audio and video rtp ports 

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

Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Tue Jun  2 19:14:44 2009
@@ -684,6 +684,10 @@
 
 	tech_pvt->adv_sdp_audio_port = sdp_port;
 
+	if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+		switch_nat_add_mapping((switch_port_t)sdp_port, SWITCH_NAT_UDP);
+	}
+
 	switch_snprintf(tmp, sizeof(tmp), "%d", sdp_port);
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
@@ -724,6 +728,10 @@
 
 	tech_pvt->adv_sdp_video_port = sdp_port;
 
+	if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+		switch_nat_add_mapping((switch_port_t)sdp_port, SWITCH_NAT_UDP);
+	}
+
 	switch_snprintf(tmp, sizeof(tmp), "%d", sdp_port);
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
@@ -1821,12 +1829,21 @@
 		switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
 	}
 
+	if (tech_pvt->local_sdp_audio_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+		!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+		switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_audio_port, SWITCH_NAT_UDP);
+	}
+	
 	if (tech_pvt->video_rtp_session) {
 		switch_rtp_destroy(&tech_pvt->video_rtp_session);
 	} else if (tech_pvt->local_sdp_video_port) {
 		switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_video_port);
 	}
 
+	if (tech_pvt->local_sdp_video_port > 0 && sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT) &&
+		!switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+		switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP);
+	}
 }
 
 switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)



More information about the Freeswitch-svn mailing list