diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index f8c5cf8f2e..5c6162a091 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -142,6 +142,7 @@ typedef struct switch_core_media_params_s { int num_codecs; int hold_laps; switch_core_media_dtmf_t dtmf_type; + switch_payload_t cng_pt; } switch_core_media_params_t; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index edda7ccecc..66c7904c04 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -161,7 +161,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * tech_pvt->mparams.rtcp_audio_interval_msec = profile->rtcp_audio_interval_msec; tech_pvt->mparams.rtcp_video_interval_msec = profile->rtcp_video_interval_msec; tech_pvt->mparams.sdp_username = profile->sdp_username; - + tech_pvt->mparams.cng_pt = tech_pvt->cng_pt; switch_media_handle_create(&tech_pvt->media_handle, session, &tech_pvt->mparams); switch_media_handle_set_media_flags(tech_pvt->media_handle, tech_pvt->profile->media_flags); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 6fb1674576..d859f282e2 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -140,7 +140,7 @@ struct switch_media_handle_s { int payload_space; char *origin; - switch_payload_t cng_pt; + const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS]; int num_negotiated_codecs; @@ -2119,7 +2119,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s cng_pt = (switch_payload_t) map->rm_pt; if (a_engine->rtp_session) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt); - switch_rtp_set_cng_pt(a_engine->rtp_session, smh->cng_pt); + switch_rtp_set_cng_pt(a_engine->rtp_session, smh->mparams->cng_pt); } } @@ -2461,7 +2461,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s sdp_parser_free(parser); } - smh->cng_pt = cng_pt; + smh->mparams->cng_pt = cng_pt; return match; } @@ -3082,8 +3082,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) { - smh->cng_pt = 0; - } else if (smh->cng_pt) { + smh->mparams->cng_pt = 0; + } else if (smh->mparams->cng_pt) { flags[SWITCH_RTP_FLAG_AUTO_CNG]++; } @@ -3423,7 +3423,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) || ((val = switch_channel_get_variable(session->channel, "supress_cng")) && switch_true(val)) || ((val = switch_channel_get_variable(session->channel, "suppress_cng")) && switch_true(val))) { - smh->cng_pt = 0; + smh->mparams->cng_pt = 0; } if (((val = switch_channel_get_variable(session->channel, "rtp_digit_delay")))) { @@ -3440,9 +3440,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } - if (smh->cng_pt && !switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", smh->cng_pt); - switch_rtp_set_cng_pt(a_engine->rtp_session, smh->cng_pt); + if (smh->mparams->cng_pt && !switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", smh->mparams->cng_pt); + switch_rtp_set_cng_pt(a_engine->rtp_session, smh->mparams->cng_pt); } switch_core_session_apply_crypto(session, SWITCH_MEDIA_TYPE_AUDIO, "rtp_secure_media_confirmed"); @@ -4018,7 +4018,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess ((val = switch_channel_get_variable(session->channel, "supress_cng")) && switch_true(val)) || ((val = switch_channel_get_variable(session->channel, "suppress_cng")) && switch_true(val))) { use_cng = 0; - smh->cng_pt = 0; + smh->mparams->cng_pt = 0; } if (!smh->payload_space) { @@ -4036,7 +4036,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess smh->payload_space++; } if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && - smh->cng_pt && use_cng && smh->cng_pt == smh->payload_space) { + smh->mparams->cng_pt && use_cng && smh->mparams->cng_pt == smh->payload_space) { smh->payload_space++; } smh->ianacodes[i] = smh->payload_space++; @@ -4136,8 +4136,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->te); } - if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) { - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->cng_pt); + if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->cng_pt); } switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n"); @@ -4158,10 +4158,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess && smh->mparams->te > 95) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", smh->mparams->te, smh->mparams->te); } - if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) { - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", smh->cng_pt); + if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", smh->mparams->cng_pt); if (!a_engine->codec_params.rm_encoding) { - smh->cng_pt = 0; + smh->mparams->cng_pt = 0; } } else { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=silenceSupp:off - - - -\n"); @@ -4197,11 +4197,11 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess int cur_ptime = 0, this_ptime = 0, cng_type = 0; const char *mult; - if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) { - cng_type = smh->cng_pt; + if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) { + cng_type = smh->mparams->cng_pt; if (!a_engine->codec_params.rm_encoding) { - smh->cng_pt = 0; + smh->mparams->cng_pt = 0; } } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 3481a2bef3..6c856986ba 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -992,7 +992,7 @@ static uint8_t get_next_write_ts(switch_rtp_t *rtp_session, uint32_t timestamp) if (rtp_session->ts <= rtp_session->last_write_ts && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) { m++; } - } else if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { + } else if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { rtp_session->ts = rtp_session->timer.samplecount; if (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->ts > 0) { @@ -1025,7 +1025,7 @@ static int check_srtp_and_ice(switch_rtp_t *rtp_session) switch_rtp_write_manual(rtp_session, (void *) data, 2, 0, rtp_session->cng_pt, ntohl(rtp_session->send_msg.header.ts), &frame_flags); - if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { + if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { rtp_session->last_write_samplecount = rtp_session->timer.samplecount; } } @@ -4276,7 +4276,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, } /* If the marker was set, and the timestamp seems to have started over - set a new SSRC, to indicate this is a new stream */ - if (m && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) && + if (m && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) && (rtp_session->last_write_ts == RTP_TS_RESET || (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->last_write_ts > 0))) { switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL))); }