On Wed, 31 Jul 2013 16:54:23 +0200, Luca Barbato <[email protected]> wrote:
> ---
> 
> Now with configure checks, still needs some testing, volunteers welcome.
> 
>  configure                |   3 +
>  libavformat/Makefile     |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/unix.c       | 165 
> +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 170 insertions(+)
>  create mode 100644 libavformat/unix.c
> 
> diff --git a/configure b/configure
> index 6b52eff..c6d6d5d 100755
> --- a/configure
> +++ b/configure
> @@ -1353,6 +1353,7 @@ HAVE_LIST="
>      sys_select_h
>      sys_soundcard_h
>      sys_time_h
> +    sys_un_h
>      sys_videoio_h
>      threads
>      unistd_h
> @@ -1884,6 +1885,7 @@ tcp_protocol_select="network"
>  tls_protocol_deps_any="openssl gnutls"
>  tls_protocol_select="tcp_protocol"
>  udp_protocol_select="network"
> +unix_protocol_select="network sys_un_h"
> 
>  # filters
>  blackframe_filter_deps="gpl"
> @@ -3661,6 +3663,7 @@ check_header sys/param.h
>  check_header sys/resource.h
>  check_header sys/select.h
>  check_header sys/time.h
> +check_header sys/un.h
>  check_header unistd.h
>  check_header vdpau/vdpau.h
>  check_header vdpau/vdpau_x11.h
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 35070d7..5bf1295 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -376,6 +376,7 @@ OBJS-$(CONFIG_SRTP_PROTOCOL)             += srtpproto.o 
> srtp.o
>  OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
>  OBJS-$(CONFIG_TLS_PROTOCOL)              += tls.o
>  OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
> +OBJS-$(CONFIG_UNIX_PROTOCOL)             += unix.o
> 
>  SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
>  SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 142d647..585cf43 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -281,6 +281,7 @@ void av_register_all(void)
>      REGISTER_PROTOCOL(TCP,              tcp);
>      REGISTER_PROTOCOL(TLS,              tls);
>      REGISTER_PROTOCOL(UDP,              udp);
> +    REGISTER_PROTOCOL(UNIX,             unix);
> 
>      /* external libraries */
>      REGISTER_PROTOCOL(LIBRTMP,          librtmp);
> diff --git a/libavformat/unix.c b/libavformat/unix.c
> new file mode 100644
> index 0000000..e98dc43
> --- /dev/null
> +++ b/libavformat/unix.c
> @@ -0,0 +1,165 @@
> +/*
> + * Unix socket protocol
> + * Copyright (c) 2013 Luca Barbato
> + *
> + * This file is part of Libav.
> + *
> + * Libav is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * Libav is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + *
> + * unix url_protocol
> + *
> + * url syntax: unix://path/to/socket
> + *
> + * AVOptions:
> + * option: 'listen'        : listen for an incoming connection
> + *
> + * @see unix_read
> + * @see unix_write
> + */
> +
> +#include <sys/un.h>
> +
> +#include "config.h"
> +
> +#if HAVE_POLL_H
> +#include <poll.h>
> +#endif
> +
> +#include "libavutil/avstring.h"
> +#include "libavutil/opt.h"
> +#include "avformat.h"
> +#include "internal.h"
> +#include "network.h"
> +#include "os_support.h"
> +#include "url.h"
> +
> +typedef struct UnixContext {
> +    const AVClass *class;
> +    struct sockaddr_un addr;
> +    int timeout;
> +    int listen;
> +    int fd;
> +} UnixContext;
> +
> +#define OFFSET(x) offsetof(UnixContext, x)
> +#define ED AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_ENCODING_PARAM
> +static const AVOption file_options[] = {
> +    { "unix_listen", "Open socket for listening", OFFSET(listen),  
> AV_OPT_TYPE_INT, { .i64 = 0 },   0, 1, ED },
> +    { "unix_timeout", "Timeout in ms",            OFFSET(timeout), 
> AV_OPT_TYPE_INT, { .i64 = 100 }, 0, 1, ED },
> +    { NULL }
> +};

Looks fine from a quick glance, except I'd drop the unix_ prefix from the
options.
Also some docs in protocols.texi would be nice.
And a minor bump/mention in general.texi.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to