[FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API

Michael Niedermayer michaelni at gmx.at
Mon Mar 30 02:58:48 CEST 2015


On Sun, Mar 29, 2015 at 01:14:54AM +0100, Mariusz Szczepańczyk wrote:
> On Fri, Mar 27, 2015 at 6:52 PM, Michael Niedermayer <michaelni at gmx.at>
> wrote:
> 
> > 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
> >
> 
> I'm attaching the patch but I'm not completely sure whether it's correct.
> Please check it.
> 
> 
> >
> > applied this one
> >
> > thanks
> >
> >
> Regards,
> Mariusz

>  doc/APIchanges        |    9 +++++++++
>  libavformat/version.h |    2 +-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 7830b83a5a5ae55f5f9189b0de95252c136499db  0001-lavf-Bump-minor-version-and-document-directory-listi.patch
> From 04da63e473b181d72dba909968ce28671ee5e5ea Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Mariusz=20Szczepa=C5=84czyk?= <mszczepanczyk at gmail.com>
> Date: Sun, 29 Mar 2015 00:54:46 +0100
> Subject: [PATCH] lavf: Bump minor version and document directory listing API
>  in doc/APIchanges.
> 
> ---
>  doc/APIchanges        | 9 +++++++++
>  libavformat/version.h | 2 +-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 3f153e9..814f752 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,15 @@ libavutil:     2014-08-09
>  
>  API changes, most recent first:
>  
> +2015-03-27 - 184084c - lavf 56.27.100 - avio.h url.h
> +  New directory listing API.
> +
> +  Add AVIODirEntryType enum.
> +  Add AVIODirEntry, AVIODirContext structures.
> +  Add avio_open_dir(), avio_read_dir(), avio_close_dir(), avio_free_directory_entry().
> +  Add ff_alloc_dir_entry().
> +  Extend URLProtocol with url_open_dir(), url_read_dir(), url_close_dir().
> +
>  -------- 8< --------- FFmpeg 2.6 was cut here -------- 8< ---------
>  
>  2015-03-04 - cca4476 - lavf 56.25.100
> diff --git a/libavformat/version.h b/libavformat/version.h
> index a183d7f..ff85227 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -30,7 +30,7 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVFORMAT_VERSION_MAJOR 56

> -#define LIBAVFORMAT_VERSION_MINOR  26
> +#define LIBAVFORMAT_VERSION_MINOR  27
>  #define LIBAVFORMAT_VERSION_MICRO 101

if you bump minor then micro needs to be reset to 100

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- 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/20150330/4c02248c/attachment.asc>


More information about the ffmpeg-devel mailing list