]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add separate inbound/outound codec prefs params to sofia profile original codec-prefs...
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 24 Nov 2009 18:52:57 +0000 (18:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 24 Nov 2009 18:52:57 +0000 (18:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15658 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/sip_profiles/external.xml
conf/sip_profiles/internal-ipv6.xml
conf/sip_profiles/internal.xml
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 5be2c066e0f7919aa02a57fd5d9a1927311d0a9d..5e49d3c6a3c33a01a5adbd24ba4a18c9c3f041b4 100644 (file)
@@ -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"/>-->
index a1a829b5da76462f80c2c23bbb7399aeb6d48616..519d1431927134d6e5be5c2cc0ba6fd3401f219f 100644 (file)
@@ -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 -->
index 9a9ed41906e00874dd83aa8bbd7d03d775951a09..077ab654f57f5952cdf665c05908fd5220ee24b3 100644 (file)
@@ -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}"/>
index 10087a2e92f613d899d4ae49a5742d90ee8a1477..de2fc9941ee4284ee84f74f4faf5bd71f92e3f4d 100644 (file)
@@ -1966,7 +1966,9 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
                                        }
                                        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 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
                                        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");
index 90b966e6679b4533d5612e2e914ae4fe4ea0b737..86af3a5ec79b6636ad19a4bf9c474f4fef0881ec 100644 (file)
@@ -459,7 +459,8 @@ struct sofia_profile {
        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_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
 
 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);
index c8aee2fc2329f6bdbbc254468dd07d5ccae9aa4d..521499ff95386201e026b5f3d34e59ee4ad211ac 100644 (file)
@@ -2179,7 +2179,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                        } 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 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                        } 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 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 
                                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);
                                }
index ab2afd2c567a3c55cdc464bcc7d54bb9ba961702..16b115c51ebabc4fe035533576d29e4eb2583e5d 100644 (file)
@@ -409,6 +409,19 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
        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,24 +439,28 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
 
        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;