From 607f5db1406f3c0eca0a0473ebcbfc0b283402ba Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 16 Sep 2021 20:17:28 -0700 Subject: [PATCH] [core] add SEND_RTCP_MESSAGE: toggle send rtcp events off fire_rtcp_events. eval most common path first when checking flags. --- src/include/switch_types.h | 1 + src/switch_core_media.c | 8 ++++++-- src/switch_rtp.c | 5 ++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 958f2b136a..059023e450 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -843,6 +843,7 @@ typedef enum { SWITCH_RTP_FLAG_PASSTHRU, SWITCH_RTP_FLAG_SECURE_SEND_MKI, SWITCH_RTP_FLAG_SECURE_RECV_MKI, + SWITCH_RTP_FLAG_AUDIO_FIRE_SEND_RTCP_EVENT, SWITCH_RTP_FLAG_VIDEO_FIRE_SEND_RTCP_EVENT, SWITCH_RTP_FLAG_INVALID } switch_rtp_flag_t; diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 57273d96f1..40180edc38 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -8775,6 +8775,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_variable(session->channel, "rtp_use_timer_name", timer_name); + if (switch_channel_var_true(session->channel, "fire_rtcp_events")) { + flags[SWITCH_RTP_FLAG_AUDIO_FIRE_SEND_RTCP_EVENT] = 1; + } a_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip, a_engine->local_sdp_port, @@ -9511,8 +9514,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi flags[SWITCH_RTP_FLAG_TMMBR]++; } - if (switch_channel_var_true(session->channel, "enable_send_rtcp_message_event_video")) { - flags[SWITCH_RTP_FLAG_VIDEO_FIRE_SEND_RTCP_EVENT] = 1; + if (switch_channel_var_true(session->channel, "fire_rtcp_events") && + switch_channel_var_true(session->channel, "enable_send_rtcp_message_event_video")) { + flags[SWITCH_RTP_FLAG_VIDEO_FIRE_SEND_RTCP_EVENT] = 1; } v_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip, diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 59882a122a..e2fcf45419 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -2286,9 +2286,8 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) rtcp_generate_report_block(rtp_session, rtcp_report_block, nack_dup); rtp_session->rtcp_send_msg.header.count = 1; /* reception report block count */ stats->sent_pkt_count = 0; - /* send event for audio, or video if flag set */ - if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO_FIRE_SEND_RTCP_EVENT] || - !(rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] || rtp_session->flags[SWITCH_RTP_FLAG_TEXT])) { + if ((!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->flags[SWITCH_RTP_FLAG_AUDIO_FIRE_SEND_RTCP_EVENT]) || + (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->flags[SWITCH_RTP_FLAG_VIDEO_FIRE_SEND_RTCP_EVENT])) { switch_send_rtcp_event(rtp_session, sr, rtcp_report_block); } }