diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 95e66f2f6d..0005008252 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -120,6 +120,7 @@ struct switch_core_session { switch_codec_t *video_write_codec; switch_codec_implementation_t read_impl; + switch_codec_implementation_t real_read_impl; switch_codec_implementation_t write_impl; switch_codec_implementation_t video_read_impl; switch_codec_implementation_t video_write_impl; diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 624d491e1d..522ebec1f8 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1500,6 +1500,7 @@ SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_sess SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 26fc3e2668..441da03052 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -8464,12 +8464,33 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ bridge_uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE); if (call_info) { + const char *olu; + switch_core_session_t *os; + switch_codec_implementation_t read_impl = { 0 }; + char *codec_str = ""; + + if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) { + olu = bridge_uuid; + } else { + olu = b_private->uuid; + } + + if ((os = switch_core_session_locate(olu))) { + switch_core_session_get_real_read_impl(os, &read_impl); + switch_core_session_rwunlock(os); + + codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame, + read_impl.microseconds_per_packet / 1000); + } + + + if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) { tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,intercept:%s", bridge_uuid); + "%sanswer,intercept:%s", codec_str, bridge_uuid); } else { tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,sofia_sla:%s", b_private->uuid); + "%sanswer,sofia_sla:%s", codec_str, b_private->uuid); } } else { if (!zstr(bridge_uuid)) { diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 28439c1b60..6ea47fcf13 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -206,6 +206,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s session->read_codec = session->real_read_codec = codec; if (codec->implementation) { session->read_impl = *codec->implementation; + session->real_read_impl = *codec->implementation; } else { memset(&session->read_impl, 0, sizeof(session->read_impl)); } @@ -319,6 +320,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_se return SWITCH_STATUS_FALSE; } +SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp) +{ + if (session->real_read_impl.codec_id) { + *impp = session->real_read_impl; + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp) { if (session->write_impl.codec_id) {