From 9eb061a72b66702d394584fac371358050f7ad18 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Sun, 13 Apr 2014 07:08:58 -0700 Subject: command: add vf-metadata property This is a read-only property that uses VFCTRL_GET_METADATA to retrieve mp_tags metadata from a filter specified by label Signed-off-by: wm4 --- DOCS/man/en/input.rst | 13 ++++++++++++- player/command.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index f6a0f04833..d6e3affcad 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -731,7 +731,7 @@ Property list (key and string value for each metdata entry) ``chapter-metadata`` - Metadata of current chapter. Works similar to ``metadata`` property. IT + Metadata of current chapter. Works similar to ``metadata`` property. It also allows the same access methods (using sub-properties). Per-chapter metadata is very rare. Usually, only the chapter name @@ -740,6 +740,17 @@ Property list For accessing other information, like chapter start, see the ``chapter-list`` property. +``vf-metadata/`` + Metadata added by video filters. Accessed by the filter label, + which if not explicitly specified using the ``@filter-label:`` syntax, + will be ``NN``. + + Works similar to ``metadata`` property. It allows the same access + methods (using sub-properties). + + An example of these kind of metadata are the cropping parameters + added by ``--vf=lavfi=cropdetect``. + ``pause`` (RW) Pause status. This is usually ``yes`` or ``no``. See ``--pause``. diff --git a/player/command.c b/player/command.c index 8891fdd3f3..cc4cc0892a 100644 --- a/player/command.c +++ b/player/command.c @@ -617,7 +617,6 @@ static int mp_property_edition(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } - static int get_edition_entry(int item, int action, void *arg, void *ctx) { struct MPContext *mpctx = ctx; @@ -933,6 +932,42 @@ static int mp_property_chapter_metadata(m_option_t *prop, int action, void *arg, return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata); } +static int mp_property_vf_metadata(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + if (!(mpctx->d_video && mpctx->d_video->vfilter)) + return M_PROPERTY_UNAVAILABLE; + struct vf_chain *vf = mpctx->d_video->vfilter; + + switch(action) { + case M_PROPERTY_GET_TYPE: + case M_PROPERTY_GET: + case M_PROPERTY_GET_NODE: + return M_PROPERTY_NOT_IMPLEMENTED; + case 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; + if (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key) + == CONTROL_UNKNOWN) + return M_PROPERTY_UNKNOWN; + + if (strlen(rem)) { + struct m_property_action_arg next_ka = *ka; + next_ka.key = rem; + return tag_property(prop, M_PROPERTY_KEY_ACTION, &next_ka, + &vf_metadata); + } else { + return tag_property(prop, ka->action, ka->arg, &vf_metadata); + } + return M_PROPERTY_OK; + } + } + return M_PROPERTY_UNAVAILABLE; +} + static int mp_property_pause(m_option_t *prop, int action, void *arg, void *ctx) { @@ -2206,6 +2241,7 @@ static const m_option_t mp_properties[] = { { "angle", mp_property_angle, &m_option_type_dummy }, M_PROPERTY("metadata", mp_property_metadata), M_PROPERTY("chapter-metadata", mp_property_chapter_metadata), + M_PROPERTY( "vf-metadata", mp_property_vf_metadata), M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause), { "cache", mp_property_cache, CONF_TYPE_INT }, { "cache-size", mp_property_cache_size, CONF_TYPE_INT, M_OPT_MIN, 0 }, -- cgit v1.2.3