From cc056c148f240c9884691701cbd7cd2d09c956af Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 17 Oct 2017 10:43:53 -0400 Subject: [PATCH] add rtcp-mux-require option to force rtcp-mux usage for WebRTC fixes #404 Change-Id: I4a5dbf30a7c02058216ea7e8c8782cf83e214623 --- README.md | 6 ++++++ daemon/call.c | 2 +- daemon/call_interfaces.c | 2 ++ daemon/call_interfaces.h | 1 + daemon/sdp.c | 6 +++++- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75d821104..9ca3e4d92 100644 --- a/README.md +++ b/README.md @@ -1018,6 +1018,12 @@ Optionally included keys are: Instructs *rtpengine* to always offer rtcp-mux, even if the client itself doesn't offer it. + - `require` + + Similar to `offer` but pretends that the receiving client has already accepted rtcp-mux. + The effect is that no separate RTCP ports will be advertised, even in an initial offer + (which is against RFC 5761). This option is provided to talk to WebRTC clients. + - `demux` If the client is offering rtcp-mux, don't offer it to the other side, but accept it back to diff --git a/daemon/call.c b/daemon/call.c index 9b7994f72..914057f2c 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1275,7 +1275,7 @@ static void __rtcp_mux_logic(const struct sdp_ng_flags *flags, struct call_media if (!MEDIA_ISSET(media, RTCP_MUX)) bf_copy_same(&media->media_flags, &other_media->media_flags, MEDIA_FLAG_RTCP_MUX); /* in our offer, we can override the client's choice */ - if (flags->rtcp_mux_offer) + if (flags->rtcp_mux_offer || flags->rtcp_mux_require) MEDIA_SET(media, RTCP_MUX); else if (flags->rtcp_mux_demux) MEDIA_CLEAR(media, RTCP_MUX); diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 91b4b9e66..1f7aba8f6 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -622,6 +622,8 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu for (it = list->child; it; it = it->sibling) { if (!bencode_strcmp(it, "offer")) out->rtcp_mux_offer = 1; + else if (!bencode_strcmp(it, "require")) + out->rtcp_mux_require = 1; else if (!bencode_strcmp(it, "demux")) out->rtcp_mux_demux = 1; else if (!bencode_strcmp(it, "accept")) diff --git a/daemon/call_interfaces.h b/daemon/call_interfaces.h index 33d61cb58..4887dc971 100644 --- a/daemon/call_interfaces.h +++ b/daemon/call_interfaces.h @@ -43,6 +43,7 @@ struct sdp_ng_flags { ice_force:1, ice_force_relay:1, rtcp_mux_offer:1, + rtcp_mux_require:1, rtcp_mux_demux:1, rtcp_mux_accept:1, rtcp_mux_reject:1, diff --git a/daemon/sdp.c b/daemon/sdp.c index 49d8c6398..ef8fa61ff 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1993,7 +1993,11 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu chopper_append_c(chop, "a=inactive\r\n"); if (call_media->protocol && call_media->protocol->rtp) { - if (MEDIA_ISSET(call_media, RTCP_MUX) && flags->opmode == OP_ANSWER) { + if (MEDIA_ISSET(call_media, RTCP_MUX) + && (flags->opmode == OP_ANSWER + || (flags->opmode == OP_OFFER + && flags->rtcp_mux_require))) + { chopper_append_c(chop, "a=rtcp:"); chopper_append_printf(chop, "%u", ps->selected_sfd->socket.local.port); chopper_append_c(chop, "\r\na=rtcp-mux\r\n");