PR #21470 opened by Rost (rost.kurylo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21470
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21470.patch


>From 6bc89b9956a2bf5606a6d3bd89c7abcba1c61110 Mon Sep 17 00:00:00 2001
From: Rost Kurylo <[email protected]>
Date: Tue, 13 Jan 2026 11:17:57 -0800
Subject: [PATCH 1/2] Don't bind sockets to 0.0.0.0 by default for unicast UDP
 inputs

---
 libavformat/udp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 61e80c86c5..4718457f42 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -700,6 +700,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
     struct sockaddr_storage my_addr;
     socklen_t len;
     int ret;
+    const char *bind_addr = NULL;
 
     h->is_streamed = 1;
 
@@ -759,7 +760,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
     if ((s->is_multicast || s->local_port < 0) && (h->flags & AVIO_FLAG_READ))
         s->local_port = port;
 
-    udp_fd = udp_socket_create(h, &my_addr, &len, s->localaddr);
+    if (!s->is_multicast && (s->localaddr == NULL || s->localaddr[0] == '\0') 
&& h->flags & AVIO_FLAG_READ)
+        bind_addr = hostname;
+    else
+        bind_addr = s->localaddr;
+
+    udp_fd = udp_socket_create(h, &my_addr, &len, bind_addr);
     if (udp_fd < 0) {
         ret = AVERROR(EIO);
         goto fail;
-- 
2.49.1


>From 0ed684751806933020deba95345b608284feb489 Mon Sep 17 00:00:00 2001
From: Rost Kurylo <[email protected]>
Date: Tue, 13 Jan 2026 11:28:04 -0800
Subject: [PATCH 2/2] Explicitly bind RTP sockets to 0.0.0.0 in rtsp

A better alternative is to bind to a local IP that is used to
communicate with RTSP server via signalling socket. Should be
considered as a further improvement.
---
 libavformat/rtsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index e8f44e571a..048f8de5bb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1566,7 +1566,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const 
char *host, int port,
             while (j + 1 <= rt->rtp_port_max) {
                 AVDictionary *opts = map_to_opts(rt);
 
-                ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1,
+                ff_url_join(buf, sizeof(buf), "rtp", NULL, "0.0.0.0", -1,
                             "?localport=%d", j);
                 /* we will use two ports per rtp stream (rtp and rtcp) */
                 j += 2;
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to