summaryrefslogtreecommitdiff
path: root/libavformat/options.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-10-03 19:49:12 +0200
committerAnton Khirnov <anton@khirnov.net>2011-10-12 16:51:16 +0200
commit641c7afe3c17334b81e3e2eef88f1751eb68f89f (patch)
tree27ff55b88d052b7947b40a40834f80f0c2c99083 /libavformat/options.c
parent1bca8f4bc596d286dc50e572f5f8d52e4fc3a8dc (diff)
downloadffmpeg-641c7afe3c17334b81e3e2eef88f1751eb68f89f.tar.gz
AVOptions: add new API for enumerating children.
This will allow the caller to enumerate child contexts in a generic way and since the API is recursive, it also allows for deeper nesting (e.g. AVFormatContext->AVIOContext->URLContext) This will also allow the new setting/reading API to transparently apply to children contexts.
Diffstat (limited to 'libavformat/options.c')
-rw-r--r--libavformat/options.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/libavformat/options.c b/libavformat/options.c
index 43a6dec323..475166f3ce 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -33,30 +33,36 @@ static const char* format_to_name(void* ptr)
else return "NULL";
}
-static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
+static void *format_child_next(void *obj, void *prev)
+{
+ AVFormatContext *s = obj;
+ if (!prev && s->priv_data &&
+ ((s->iformat && s->iformat->priv_class) ||
+ s->oformat && s->oformat->priv_class))
+ return s->priv_data;
+ return NULL;
+}
+
+static const AVClass *format_child_class_next(const AVClass *prev)
{
- AVFormatContext *s = obj;
AVInputFormat *ifmt = NULL;
AVOutputFormat *ofmt = NULL;
- if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) {
- if ((s->iformat && !s->iformat->priv_class) ||
- (s->oformat && !s->oformat->priv_class))
- return NULL;
- return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);
- }
-
- while ((ifmt = av_iformat_next(ifmt))) {
- const AVOption *o;
-
- if (ifmt->priv_class && (o = av_opt_find(&ifmt->priv_class, name, unit, opt_flags, search_flags)))
- return o;
- }
- while ((ofmt = av_oformat_next(ofmt))) {
- const AVOption *o;
-
- if (ofmt->priv_class && (o = av_opt_find(&ofmt->priv_class, name, unit, opt_flags, search_flags)))
- return o;
- }
+
+ while (prev && (ifmt = av_iformat_next(ifmt)))
+ if (ifmt->priv_class == prev)
+ break;
+ if ((prev && ifmt) || (!prev))
+ while (ifmt = av_iformat_next(ifmt))
+ if (ifmt->priv_class)
+ return ifmt->priv_class;
+
+ while (prev && (ofmt = av_oformat_next(ofmt)))
+ if (ofmt->priv_class == prev)
+ break;
+ while (ofmt = av_oformat_next(ofmt))
+ if (ofmt->priv_class)
+ return ofmt->priv_class;
+
return NULL;
}
@@ -103,7 +109,8 @@ static const AVClass av_format_context_class = {
.item_name = format_to_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
- .opt_find = opt_find,
+ .child_next = format_child_next,
+ .child_class_next = format_child_class_next,
};
static void avformat_get_context_defaults(AVFormatContext *s)