From ae82034dfe1878af0dcdcbae0e6db702ce5fb86f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 26 Jan 2021 10:07:57 -0500 Subject: [PATCH] TT#99621 add option to disable RTCP generation Change-Id: Ifed6d255dd9d3ec5bc38a79a8f71da59d98243ea --- README.md | 13 +++++++++---- daemon/call.c | 4 ++++ daemon/call_interfaces.c | 7 +++++++ daemon/codec.c | 6 ++++-- include/call_interfaces.h | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0ee1a0f43..03b50bd20 100644 --- a/README.md +++ b/README.md @@ -827,10 +827,15 @@ Optionally included keys are: - `generate RTCP` - With this flag set, received RTCP packets will not simply be passed through as - usual, but instead will be consumed, and instead *rtpengine* will generate its own - RTCP packets to send to the RTP peers. This flag will be effective for both - sides of a call. + Identical to setting `generate RTCP = on`. + +* `generate RTCP` + + Contains a string, either `on` or `off`. If enabled for a call, + received RTCP packets will not simply be passed through as usual, but + instead will be consumed, and instead *rtpengine* will generate its own + RTCP packets to send to the RTP peers. This flag will be effective for + both sides of a call. * `replace` diff --git a/daemon/call.c b/daemon/call.c index 9bfd2976a..dd8551533 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2132,6 +2132,10 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams, MEDIA_SET(media, RTCP_GEN); MEDIA_SET(other_media, RTCP_GEN); } + else if (flags && flags->generate_rtcp_off) { + MEDIA_CLEAR(media, RTCP_GEN); + MEDIA_CLEAR(other_media, RTCP_GEN); + } __update_media_protocol(media, other_media, sp, flags); __update_media_id(media, other_media, sp, flags); diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 2094dd082..1bbbdab28 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1111,6 +1111,13 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu } #endif } + + if (bencode_get_alt(input, "generate-RTCP", "generate RTCP", &s)) { + if (!str_cmp(&s, "on")) + out->generate_rtcp = 1; + else if (!str_cmp(&s, "off")) + out->generate_rtcp_off = 1; + } } static void call_ng_free_flags(struct sdp_ng_flags *flags) { if (flags->codec_strip) diff --git a/daemon/codec.c b/daemon/codec.c index 9fdcb4198..acc286e38 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1186,9 +1186,11 @@ static void __rtcp_timer_run(struct timerthread_queue *q, void *p) { log_info_call(rt->call); - if (!rtcp_timer.tv_sec || timeval_diff(&rtpe_now, &rtcp_timer) < 0 || !proto_is_rtp(media->protocol)) { - __rtcp_timer_free(rt); + if (!rtcp_timer.tv_sec || timeval_diff(&rtpe_now, &rtcp_timer) < 0 || !proto_is_rtp(media->protocol) + || !MEDIA_ISSET(media, RTCP_GEN)) + { rwlock_unlock_w(&rt->call->master_lock); + __rtcp_timer_free(rt); goto out; } timeval_add_usec(&rtcp_timer, 5000000 + (random() % 2000000)); diff --git a/include/call_interfaces.h b/include/call_interfaces.h index fbdb5d85b..56e19cf20 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -79,6 +79,7 @@ struct sdp_ng_flags { no_rtcp_attr:1, full_rtcp_attr:1, generate_rtcp:1, + generate_rtcp_off:1, generate_mid:1, strict_source:1, media_handover:1,