[FFmpeg-devel] [PATCH] always enable reuse for reading multicast udp

aviad rozenhek aviadr1
Thu Oct 7 11:26:38 CEST 2010


>
> > @@ -361,6 +364,8 @@ static int udp_open(URLContext *h, const char *uri,
> int flags)
> >
> >      if (s->is_multicast && !(h->flags & URL_WRONLY))
> >          s->local_port = port;
> > +    if(s->is_multicast && !has_reuse_arg && !(h->flags & (URL_WRONLY |
> URL_RDWR)))
> > +        s->reuse_socket = 1;
>
> Couldn't you do just && h->flags & URL_RDONLY at the end?
>
>
no because URL_RDONLY is #defined to be 0


> >      udp_fd = udp_socket_create(s, &my_addr, &len);
> >      if (udp_fd < 0)
> >          goto fail;
> > --
> > 1.6.0.4
> >
>
> I don't think this would do much harm if enabled for all read-only
> sockets, not only multicast. Then the code could be quite much simplified,
> into something like this:
>

I disagree since usually the expectation is that if a socket has been opened
by one application, it cannot be opened by another application in parallel,
except for the case of multicast.


>
> From 59f3bf42df15716ac5555d9c1ff2c720fdceb731 Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Mon, 4 Oct 2010 23:43:02 -0400
> Subject: [PATCH] Allow reuse of UDP addresses for read-only sockets by
> default, unless reuse=0 is specified
>
> ---
>  libavformat/udp.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index d30af57..5e4a1e8 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -310,10 +310,13 @@ static int udp_open(URLContext *h, const char *uri,
> int flags)
>     h->priv_data = s;
>     s->ttl = 16;
>     s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
> +    s->reuse_socket = h->flags & URL_RDONLY;
>
>     p = strchr(uri, '?');
>     if (p) {
> -        s->reuse_socket = find_info_tag(buf, sizeof(buf), "reuse", p);
> +        if (find_info_tag(buf, sizeof(buf), "reuse", p)) {
> +            s->reuse_socket = strtol(buf, NULL, 10);
> +        }
>          if (find_info_tag(buf, sizeof(buf), "ttl", p)) {
>             s->ttl = strtol(buf, NULL, 10);
>         }
> --
> 1.7.3.1
>
>
> // Martin
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>



-- 
Aviad Rozenhek



More information about the ffmpeg-devel mailing list