diff --git a/conf/sip_profiles/external.xml b/conf/sip_profiles/external.xml
index 5be2c066e0..5e49d3c6a3 100644
--- a/conf/sip_profiles/external.xml
+++ b/conf/sip_profiles/external.xml
@@ -24,7 +24,8 @@
-
+
+
diff --git a/conf/sip_profiles/internal-ipv6.xml b/conf/sip_profiles/internal-ipv6.xml
index a1a829b5da..519d143192 100644
--- a/conf/sip_profiles/internal-ipv6.xml
+++ b/conf/sip_profiles/internal-ipv6.xml
@@ -14,7 +14,8 @@
-
+
+
diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml
index 9a9ed41906..077ab654f5 100644
--- a/conf/sip_profiles/internal.xml
+++ b/conf/sip_profiles/internal.xml
@@ -47,7 +47,8 @@
-
+
+
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 10087a2e92..de2fc9941e 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -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, " %s\n", switch_str_nil(profile->tls_bindurl));
stream->write_function(stream, " %s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music);
stream->write_function(stream, " %s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
- stream->write_function(stream, " %s\n", switch_str_nil(profile->codec_string));
+ stream->write_function(stream, " %s\n", switch_str_nil(profile->inbound_codec_string));
+ stream->write_function(stream, " %s\n", switch_str_nil(profile->outbound_codec_string));
+
stream->write_function(stream, " %d\n", profile->te);
stream->write_function(stream, " rfc2833\n");
stream->write_function(stream, " info\n");
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h
index 90b966e667..86af3a5ec7 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.h
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.h
@@ -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);
diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index c8aee2fc23..521499ff95 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -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);
}
diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index ab2afd2c56..16b115c51e 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -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 ((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;
- }
- }
+ 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)) {
+ 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;