summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-08 06:32:48 +0200
committerwm4 <wm4@nowhere>2013-09-08 06:32:48 +0200
commitba07000b886802909a52810568705897d600263a (patch)
tree5ea7bded083ba092999466b36985307f6a25d8a3 /mpvcore
parent1aae5981a7165f5236a9f3a1518ab2b6f7c7eae9 (diff)
downloadmpv-ba07000b886802909a52810568705897d600263a.tar.bz2
mpv-ba07000b886802909a52810568705897d600263a.tar.xz
demux: refactor tag handling
Make the code somewhat reuseable, instead of bound to a single demuxer instance. The plan is to add support for per-chapter tags later.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index f7bed60713..d8642e40fa 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -636,39 +636,38 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-/// Demuxer meta data
-static int mp_property_metadata(m_option_t *prop, int action, void *arg,
- MPContext *mpctx)
+static int tag_property(m_option_t *prop, int action, void *arg,
+ struct mp_tags *tags)
{
- struct demuxer *demuxer = mpctx->master_demuxer;
- if (!demuxer)
- return M_PROPERTY_UNAVAILABLE;
-
static const m_option_t key_type =
{
- "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL
+ "tags", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL
};
switch (action) {
case M_PROPERTY_GET: {
char **slist = NULL;
- m_option_copy(prop, &slist, &demuxer->info);
+ int num = 0;
+ for (int n = 0; n < tags->num_keys; n++) {
+ MP_TARRAY_APPEND(NULL, slist, num, tags->keys[n]);
+ MP_TARRAY_APPEND(NULL, slist, num, tags->values[n]);
+ }
+ MP_TARRAY_APPEND(NULL, slist, num, NULL);
*(char ***)arg = slist;
return M_PROPERTY_OK;
}
case M_PROPERTY_PRINT: {
- char **list = demuxer->info;
char *res = NULL;
- for (int n = 0; list && list[n]; n += 2) {
+ for (int n = 0; n < tags->num_keys; n++) {
res = talloc_asprintf_append_buffer(res, "%s: %s\n",
- list[n], list[n + 1]);
+ tags->keys[n], tags->values[n]);
}
*(char **)arg = res;
return res ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
}
case M_PROPERTY_KEY_ACTION: {
struct m_property_action_arg *ka = arg;
- char *meta = demux_info_get(demuxer, ka->key);
+ char *meta = mp_tags_get_str(tags, ka->key);
if (!meta)
return M_PROPERTY_UNKNOWN;
switch (ka->action) {
@@ -684,6 +683,17 @@ static int mp_property_metadata(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+/// Demuxer meta data
+static int mp_property_metadata(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ struct demuxer *demuxer = mpctx->master_demuxer;
+ if (!demuxer)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return tag_property(prop, action, arg, demuxer->metadata);
+}
+
static int mp_property_pause(m_option_t *prop, int action, void *arg,
void *ctx)
{