[FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
Michael Niedermayer
michaelni at gmx.at
Thu Mar 26 14:31:40 CET 2015
On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote:
> From: Lukasz Marek <lukasz.m.luki2 at gmail.com>
>
> API allows protocol implementations to provide API that
> allows to list directory content.
> API is similar to POSIX opendir/readdir/closedir.
> ---
> libavformat/avio.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/avio.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> libavformat/url.c | 16 +++++++++++
> libavformat/url.h | 10 +++++++
> 4 files changed, 183 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 4896782..51419cc 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -23,6 +23,7 @@
> #include "libavutil/dict.h"
> #include "libavutil/opt.h"
> #include "libavutil/time.h"
> +#include "libavutil/avassert.h"
> #include "os_support.h"
> #include "avformat.h"
> #if CONFIG_NETWORK
> @@ -418,6 +419,79 @@ int avio_check(const char *url, int flags)
> return ret;
> }
>
> +int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
> +{
> + URLContext *h = NULL;
> + AVIODirContext *ctx = NULL;
> + int ret;
> + av_assert0(s);
> +
> + ctx = av_mallocz(sizeof(*ctx));
> + if (!ctx) {
> + ret = AVERROR(ENOMEM);
> + goto fail;
> + }
> +
> + if ((ret = ffurl_alloc(&h, url, AVIO_FLAG_READ, NULL)) < 0)
> + goto fail;
> +
> + if (h->prot->url_open_dir && h->prot->url_read_dir && h->prot->url_close_dir) {
> + if (options && h->prot->priv_data_class &&
> + (ret = av_opt_set_dict(h->priv_data, options)) < 0)
> + goto fail;
> + ret = h->prot->url_open_dir(h);
> + } else
> + ret = AVERROR(ENOSYS);
> + if (ret < 0)
> + goto fail;
> +
> + ctx->url_context = h;
> + *s = ctx;
> + return 0;
> +
> + fail:
> + av_free(ctx);
> + *s = NULL;
> + ffurl_close(h);
> + return ret;
> +}
> +
> +int avio_read_dir(AVIODirContext *s, AVIODirEntry **next)
> +{
> + URLContext *h;
> + int ret;
> +
> + if (!s || !s->url_context)
> + return EINVAL;
i assume this is intended to be AVERROR(EINVAL)
> + h = s->url_context;
> + if ((ret = h->prot->url_read_dir(h, next)) < 0)
> + avio_free_directory_entry(next);
> + return ret;
> +}
> +
> +int avio_close_dir(AVIODirContext **s)
> +{
> + URLContext *h;
> +
> + av_assert0(s);
> + if (!(*s) || !(*s)->url_context)
> + return EINVAL;
same as previous
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150326/bef9ddd9/attachment.asc>
More information about the ffmpeg-devel
mailing list