Revision
15658
Author
anthm
Date
2009-11-24 12:52:57 -0600 (Tue, 24 Nov 2009)

Log Message

add separate inbound/outound codec prefs params to sofia profile original codec-prefs sets both to the same value for back-compat

Modified Paths

Diff

Modified: freeswitch/trunk/conf/sip_profiles/external.xml (15657 => 15658)


--- freeswitch/trunk/conf/sip_profiles/external.xml	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/conf/sip_profiles/external.xml	2009-11-24 18:52:57 UTC (rev 15658)
@@ -24,7 +24,8 @@
     <param name="dialplan" value="XML"/>
     <param name="context" value="public"/>
     <param name="dtmf-duration" value="100"/>
-    <param name="codec-prefs" value="$${outbound_codec_prefs}"/>
+    <param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
+    <param name="outbound-codec-prefs" value="$${outbound_codec_prefs}"/>
     <param name="hold-music" value="$${hold_music}"/>
     <param name="rtp-timer-name" value="soft"/>
     <!--<param name="enable-100rel" value="true"/>-->

Modified: freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml (15657 => 15658)


--- freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml	2009-11-24 18:52:57 UTC (rev 15658)
@@ -14,7 +14,8 @@
     <param name="sip-port" value="$${internal_sip_port}"/>
     <param name="dialplan" value="XML"/>
     <param name="dtmf-duration" value="100"/>
-    <param name="codec-prefs" value="$${global_codec_prefs}"/>
+    <param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
+    <param name="outbound-codec-prefs" value="$${global_codec_prefs}"/>
     <param name="use-rtp-timer" value="true"/>
     <param name="rtp-timer-name" value="soft"/>
     <!-- ip address to use for rtp -->

Modified: freeswitch/trunk/conf/sip_profiles/internal.xml (15657 => 15658)


--- freeswitch/trunk/conf/sip_profiles/internal.xml	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/conf/sip_profiles/internal.xml	2009-11-24 18:52:57 UTC (rev 15658)
@@ -47,7 +47,8 @@
     <param name="sip-port" value="$${internal_sip_port}"/>
     <param name="dialplan" value="XML"/>
     <param name="dtmf-duration" value="100"/>
