summaryrefslogtreecommitdiffstats
path: root/demux/timeline.c
diff options
context:
space:
mode:
Diffstat (limited to 'demux/timeline.c')
-rw-r--r--demux/timeline.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/demux/timeline.c b/demux/timeline.c
new file mode 100644
index 0000000000..6274c25fa3
--- /dev/null
+++ b/demux/timeline.c
@@ -0,0 +1,42 @@
+#include "common/common.h"
+#include "stream/stream.h"
+#include "demux.h"
+
+#include "timeline.h"
+
+struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log,
+ struct demuxer *demuxer)
+{
+ if (!demuxer->desc->load_timeline)
+ return NULL;
+
+ struct timeline *tl = talloc_ptrtype(NULL, tl);
+ *tl = (struct timeline){
+ .global = global,
+ .log = log,
+ .demuxer = demuxer,
+ .track_layout = demuxer,
+ };
+
+ demuxer->desc->load_timeline(tl);
+
+ if (tl->num_parts)
+ return tl;
+ timeline_destroy(tl);
+ return NULL;
+}
+
+void timeline_destroy(struct timeline *tl)
+{
+ if (!tl)
+ return;
+ for (int n = 0; n < tl->num_sources; n++) {
+ struct demuxer *d = tl->sources[n];
+ if (d != tl->demuxer) {
+ struct stream *s = d->stream;
+ free_demuxer(d);
+ free_stream(s);
+ }
+ }
+ talloc_free(tl);
+}