From 97ab40290eaf5d5f2c97a7a7c6678cdee2283e79 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 29 Dec 2014 23:03:39 +0100 Subject: command: add filtered-metadata property Goes in hand with the previous commit; the main purpose is to easily show on OSD what is shown on terminal. --- DOCS/man/input.rst | 4 ++++ player/command.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index eee6beaf78..aed7251aca 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -903,6 +903,10 @@ Property list MPV_FORMAT_NODE_MAP (key and string value for each metadata entry) +``filtered-metadata`` + Like ``metadata``, but includes only fields listed in the ``--display-tags`` + option. This is the same set of tags that is printed to the terminal. + ``chapter-metadata`` Metadata of current chapter. Works similar to ``metadata`` property. It also allows the same access methods (using sub-properties). diff --git a/player/command.c b/player/command.c index 4e5fdc6509..97b890af5c 100644 --- a/player/command.c +++ b/player/command.c @@ -1122,6 +1122,16 @@ static int mp_property_metadata(void *ctx, struct m_property *prop, return tag_property(action, arg, demuxer->metadata); } +static int mp_property_filtered_metadata(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + if (!mpctx->filtered_tags) + return M_PROPERTY_UNAVAILABLE; + + return tag_property(action, arg, mpctx->filtered_tags); +} + static int mp_property_chapter_metadata(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3246,6 +3256,7 @@ static const struct m_property mp_properties[] = { {"editions", mp_property_editions}, {"angle", mp_property_angle}, {"metadata", mp_property_metadata}, + {"filtered-metadata", mp_property_filtered_metadata}, {"chapter-metadata", mp_property_chapter_metadata}, {"vf-metadata", mp_property_vf_metadata}, {"pause", mp_property_pause}, @@ -3429,7 +3440,7 @@ static const char *const *const mp_event_property_change[] = { "samplerate", "channels", "audio"), E(MPV_EVENT_SEEK, "seeking"), E(MPV_EVENT_PLAYBACK_RESTART, "seeking"), - E(MPV_EVENT_METADATA_UPDATE, "metadata"), + E(MPV_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata"), E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"), E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle", "demuxer-cache-duration", "demuxer-cache-idle"), -- cgit v1.2.3