From 88dff1c02161e16e41a0b8c88535205efbad4d67 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 24 Sep 2024 20:08:42 +0300 Subject: [PATCH] rtp-sap: announce the source IP as the "connection" address in unicast The "connection" address ("c=") is meant to be the address that the RTP receiver will use to filter for incoming packets. In multicast, it must be the multicast address, which is also the "destination" address in this context. In unicast, however, it must be the sender's address, i.e. the "source" in this context. The RTP receiver will then call connect() on this address, effectively filtering the incoming packets to the ones coming from that particular source. --- src/modules/module-rtp-sap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/module-rtp-sap.c b/src/modules/module-rtp-sap.c index cc0c27035..cda09efb4 100644 --- a/src/modules/module-rtp-sap.c +++ b/src/modules/module-rtp-sap.c @@ -650,6 +650,7 @@ static int send_sap(struct impl *impl, struct session *sess, bool bye) struct spa_strbuf buf; struct sdp_info *sdp = &sess->info; bool src_ip4, dst_ip4; + bool multicast; int res; if (!sess->has_sent_sap && bye) @@ -683,8 +684,10 @@ static int send_sap(struct impl *impl, struct session *sess, bool bye) if ((user_name = pw_get_user_name()) == NULL) user_name = "-"; + multicast = is_multicast((struct sockaddr*)&sdp->dst_addr, sdp->dst_len); + spa_zero(dst_ttl); - if (is_multicast((struct sockaddr*)&sdp->dst_addr, sdp->dst_len)) + if (multicast) snprintf(dst_ttl, sizeof(dst_ttl), "/%d", sdp->ttl); spa_strbuf_init(&buf, buffer, sizeof(buffer)); @@ -700,7 +703,7 @@ static int send_sap(struct impl *impl, struct session *sess, bool bye) "m=%s %u RTP/AVP %i\n", user_name, sdp->session_id, sdp->session_version, src_ip4 ? "IP4" : "IP6", src_addr, sdp->session_name, - dst_ip4 ? "IP4" : "IP6", dst_addr, dst_ttl, + (multicast ? dst_ip4 : src_ip4) ? "IP4" : "IP6", multicast ? dst_addr : src_addr, dst_ttl, sdp->t_ntp, sdp->media_type, sdp->dst_port, sdp->payload);