aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJindřich Makovička <makovick@gmail.com>2008-12-07 17:29:09 +0000
committerJindřich Makovička <makovick@gmail.com>2008-12-07 17:29:09 +0000
commit36b532815cb83acc1d773cea63eea52303bedddc (patch)
tree40f57e95f6ea9a94546d3ef5fc958882feab94fd
parent0dfcc368188d9c8ffba79f2165521a43cde62ea0 (diff)
downloadffmpeg-36b532815cb83acc1d773cea63eea52303bedddc.tar.gz
bind to the multicast address if possible
Originally committed as revision 16032 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/udp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c
index bbdb930e4e..59ba4188b5 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -336,7 +336,7 @@ int udp_get_file_handle(URLContext *h)
static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024];
- int port, udp_fd = -1, tmp;
+ int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = NULL;
int is_output;
const char *p;
@@ -404,7 +404,13 @@ static int udp_open(URLContext *h, const char *uri, int flags)
goto fail;
/* the bind is needed to give a port to the socket now */
- if (bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0)
+ /* if multicast, try the multicast address bind first */
+ if (s->is_multicast && !(h->flags & URL_WRONLY)) {
+ bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
+ }
+ /* bind to the local address if not multicast or if the multicast
+ * bind failed */
+ if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0)
goto fail;
len = sizeof(my_addr);