summaryrefslogtreecommitdiff
path: root/libavformat/udp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-10 01:12:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-10 01:12:08 +0100
commit8e31dbc1dcb56d40bcc1dd45840aaef0d37bae51 (patch)
tree08342b8eede67521c32c139ebb4d9ddd04e871fa /libavformat/udp.c
parent1af9fdc3baa47596757da7c401d58710cef45c75 (diff)
parentffae713a5b3a0d20ff958d8bd58a052b495c38fd (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: Fix a bunch of common typos. build: Skip compiling xvmc.h under the correct condition. configure: darwin: Change dylib install names to include major version. mpegts: Always honor a registration descriptor if present and there is no other codec information. aacdec: Fix SCE parity check. aacdec: Fix out of array writes (stack). rtsp: Only set the ttl parameter if the server actually gave a value udp: Set ttl for read-write streams, too, not only for write-only ones udp: Only bind to the multicast address if in read-only mode udp: Clarify the comment about binding the multicast address udp: Reorder comments Conflicts: libavcodec/aacdec.c tools/patcheck Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r--libavformat/udp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c
index d3e4d906a7..cfc5ae51db 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -473,13 +473,16 @@ 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 multicast, try the multicast address bind first */
- if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) {
+ /* If multicast, try binding the multicast address first, to avoid
+ * 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)) {
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 */
+ /* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
goto fail;
@@ -490,11 +493,12 @@ static int udp_open(URLContext *h, const char *uri, int flags)
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
- if (!(h->flags & AVIO_FLAG_READ)) {
+ if (h->flags & AVIO_FLAG_WRITE) {
/* output */
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
- } else {
+ }
+ if (h->flags & AVIO_FLAG_READ) {
/* input */
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;