summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-08 07:42:05 +0200
committerwm4 <wm4@nowhere>2013-09-08 07:43:23 +0200
commit35fd083828a57eb7ae995bd081dad88a8d64f75d (patch)
treeb6f377dceee9ad4f888bb44d0842a00fc4ee3d04 /demux/demux.c
parentba07000b886802909a52810568705897d600263a (diff)
downloadmpv-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 'demux/demux.c')
-rw-r--r--demux/demux.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 8d84d4450c..c3635b9ab1 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -870,18 +870,33 @@ void demuxer_sort_chapters(demuxer_t *demuxer)
}
int demuxer_add_chapter(demuxer_t *demuxer, struct bstr name,
- uint64_t start, uint64_t end)
+ uint64_t start, uint64_t end, uint64_t demuxer_id)
{
struct demux_chapter new = {
.original_index = demuxer->num_chapters,
.start = start,
.end = end,
.name = name.len ? bstrdup0(demuxer, name) : NULL,
+ .metadata = talloc_zero(demuxer, struct mp_tags),
+ .demuxer_id = demuxer_id,
};
+ mp_tags_set_bstr(new.metadata, bstr0("title"), name);
MP_TARRAY_APPEND(demuxer, demuxer->chapters, demuxer->num_chapters, new);
return 0;
}
+void demuxer_add_chapter_info(struct demuxer *demuxer, uint64_t demuxer_id,
+ bstr key, bstr value)
+{
+ for (int n = 0; n < demuxer->num_chapters; n++) {
+ struct demux_chapter *ch = &demuxer->chapters[n];
+ if (ch->demuxer_id == demuxer_id) {
+ mp_tags_set_bstr(ch->metadata, key, value);
+ return;
+ }
+ }
+}
+
static void add_stream_chapters(struct demuxer *demuxer)
{
if (demuxer->num_chapters)
@@ -892,7 +907,7 @@ static void add_stream_chapters(struct demuxer *demuxer)
if (stream_control(demuxer->stream, STREAM_CTRL_GET_CHAPTER_TIME, &p)
!= STREAM_OK)
return;
- demuxer_add_chapter(demuxer, bstr0(""), p * 1e9, 0);
+ demuxer_add_chapter(demuxer, bstr0(""), p * 1e9, 0, 0);
}
}