summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-11 23:04:02 +0200
committerwm4 <wm4@nowhere>2015-09-11 23:04:02 +0200
commit4e0e24c3c27362939d9f88d3e22267afef5f6d4f (patch)
tree5d8ad6f4a3ed84071b79e07df48e9bfc818db07f /player
parentf095e86b61022613371334d80552b918946b9387 (diff)
downloadmpv-4e0e24c3c27362939d9f88d3e22267afef5f6d4f.tar.bz2
mpv-4e0e24c3c27362939d9f88d3e22267afef5f6d4f.tar.xz
af_lavfi: implement af-metadata property
Works like vf-metadata. Unfortunately requires some code duplication (even though it's not much). Fixes #2311.
Diffstat (limited to 'player')
-rw-r--r--player/command.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/player/command.c b/player/command.c
index 19f725ba3a..6dcd200b29 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1187,21 +1187,31 @@ static int mp_property_chapter_metadata(void *ctx, struct m_property *prop,
return tag_property(action, arg, mpctx->chapters[chapter].metadata);
}
-static int mp_property_vf_metadata(void *ctx, struct m_property *prop,
- int action, void *arg)
+static int mp_property_filter_metadata(void *ctx, struct m_property *prop,
+ int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!(mpctx->d_video && mpctx->d_video->vfilter))
- return M_PROPERTY_UNAVAILABLE;
- struct vf_chain *vf = mpctx->d_video->vfilter;
+ const char *type = prop->priv;
if (action == M_PROPERTY_KEY_ACTION) {
struct m_property_action_arg *ka = arg;
bstr key;
char *rem;
m_property_split_path(ka->key, &key, &rem);
- struct mp_tags vf_metadata = {0};
- switch (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)) {
+ struct mp_tags metadata = {0};
+ int res = CONTROL_UNKNOWN;
+ if (strcmp(type, "vf") == 0) {
+ if (!(mpctx->d_video && mpctx->d_video->vfilter))
+ return M_PROPERTY_UNAVAILABLE;
+ struct vf_chain *vf = mpctx->d_video->vfilter;
+ res = vf_control_by_label(vf, VFCTRL_GET_METADATA, &metadata, key);
+ } else if (strcmp(type, "af") == 0) {
+ if (!(mpctx->d_audio && mpctx->d_audio->afilter))
+ return M_PROPERTY_UNAVAILABLE;
+ struct af_stream *af = mpctx->d_audio->afilter;
+ res = af_control_by_label(af, AF_CONTROL_GET_METADATA, &metadata, key);
+ }
+ switch (res) {
case CONTROL_UNKNOWN:
return M_PROPERTY_UNKNOWN;
case CONTROL_NA: // empty
@@ -1209,9 +1219,9 @@ static int mp_property_vf_metadata(void *ctx, struct m_property *prop,
if (strlen(rem)) {
struct m_property_action_arg next_ka = *ka;
next_ka.key = rem;
- return tag_property(M_PROPERTY_KEY_ACTION, &next_ka, &vf_metadata);
+ return tag_property(M_PROPERTY_KEY_ACTION, &next_ka, &metadata);
} else {
- return tag_property(ka->action, ka->arg, &vf_metadata);
+ return tag_property(ka->action, ka->arg, &metadata);
}
return M_PROPERTY_OK;
default:
@@ -3379,7 +3389,8 @@ static const struct m_property mp_properties[] = {
{"metadata", mp_property_metadata},
{"filtered-metadata", mp_property_filtered_metadata},
{"chapter-metadata", mp_property_chapter_metadata},
- {"vf-metadata", mp_property_vf_metadata},
+ {"vf-metadata", mp_property_filter_metadata, .priv = "vf"},
+ {"af-metadata", mp_property_filter_metadata, .priv = "af"},
{"pause", mp_property_pause},
{"core-idle", mp_property_core_idle},
{"eof-reached", mp_property_eof_reached},