Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On 30.03.2015 03:01, Michael Niedermayer wrote: On Mon, Mar 30, 2015 at 12:36:34AM +0200, Lukasz Marek wrote: On 29.03.2015 01:14, Mariusz Szczepańczyk wrote: 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(). It can be simple add url_open_dir()..., but it is OK I think + 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 Michaels, do you gonna merge it? this one still had a minor issue in the version number but if the next looks fine to you or you want to correct it yourself dont hesitate to apply it Fixed locally and pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On Mon, Mar 30, 2015 at 12:36:34AM +0200, Lukasz Marek wrote: On 29.03.2015 01:14, Mariusz Szczepańczyk wrote: 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(). It can be simple add url_open_dir()..., but it is OK I think + 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 Michaels, do you gonna merge it? this one still had a minor issue in the version number but if the next looks fine to you or you want to correct it yourself dont hesitate to apply it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 3 Rare item - Common item with rare defect or maybe just a lie Professional - 'Toy' made in china, not functional except as doorstop Experts will know - The seller hopes you are not an expert signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
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 michae...@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 michae...@gmx.at wrote: On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote: From: Lukasz Marek lukasz.m.lu...@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.lu...@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?= mszczepanc...@gmail.com Date: Sun, 29 Mar 2015 00:54:46 +0100
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On 29.03.2015 01:14, Mariusz Szczepańczyk wrote: 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(). It can be simple add url_open_dir()..., but it is OK I think + 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 Michaels, do you gonna merge it? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On Fri, Mar 27, 2015 at 6:52 PM, Michael Niedermayer michae...@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 michae...@gmx.at wrote: On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote: From: Lukasz Marek lukasz.m.lu...@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.lu...@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 From 04da63e473b181d72dba909968ce28671ee5e5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Szczepa=C5=84czyk?= mszczepanc...@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 +
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
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 michae...@gmx.at wrote: On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote: From: Lukasz Marek lukasz.m.lu...@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.lu...@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 signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote: From: Lukasz Marek lukasz.m.lu...@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 signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On Thu, Mar 26, 2015 at 2:31 PM, Michael Niedermayer michae...@gmx.at wrote: On Thu, Mar 26, 2015 at 01:25:17AM +0100, Mariusz Szczepańczyk wrote: From: Lukasz Marek lukasz.m.lu...@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 From 628fa295d2710da56ba672ac0cb8502cafc27f82 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@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(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 4896782..a990ea2 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 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 AVERROR(EINVAL); +h = (*s)-url_context; +
[FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
From: Lukasz Marek lukasz.m.lu...@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; +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; +h = (*s)-url_context; +h-prot-url_close_dir(h); +ffurl_close(h); +av_freep(s); +*s = NULL; +return 0; +} + +void avio_free_directory_entry(AVIODirEntry **entry) +{ +if (!entry || !*entry) +return; +av_free((*entry)-name); +av_freep(entry); +} + int64_t ffurl_size(URLContext *h) { int64_t pos, size; diff --git a/libavformat/avio.h b/libavformat/avio.h index 8fc7e27..bbd482a 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -34,7 +34,6 @@ #include libavformat/version.h - #define AVIO_SEEKABLE_NORMAL 0x0001 /** Seeking works like for a local file */ /** @@ -54,6 +53,47 @@ typedef struct AVIOInterruptCB { } AVIOInterruptCB; /** + * Directory entry types. + */ +enum AVIODirEntryType { +AVIO_ENTRY_UNKNOWN, +AVIO_ENTRY_BLOCK_DEVICE, +AVIO_ENTRY_CHARACTER_DEVICE, +AVIO_ENTRY_DIRECTORY, +AVIO_ENTRY_NAMED_PIPE, +AVIO_ENTRY_SYMBOLIC_LINK, +AVIO_ENTRY_SOCKET, +AVIO_ENTRY_FILE +}; + +/** + * Describes single entry of the directory. + * + * Only name and type fields are guaranteed be set. + * Rest of fields are protocol or/and platform dependent and might be unknown. + */ +typedef struct AVIODirEntry { +char *name; /** Filename */ +int type; /** Type of the entry */ +int utf8; /** Set to 1 when name is encoded with UTF-8, 0 otherwise. + Name can be encoded with UTF-8 eventhough 0 is set. */ +int64_t size; /** File size in bytes, -1 if unknown. */ +int64_t modification_timestamp; /** Time of last modification in microseconds since unix + epoch, -1 if unknown. */ +int64_t access_timestamp; /** Time of last access in microseconds since unix epoch, + -1 if unknown. */ +int64_t status_change_timestamp; /** Time of last status change in microseconds since unix + epoch, -1 if unknown. */ +int64_t user_id; /** User ID of owner, -1 if unknown. */ +int64_t group_id; /** Group ID of owner, -1 if unknown. */ +int64_t filemode; /** Unix file mode, -1 if unknown. */ +} AVIODirEntry; + +typedef struct AVIODirContext { +struct URLContext *url_context; +} AVIODirContext; + +/** * Bytestream IO Context. * New fields can be added to the end with minor version bumps. * Removal, reordering and changes to existing fields require a major @@ -181,6 +221,48 @@ const char *avio_find_protocol_name(const char *url); int avio_check(const char *url, int flags); /** + * Open directory for
Re: [FFmpeg-devel] [PATCH 1/4] lavf: add directory listing API
On 15.07.2014 14:54, Nicolas George wrote: Le quartidi 24 messidor, an CCXXII, Lukasz Marek a écrit : TODO: bump minor, update doc/APIchanges API allows protocol implementations to provide API that allows to list directory content. API is similar to POSIX opendir/readdir/closedir. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- libavformat/avio.c | 76 +- libavformat/avio.h | 88 +- libavformat/url.h | 55 ++ 3 files changed, 217 insertions(+), 2 deletions(-) Hi, Thanks all for good review given, but for the time being I drop this patchset. Some operation as rename, delete, move would also be good, but this is probably more than the scope of ffmpeg, so I decide to move it to player layer. If you give some rationale to continue, I will finish tho. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel