diff options
author | wm4 <wm4@nowhere> | 2013-09-08 07:42:05 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-09-08 07:43:23 +0200 |
commit | 35fd083828a57eb7ae995bd081dad88a8d64f75d (patch) | |
tree | b6f377dceee9ad4f888bb44d0842a00fc4ee3d04 /mpvcore | |
parent | ba07000b886802909a52810568705897d600263a (diff) | |
download | mpv-35fd083828a57eb7ae995bd081dad88a8d64f75d.tar.bz2 mpv-35fd083828a57eb7ae995bd081dad88a8d64f75d.tar.xz |
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.
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/command.c | 17 |
1 files changed, 15 insertions, 2 deletions
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"), |