aboutsummaryrefslogtreecommitdiffhomepage
path: root/demux
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-05-19 21:36:52 +0200
committerGravatar wm4 <wm4@nowhere>2015-05-19 21:36:52 +0200
commit4d2a01b776f6f5d7d5e2971115fad0a10824a1b9 (patch)
tree6591d81f22c31da8b1607729a7d24efb15c94f43 /demux
parent0ed1719e1a4a9215a45fd0281c09d4e3553b9be7 (diff)
demux: read cue sheets embedded in tags
This reads the "CUESHEET" tag, and attempts to parse it as .cue data. If any is found, the cue tracks are added as chapters. This reuses the parser written for demux_cue.c. Fixes #1957.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c
index bb367055cb..b99d0263c9 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -37,8 +37,7 @@
#include "stream/stream.h"
#include "demux.h"
#include "stheader.h"
-
-#include "audio/format.h"
+#include "cue.h"
// Demuxer list
extern const struct demuxer_desc demuxer_desc_edl;
@@ -902,6 +901,21 @@ static void demux_init_cache(struct demuxer *demuxer)
in->stream_base_filename = talloc_steal(demuxer, base);
}
+static void demux_init_cuesheet(struct demuxer *demuxer)
+{
+ char *cue = mp_tags_get_str(demuxer->metadata, "cuesheet");
+ if (cue && !demuxer->num_chapters) {
+ struct cue_file *f = mp_parse_cue(bstr0(cue));
+ if (f) {
+ for (int n = 0; n < f->num_tracks; n++) {
+ struct cue_track *t = &f->tracks[n];
+ demuxer_add_chapter(demuxer, t->title, t->start, -1);
+ }
+ }
+ talloc_free(f);
+ }
+}
+
static struct demuxer *open_given_type(struct mpv_global *global,
struct mp_log *log,
const struct demuxer_desc *desc,
@@ -977,6 +991,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
in->d_thread->seekable = true;
in->d_thread->partially_seekable = true;
}
+ demux_init_cuesheet(in->d_thread);
demux_init_cache(demuxer);
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
demux_update(demuxer);