udp: Receive on the remote port number, if no local port is set

Message ID 1308296834-171-1-git-send-email-martin@martin.st
State Committed
Commit fc66e231541b91b22f6e0d8257991cc5343db8d5
Headers show

Commit Message

Martin Storsjö June 17, 2011, 7:47 a.m.
From: Can Wu <wu.canus@gmail.com>

For a unicast udp stream to localhost:1234, currently
ffplay udp://:1234?localport=1234
works, but
ffplay udp://:1234
doesn't work.
---
 libavformat/udp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

wucan June 20, 2011, 1:35 a.m. | #1
On 06/17/11 15:47, Martin Storsjö wrote:

I'm ok with this.

> From: Can Wu<wu.canus@gmail.com>
>
> For a unicast udp stream to localhost:1234, currently
> ffplay udp://:1234?localport=1234
> works, but
> ffplay udp://:1234
> doesn't work.
> ---
>   libavformat/udp.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index d6522bf..724ff01 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -365,7 +365,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
>               goto fail;
>       }
>
> -    if (s->is_multicast&&  (h->flags&  AVIO_FLAG_READ))
> +    if ((s->is_multicast || !s->local_port)&&  (h->flags&  AVIO_FLAG_READ))
>           s->local_port = port;
>       udp_fd = udp_socket_create(s,&my_addr,&len);
>       if (udp_fd<  0)
Ronald Bultje June 24, 2011, 3:26 p.m. | #2
Hi,

On Fri, Jun 17, 2011 at 12:47 AM, Martin Storsjö <martin@martin.st> wrote:
> From: Can Wu <wu.canus@gmail.com>
>
> For a unicast udp stream to localhost:1234, currently
> ffplay udp://:1234?localport=1234
> works, but
> ffplay udp://:1234
> doesn't work.
> ---
>  libavformat/udp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index d6522bf..724ff01 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -365,7 +365,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
>             goto fail;
>     }
>
> -    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
> +    if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))

OK.

Ronald

Patch

diff --git a/libavformat/udp.c b/libavformat/udp.c
index d6522bf..724ff01 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -365,7 +365,7 @@  static int udp_open(URLContext *h, const char *uri, int flags)
             goto fail;
     }
 
-    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
+    if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
         s->local_port = port;
     udp_fd = udp_socket_create(s, &my_addr, &len);
     if (udp_fd < 0)