-    <param name="codec-prefs" value="$${global_codec_prefs}"/>
+    <param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
+    <param name="outbound-codec-prefs" value="$${global_codec_prefs}"/>
     <param name="rtp-timer-name" value="soft"/>
     <!-- ip address to use for rtp, DO NOT USE HOSTNAMES ONLY IP ADDRESSES -->
     <param name="rtp-ip" value="$${local_ip_v4}"/>

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15657 => 15658)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-11-24 18:52:57 UTC (rev 15658)
@@ -1966,7 +1966,9 @@
 					}
 					stream->write_function(stream, "HOLD-MUSIC       \t%s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music);
 					stream->write_function(stream, "OUTBOUND-PROXY   \t%s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
-					stream->write_function(stream, "CODECS           \t%s\n", switch_str_nil(profile->codec_string));
+					stream->write_function(stream, "CODECS IN        \t%s\n", switch_str_nil(profile->inbound_codec_string));
+					stream->write_function(stream, "CODECS OUT       \t%s\n", switch_str_nil(profile->outbound_codec_string));
+
 					stream->write_function(stream, "TEL-EVENT        \t%d\n", profile->te);
 					if (profile->dtmf_type == DTMF_2833) {
 					stream->write_function(stream, "DTMF-MODE        \trfc2833\n");
@@ -2186,7 +2188,9 @@
 					stream->write_function(stream, "    <tls-bind-url>%s</tls-bind-url>\n", switch_str_nil(profile->tls_bindurl));
 					stream->write_function(stream, "    <hold-music>%s</hold-music>\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music);
 					stream->write_function(stream, "    <outbound-proxy>%s</outbound-proxy>\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
-					stream->write_function(stream, "    <codecs>%s</codecs>\n", switch_str_nil(profile->codec_string));
+					stream->write_function(stream, "    <inbound-codecs>%s</inbound-codecs>\n", switch_str_nil(profile->inbound_codec_string));
+					stream->write_function(stream, "    <outbound-codecs>%s</outbound-codecs>\n", switch_str_nil(profile->outbound_codec_string));
+
 					stream->write_function(stream, "    <tel-event>%d</tel-event>\n", profile->te);
 					stream->write_function(stream, "    <dtmf-mode>rfc2833</dtmf-mode>\n");
 					stream->write_function(stream, "    <dtmf-mode>info</dtmf-mode>\n");

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (15657 => 15658)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-11-24 18:52:57 UTC (rev 15658)
@@ -459,7 +459,8 @@
 	switch_port_t sip_port;
 	switch_port_t tls_sip_port;
 	int tls_version;
-	char *codec_string;
+	char *inbound_codec_string;
+	char *outbound_codec_string;
 	int running;
 	int dtmf_duration;
 	uint8_t flags[TFLAG_MAX];
@@ -705,6 +706,8 @@
 
 void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt);
 
+const char *sofia_glue_get_codec_string(private_object_t *tech_pvt);
+
 void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame);
 
 switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int force);

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


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-24 18:52:57 UTC (rev 15658)
@@ -2179,7 +2179,12 @@
 					} else if (!strcasecmp(var, "max-calls")) {
 						profile->max_calls = atoi(val);
 					} else if (!strcasecmp(var, "codec-prefs")) {
-						profile->codec_string = switch_core_strdup(profile->pool, val);
+						profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
+						profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
+					} else if (!strcasecmp(var, "inbound-codec-prefs")) {
+						profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
+					} else if (!strcasecmp(var, "outbound-codec-prefs")) {
+						profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
 					} else if (!strcasecmp(var, "challenge-realm")) {
 						profile->challenge_realm = switch_core_strdup(profile->pool, val);
 					} else if (!strcasecmp(var, "dtmf-duration")) {
@@ -2883,7 +2888,12 @@
 					} else if (!strcasecmp(var, "max-calls")) {
 						profile->max_calls = atoi(val);
 					} else if (!strcasecmp(var, "codec-prefs")) {
-						profile->codec_string = switch_core_strdup(profile->pool, val);
+						profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
+						profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
+					} else if (!strcasecmp(var, "inbound-codec-prefs")) {
+						profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
+					} else if (!strcasecmp(var, "outbound-codec-prefs")) {
+						profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
 					} else if (!strcasecmp(var, "challenge-realm")) {
 						profile->challenge_realm = switch_core_strdup(profile->pool, val);
 					} else if (!strcasecmp(var, "dtmf-duration")) {
@@ -3700,7 +3710,7 @@
 
 				if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
 					if ((sdp = sdp_session(parser))) {
-						sofia_glue_set_r_sdp_codec_string(session, (tech_pvt->profile?tech_pvt->profile->codec_string:NULL), sdp);
+						sofia_glue_set_r_sdp_codec_string(session, sofia_glue_get_codec_string(tech_pvt), sdp);
 					}
 					sdp_parser_free(parser);
 				}

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


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-24 18:18:09 UTC (rev 15657)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-24 18:52:57 UTC (rev 15658)
@@ -409,6 +409,19 @@
 	sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE);
 }
 
+const char *sofia_glue_get_codec_string(private_object_t *tech_pvt)
+{
+	const char *codec_string = NULL;
+	
+	if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !zstr(tech_pvt->profile->outbound_codec_string)) {
+		codec_string = tech_pvt->profile->outbound_codec_string ? tech_pvt->profile->outbound_codec_string : tech_pvt->profile->inbound_codec_string;
+	} else if (!zstr(tech_pvt->profile->inbound_codec_string)) {
+		codec_string = tech_pvt->profile->inbound_codec_string ? tech_pvt->profile->inbound_codec_string : tech_pvt->profile->outbound_codec_string;
+	}
+	
+	return codec_string;
+}
+
 void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
 {
 	const char *abs, *codec_string = NULL;
@@ -426,25 +439,29 @@
 
 	if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
 		codec_string = abs;
-	} else {
-		if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
-			if (tech_pvt->profile->codec_string) {
-				codec_string = tech_pvt->profile->codec_string;
-			}
+		goto ready;
+	}
+
+	if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
+		codec_string = sofia_glue_get_codec_string(tech_pvt);
+		if (codec_string && *codec_string == '=') {
+			codec_string++;
+			goto ready;
 		}
+	}
 
-		if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
-			if (!codec_string || sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_TRANSCODING)) {
+	if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
+		if (!codec_string || sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_TRANSCODING)) {
+			codec_string = ocodec;
+		} else {
+			if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
 				codec_string = ocodec;
-			} else {
-				if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
-					codec_string = ocodec;
-				}
 			}
 		}
 	}
+	
+ ready:
 
-
 	if (codec_string) {
 		char *tmp_codec_string;
 		if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {