[FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
Mariusz Szczepańczyk
mszczepanczyk at gmail.com
Thu Mar 26 15:31:27 CET 2015
On Thu, Mar 26, 2015 at 2:31 PM, Michael Niedermayer <michaelni at gmx.at>
wrote:
> 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)
>
Yes, of course! Fixed.
>
>
> > + 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
>
ditto
>
> [...]
>
Mariusz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavf-add-directory-listing-API.patch
Type: text/x-diff
Size: 8206 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150326/dce98efa/attachment.bin>
More information about the ffmpeg-devel
mailing list