[FFmpeg-devel] [RFC] Browser remote content API

Michael Niedermayer michaelni at gmx.at
Sun Feb 16 12:28:34 CET 2014


On Sun, Feb 16, 2014 at 12:51:42AM +0100, Lukasz Marek wrote:
> On 10.02.2014 03:29, Michael Niedermayer wrote:
> >>>> >also i would suggest you design and implement the API without the
> >>>> >student to not complicate that further
> >>>
> >>>Not sure I understand.
> >>>You want a student to implement this at protocol level only (new
> >>>callback) and lavf would be prepared before?
> >it will take you less time to design and add the framework/API
> >without a student than with.
> >so why do it with one ?
> >
> >you know ffmpeg and the API, the student doesnt
> >
> >
> 
> I've attached implementation of my proposal API.
> 
> Second patch is just for testing purposes, but probably may be
> helpful for the student. Example may be also merged at some point
> when first protocol supports it.
> 
> -- 
> Best Regards,
> Lukasz Marek
> 
> When you look long into an abyss, the abyss looks into you. -
> Friedrich Nietzsche

>  avio.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  avio.h |   49 +++++++++++++++++++++++++++++++++++++++
>  url.h  |    1 
>  3 files changed, 130 insertions(+)
> 6cc952d48db502c0efe27b6ec7113543730e67f6  0001-lavf-avio-add-directory-list-API.patch
> From be932968c1ba2b9f4e34dd096f31df2ddba97249 Mon Sep 17 00:00:00 2001
> From: Lukasz Marek <lukasz.m.luki at gmail.com>
> Date: Sun, 16 Feb 2014 00:44:09 +0100
> Subject: [PATCH 1/2] lavf/avio: add directory list API
> 
> TODO: minor bump and APIchnage update.
> 
> This is preparation for GSoC project.
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> ---
>  libavformat/avio.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/avio.h | 49 +++++++++++++++++++++++++++++++++
>  libavformat/url.h  |  1 +
>  3 files changed, 130 insertions(+)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 225d982..1851654 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
> @@ -395,6 +396,85 @@ int avio_check(const char *url, int flags)
>      return ret;
>  }
>  
> +void avio_free_dir_list(AVIODirEntryList **entries)
> +{
> +    AVIODirEntryList *list;
> +    int i;
> +
> +    if (!entries || !(*entries))
> +        return;
> +    list = *entries;
> +    for (i = 0; i < list->nb_entries; i++) {
> +        if (list->enties[i]) {
> +            av_free(list->enties[i]->name);
> +            av_free(list->enties[i]);
> +        }
> +    }
> +    av_free(list->enties);
> +    av_freep(entries);
> +}
> +
> +static int cmp_dir_entires(AVIODirEntry *e1, AVIODirEntry *e2, int flags)
> +{
> +    int ret = flags & AVIO_SORT_DESCENDING;
> +    av_assert0(e1 && e2);
> +    if ((flags & AVIO_SORT_DIRS_FIRST) && e1->type != e2->type)
> +        return e1->type != AVIO_ENTRY_DIR;
> +    if (flags & AVIO_SORT_BY_SIZE) {
> +        if (e1->size != e2->size)
> +            return e1->size > e2->size ? ret : !ret;
> +    } else if (flags & AVIO_SORT_BY_CREATION_DATE) {
> +        if (e1->creation_timestamp != e2->creation_timestamp)
> +            return e1->creation_timestamp > e2->creation_timestamp ? ret : !ret;
> +    } else if (flags & AVIO_SORT_BY_MODIFICATION_DATE) {
> +        if (e1->modification_timestamp != e2->modification_timestamp)
> +            return e1->modification_timestamp > e2->modification_timestamp ? ret : !ret;
> +    }
> +    return strcmp(e1->name, e2->name) < 0 ? ret : !ret;
> +}
> +
> +int avio_list_dir(const char *url, AVIODirEntryList **entries, int sort_flags,
> +                  AVDictionary **options)
> +{
> +    int ret, i1, i2;
> +    URLContext *h;
> +    AVIODirEntryList *list;
> +
> +    av_assert0(entries);
> +    *entries = NULL;
> +    if ((ret = ffurl_alloc(&h, url, 0, NULL)))
> +        return ret;
> +    if (!h->prot->url_list_dir) {
> +        ret = AVERROR(ENOSYS);
> +        goto fail;
> +    }
> +    if (options && h->prot->priv_data_class &&
> +        (ret = av_opt_set_dict(h->priv_data, options)) < 0)
> +        goto fail;
> +
> +    list = av_mallocz(sizeof(**entries));
> +    if (!list) {
> +        ret = AVERROR(ENOMEM);
> +        goto fail;
> +    }
> +    *entries  = list;
> +    if ((ret = h->prot->url_list_dir(h, url, list)) < 0)
> +        goto fail;
> +
> +    for (i1 = 0; i1 < list->nb_entries - 1; i1++)
> +        for (i2 = i1 + 1; i2 < list->nb_entries; i2++) {
> +            if (cmp_dir_entires(list->enties[i1], list->enties[i2], sort_flags))
> +                FFSWAP(AVIODirEntry *, list->enties[i1], list->enties[i2]);
> +        }
> +
> +    ffurl_close(h);
> +    return 0;
> +  fail:
> +    ffurl_close(h);
> +    avio_free_dir_list(entries);
> +    return ret;
> +}
> +
>  int64_t ffurl_size(URLContext *h)
>  {
>      int64_t pos, size;
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 4f4ac3c..ff8ec22 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -53,6 +53,32 @@ typedef struct AVIOInterruptCB {
>      void *opaque;
>  } AVIOInterruptCB;
>  
> +enum AVIODirEntryType {
> +    AVIO_ENTRY_UNKNOWN,
> +    AVIO_ENTRY_DIR,
> +    AVIO_ENTRY_FILE
> +};


> +
> +/**
> + * Describes single entry of the directory.
> + */
> +typedef struct AVIODirEntry {
> +    char *name;                      /**< filename */
> +    enum AVIODirEntryType type;      /**< one of AVIO_ENTRY_* value */
> +    int64_t size;                    /**< file size */
> +    int64_t creation_timestamp;      /**< creation timestamp */
> +    int64_t modification_timestamp;  /**< modification timestamp */
> +} AVIODirEntry;

user, group, access rights, symbolic link destination

whats the encoding of name ? utf-8 ? undefined ?

some flag or tri-state field or other system that indicated if the
target matches filename case sensitively or not might be usefull too

[....]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140216/966cf12c/attachment.asc>


More information about the ffmpeg-devel mailing list