[libav-devel] [PATCH 1/4] avio: Add a function for signalling end of reading/writing.

Martin Storsjö martin at martin.st
Mon May 21 12:21:28 CEST 2012


On Mon, 21 May 2012, Samuel Pitoiset wrote:

> ---
> libavformat/avio.c       |    7 +++++++
> libavformat/os_support.h |    6 ++++++
> libavformat/url.h        |   13 +++++++++++++
> 3 files changed, 26 insertions(+)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index ba25abe..371500e 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -345,6 +345,13 @@ int ffurl_get_file_handle(URLContext *h)
>     return h->prot->url_get_file_handle(h);
> }
>
> +int ffurl_shutdown(URLContext *h, int flags)
> +{
> +    if (!h->prot->url_shutdown)
> +        return AVERROR(EINVAL);
> +    return h->prot->url_shutdown(h, flags);
> +}
> +
> int ff_check_interrupt(AVIOInterruptCB *cb)
> {
>     int ret;
> diff --git a/libavformat/os_support.h b/libavformat/os_support.h
> index 20c6d73..1088c6c 100644
> --- a/libavformat/os_support.h
> +++ b/libavformat/os_support.h
> @@ -45,6 +45,12 @@ static inline int is_dos_path(const char *path)
>     return 0;
> }
>
> +#if defined(_WIN32)
> +#define SHUT_RD SD_RECEIVE
> +#define SHUT_WR SD_SEND
> +#define SHUT_RDWR SD_BOTH
> +#endif
> +
> #if defined(_WIN32) && !defined(__MINGW32CE__)
> int ff_win32_open(const char *filename, int oflag, int pmode);
> #define open ff_win32_open
> diff --git a/libavformat/url.h b/libavformat/url.h
> index bf8b6ed..0f0de78 100644
> --- a/libavformat/url.h
> +++ b/libavformat/url.h
> @@ -81,6 +81,7 @@ typedef struct URLProtocol {
>     int64_t (*url_read_seek)(URLContext *h, int stream_index,
>                              int64_t timestamp, int flags);
>     int (*url_get_file_handle)(URLContext *h);
> +    int (*url_shutdown)(URLContext *h, int flags);
>     int priv_data_size;
>     const AVClass *priv_data_class;
>     int flags;
> @@ -201,6 +202,18 @@ int64_t ffurl_size(URLContext *h);
> int ffurl_get_file_handle(URLContext *h);
>
> /**
> + * Signal the URLContext that we are done reading or writing the stream.
> + *
> + * @param h pointer to the resource
> + * @param flags flags which control how the resource indicated by url
> + * is to be shutdown
> + *
> + * @return a negative value if an error condition occurred, 0
> + * otherwise
> + */
> +int ffurl_shutdown(URLContext *h, int flags);
> +
> +/**
>  * Register the URLProtocol protocol.
>  *
>  * @param size the size of the URLProtocol struct referenced
> -- 
> 1.7.10.2

Looks good to me.

// Martin


More information about the libav-devel mailing list