From 35fd083828a57eb7ae995bd081dad88a8d64f75d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 8 Sep 2013 07:42:05 +0200 Subject: demux: retrieve per-chapter metadata Retrieve per-chapter metadata, but don't do much with it. We just make the metadata of the _current_ chapter available as chapter-metadata property. Returning the full chapter list with metadata would be no problem, except that the property interface isn't really good with structured data, so it's not available for now. Not sure if it's worth it, but it was requested via github issue #201. --- mpvcore/command.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/command.c b/mpvcore/command.c index d8642e40fa..d986ae1a64 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -694,6 +694,19 @@ static int mp_property_metadata(m_option_t *prop, int action, void *arg, return tag_property(prop, action, arg, demuxer->metadata); } +static int mp_property_chapter_metadata(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + struct demuxer *demuxer = mpctx->master_demuxer; + int chapter = get_current_chapter(mpctx); + if (!demuxer || chapter < 0) + return M_PROPERTY_UNAVAILABLE; + + assert(chapter < demuxer->num_chapters); + + return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata); +} + static int mp_property_pause(m_option_t *prop, int action, void *arg, void *ctx) { @@ -1741,8 +1754,8 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "editions", mp_property_editions, CONF_TYPE_INT }, { "angle", mp_property_angle, &m_option_type_dummy }, - { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST, - 0, 0, 0, NULL }, + { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST }, + { "chapter-metadata", mp_property_chapter_metadata, CONF_TYPE_STRING_LIST }, M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause), { "cache", mp_property_cache, CONF_TYPE_INT }, M_OPTION_PROPERTY("pts-association-mode"), -- cgit v1.2.3