[FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
Michael Niedermayer
michaelni at gmx.at
Fri Mar 27 18:52:59 CET 2015
On Thu, Mar 26, 2015 at 03:31:27PM +0100, Mariusz Szczepańczyk wrote:
> 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
> avio.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> avio.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> url.c | 16 ++++++++++++
> url.h | 10 +++++++
> 4 files changed, 183 insertions(+), 1 deletion(-)
> 0289391026b4d7c3d698b7b47bd18045e9f14460 0001-lavf-add-directory-listing-API.patch
> From 628fa295d2710da56ba672ac0cb8502cafc27f82 Mon Sep 17 00:00:00 2001
> From: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> Date: Sat, 5 Jul 2014 18:11:59 +0200
> Subject: [PATCH 1/4] lavf: add directory listing API
>
> 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(-)
theres no update to version.h and APIChanges but i think its
actually good to wait with these a few days so if more comments
come in we could still change the API
but please add a patch that updates them
applied this one
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- 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/20150327/b2b8496e/attachment.asc>
More information about the ffmpeg-devel
mailing list