From b1714199cea82dae1fff190122a60f7520c33b4d Mon Sep 17 00:00:00 2001 From: Liyang Date: Mon, 20 May 2019 19:56:42 +0800 Subject: [PATCH] FS-11855: [Core] Offer all negotiated codecs in 200 OK when receiving re-INVITE without SDP --- src/include/switch_types.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 4 ++++ src/switch_core_media.c | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 059023e450..73c91d961e 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1564,6 +1564,7 @@ typedef enum { CF_T38_PASSTHRU, CF_DROP_DTMF, CF_REINVITE, + CF_NOSDP_REINVITE, CF_AUTOFLUSH_DURING_BRIDGE, CF_RTP_NOTIMER_DURING_BRIDGE, CF_AVPF, diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 491b9c6444..293199f07a 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -8028,6 +8028,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } + switch_channel_set_flag(channel, CF_NOSDP_REINVITE); + if (switch_channel_var_true(channel, "sip_unhold_nosdp")) { switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, "sendrecv", zstr(tech_pvt->mparams.local_sdp_str) || !switch_channel_test_flag(channel, CF_PROXY_MODE)); @@ -8036,6 +8038,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, zstr(tech_pvt->mparams.local_sdp_str) || !switch_channel_test_flag(channel, CF_PROXY_MODE)); } + switch_channel_clear_flag(channel, CF_NOSDP_REINVITE); + if (zstr(tech_pvt->mparams.local_sdp_str)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot find a SDP\n"); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 0e94724249..a32781ad99 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -10582,10 +10582,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", a_engine->cur_payload_map->pt); - if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO)) { + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO) || switch_channel_test_flag(session->channel, CF_NOSDP_REINVITE)) { switch_mutex_lock(smh->sdp_mutex); for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { - if (pmap->pt != a_engine->cur_payload_map->pt) { + if (pmap->pt != a_engine->cur_payload_map->pt && pmap->pt != smh->mparams->te) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", pmap->pt); } } @@ -10621,10 +10621,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\r\n", a_engine->cur_payload_map->pt, fmtp_out); } - if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO)) { + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO) || switch_channel_test_flag(session->channel, CF_NOSDP_REINVITE)) { switch_mutex_lock(smh->sdp_mutex); for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { - if (pmap->pt != a_engine->cur_payload_map->pt) { + if (pmap->pt != a_engine->cur_payload_map->pt && pmap->pt != smh->mparams->te) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\r\n", pmap->pt, pmap->iananame, pmap->rate);