[FFmpeg-devel] [patch] fix problem receiving udp multicast
Deti Fliegl
deti at fliegl.de
Tue Nov 19 22:41:10 CET 2013
Hi there,
I am using the trunk version of ffmpeg. When receiving udp multicast
libavformat does not bind the destination address which results in
receiving all subscribed multicast traffic from only one network socket.
This causes massively scrambled data containing every stream on the
network seen by libavformat. Someone commented in the source of udp.c
that bind would not work under Windows and disabled it completely for
all platforms.
This patch tries to keep things broken for Windows and fixes it for the
rest.
Deti
-------------- next part --------------
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 3c0d6bf..3b36198 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -530,7 +530,12 @@ static int udp_open(URLContext *h, const char *uri, int flags)
int reuse_specified = 0;
int i, num_include_sources = 0, num_exclude_sources = 0;
char *include_sources[32], *exclude_sources[32];
-
+ int is_win32 = 0;
+
+ #if defined(_WIN32) || defined(__MINGW32CE__)
+ is_win32 = 1;
+ #endif
+
h->is_streamed = 1;
is_output = !(flags & AVIO_FLAG_READ);
@@ -637,7 +642,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
* receiving UDP packets from other sources aimed at the same UDP
* port. This fails on windows. This makes sending to the same address
* using sendto() fail, so only do it if we're opened in read-only mode. */
- if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
+ if (s->is_multicast && (!(h->flags & AVIO_FLAG_WRITE) || !is_win32)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
/* bind to the local address if not multicast or if the multicast
More information about the ffmpeg-devel
mailing list