[FFmpeg-devel] Quick Patch for Multicast UDP Receive on macOS
ffmpeg at gallery.co.uk
ffmpeg at gallery.co.uk
Thu Aug 16 17:56:30 EEST 2018
Hi Folks.
New here, so apologies if this is not how its done, but I have a tiny patch to fix a fundamental flaw in FFMPEG on macOS.
The Problem:
-------------------
On macOS Try to run 2 copies of FFMPEG each consuming an RTP Multicast which are on *different* multicast addresses - but the *same* port.
The second copy will fail with a bind error and possibly a crash.
The Solution:
------------------
Very simple - on macOS you need to use SO_REUSEPORT as well as SO_REUSEADDR to avoid this sort of issue.
Thanks
Mark Gilbert
CTO: Gallery SIENNA.
PATCH FOLLOWS:
--------------------------
--- /Users/mark/Downloads/udpORIG.c 2018-08-16 15:39:21.000000000 +0100
+++ /Users/mark/Downloads/udp.c 2018-08-16 15:40:55.000000000 +0100
@@ -828,7 +828,11 @@
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
- }
+ #ifdef __APPLE__ // MacOS/X requires an additional call
+ if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEPORT, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
+ goto fail;
+ #endif
+ }
if (s->is_broadcast) {
#ifdef SO_BROADCAST
More information about the ffmpeg-devel
mailing list