diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index ac47236f9d..95485e9c1a 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -243,7 +243,7 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_ses SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp); SWITCH_DECLARE(void) switch_core_media_reset_autofix_timing(switch_core_session_t *session, switch_media_type_t type); -SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session); +SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session); SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t media); SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *session); SWITCH_DECLARE(switch_status_t) switch_core_media_add_ice_acl(switch_core_session_t *session, switch_media_type_t type, const char *acl_name); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c088e7a940..4017042410 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4320,7 +4320,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } } - switch_core_media_check_outgoing_proxy(session); + switch_core_media_check_outgoing_proxy(nsession, session); } diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 24f91ad51c..435ad2d0ec 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6266,7 +6266,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } break; case nua_callstate_ready: - if (r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) { + if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA) && + r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) { /* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */ uint8_t match = 0; diff --git a/src/switch_core_media.c b/src/switch_core_media.c index fc21c395b4..a69628d7ab 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -4993,6 +4993,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess rate = a_engine->codec_params.rm_rate; + if (a_engine->codec_params.adv_channels > 1) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\n", a_engine->codec_params.agreed_pt, a_engine->codec_params.rm_encoding, rate, a_engine->codec_params.adv_channels); @@ -5726,7 +5727,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session) return; } - if (zstr(a_engine->codec_params.local_sdp_ip) || !a_engine->codec_params.local_sdp_port) { + if (zstr(a_engine->codec_params.local_sdp_ip) || !a_engine->codec_params.local_sdp_port || switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) { if (switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_AUDIO, 1) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s I/O Error\n", switch_channel_get_name(session->channel)); @@ -6919,37 +6920,42 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_sessi //? -SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session) +SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session) { switch_rtp_engine_t *a_engine, *v_engine; switch_media_handle_t *smh; + const char *r_sdp = NULL; switch_assert(session); + if (!switch_channel_test_flag(o_session->channel, CF_PROXY_MEDIA)) { + return; + } + if (!(smh = session->media_handle)) { return; } + + r_sdp = switch_channel_get_variable(o_session->channel, SWITCH_R_SDP_VARIABLE); a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO]; v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO]; + switch_channel_set_flag(session->channel, CF_PROXY_MEDIA); + a_engine->codec_params.iananame = switch_core_session_strdup(session, "PROXY"); a_engine->codec_params.rm_rate = 8000; + a_engine->codec_params.codec_ms = 20; - if (switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) { - const char *r_sdp = switch_channel_get_variable(session->channel, SWITCH_R_SDP_VARIABLE); - - if (switch_stristr("m=video", r_sdp)) { - switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1); - v_engine->codec_params.rm_encoding = "PROXY-VID"; - v_engine->codec_params.rm_rate = 90000; - v_engine->codec_params.codec_ms = 0; - switch_channel_set_flag(session->channel, CF_VIDEO); - switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); - } + if (switch_stristr("m=video", r_sdp)) { + switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1); + v_engine->codec_params.rm_encoding = "PROXY-VID"; + v_engine->codec_params.rm_rate = 90000; + v_engine->codec_params.codec_ms = 0; + switch_channel_set_flag(session->channel, CF_VIDEO); + switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); } - } //? diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 8968a3a141..2636c3da7e 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -2462,7 +2462,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess } if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto")); + if (rtp_session->dtls) { + switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:dtls:AES_CM_128_HMAC_SHA1_80"); + } else { + switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto")); + } switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel)); switch_event_fire(&fsevent); }