diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index aff86a6331..ae31d3a34c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1419,14 +1419,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_MEDIA: { uint32_t send_invite = 1; + const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); switch_channel_clear_flag(channel, CF_PROXY_MODE); switch_core_media_set_local_sdp(session, NULL, SWITCH_FALSE); if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) { if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { - const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); - switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE); if (sofia_media_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) { @@ -1439,7 +1438,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } if (!switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { - switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE); + switch_core_media_set_sdp_codec_string(tech_pvt->session, r_sdp, SDP_TYPE_RESPONSE); + switch_channel_set_variable(tech_pvt->channel, "absolute_codec_string", switch_channel_get_variable(tech_pvt->channel, "ep_codec_string")); + switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE); + if ((status = switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0)) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); goto end_lock; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index ee03f235ce..ba8143de4f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -792,6 +792,7 @@ struct private_object { char *respond_dest; time_t last_vid_info; uint32_t keepalive; + uint32_t sent_invites; }; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 99caba5c2e..3a9fdf800f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -735,8 +735,12 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) cid_name = caller_profile->caller_id_name; cid_num = caller_profile->caller_id_number; - switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE); - switch_core_media_check_video_codecs(tech_pvt->session); + + if (!tech_pvt->sent_invites && !switch_channel_test_flag(channel, CF_ANSWERED)) { + switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE); + switch_core_media_check_video_codecs(tech_pvt->session); + } + check_decode(cid_name, session); check_decode(cid_num, session); @@ -1229,6 +1233,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) switch_channel_get_name(tech_pvt->channel), switch_version_full_human(), tech_pvt->mparams.local_sdp_str ? tech_pvt->mparams.local_sdp_str : "NO SDP PRESENT\n"); + tech_pvt->sent_invites++; if (sofia_use_soa(tech_pvt)) { nua_invite(tech_pvt->nh,