[FFmpeg-devel] [PATCH] always enable reuse for reading multicast udp
Martin Storsjö
martin
Thu Oct 7 10:48:29 CEST 2010
On Thu, 7 Oct 2010, aviad rozenhek wrote:
> On Tue, Oct 5, 2010 at 00:01, aviad rozenhek <aviadr1 at gmail.com> wrote:
>
> > On Thu, Sep 16, 2010 at 13:50, aviad rozenhek <aviadr1 at gmail.com> wrote:
> >
> >> On Thu, Sep 16, 2010 at 04:51, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> >>
> >>> aviad rozenhek <aviadr1 <at> gmail.com> writes:
> >>>
> >>> > - int len;
> >>> > + int len, has_reuse_arg = 0;
> >>>
> >>> Being read-only, the new variable does not look useful.
> >>>
> >>>
> >> fixed by using it properly
> >>
> >> + if (find_info_tag(buf, sizeof(buf), "reuse", p)) {
> >> + s->reuse_socket = strtol(buf, NULL, 10);
> >> + has_reuse_arg = 1;
> >> + }
> >>
> >
> > attached is the correct patch which IMHO addresses the comments made
> > earlier.
> > again the idea here is that reuse should be enabled by default for
> > read-only multicast udp, but it can be overriden by user.
> >
>
>
> ping
> From b9b796d79368dceaaec9995ffed7ce181a21b244 Mon Sep 17 00:00:00 2001
> From: aviad <aviad at aviad-ubuntu.(none)>
> Date: Mon, 4 Oct 2010 23:43:02 -0400
> Subject: [PATCH] enable mutlicast udp reuse, for read-only multicast udp
>
> ---
> libavformat/udp.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 83e8b37..5197053 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -314,7 +314,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
> const char *p;
> char buf[256];
> struct sockaddr_storage my_addr;
> - int len;
> + int len, has_reuse_arg = 0;
>
> h->is_streamed = 1;
> h->max_packet_size = 1472;
> @@ -331,7 +331,10 @@ static int udp_open(URLContext *h, const char *uri, int flags)
>
> 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);
> + has_reuse_arg = 1;
> + }
> if (find_info_tag(buf, sizeof(buf), "ttl", p)) {
> s->ttl = strtol(buf, NULL, 10);
> }
> @@ -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?
> 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:
More information about the ffmpeg-devel
mailing list