summaryrefslogtreecommitdiffstats
path: root/demux/demux_timeline.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-21 00:19:17 +0100
committerwm4 <wm4@nowhere>2020-02-21 00:19:17 +0100
commit6f0297dff497f219d6da3e09ecfe0fd545825d9c (patch)
treedb73f7bce99c45c33348e16905a97e48680f0417 /demux/demux_timeline.c
parent6726b7a1ba5248e4edcab3dbd24c730551afb012 (diff)
downloadmpv-6f0297dff497f219d6da3e09ecfe0fd545825d9c.tar.bz2
mpv-6f0297dff497f219d6da3e09ecfe0fd545825d9c.tar.xz
edl: make it possible to delay-load files with multiple tracks
Until now, delay-loading was for files with single tracks only (basically what DASH and HLS like to expose, so adaptive streaming and codec selection becomes easier - for sites, not for us). But they also provide some interleaved versions, probably for compatibility. Until now, we were forced to eagerly load it (making startup slightly slower). But there is not much missing. We just need a way to provide multiple metadata entries, and use them to represent each track. A side effect is now that the "track_meta" header can be used for normal EDL files too.
Diffstat (limited to 'demux/demux_timeline.c')
-rw-r--r--demux/demux_timeline.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c
index ab6d29b538..eb923d92e4 100644
--- a/demux/demux_timeline.c
+++ b/demux/demux_timeline.c
@@ -528,6 +528,17 @@ static void apply_meta(struct sh_stream *dst, struct sh_stream *src)
dst->attached_picture = src->attached_picture;
}
+// This is mostly for EDL user-defined metadata.
+static struct sh_stream *find_matching_meta(struct timeline_par *tl, int index)
+{
+ for (int n = 0; n < tl->num_sh_meta; n++) {
+ struct sh_stream *sh = tl->sh_meta[n];
+ if (sh->index == index || sh->index < 0)
+ return sh;
+ }
+ return NULL;
+}
+
static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl)
{
struct priv *p = demuxer->priv;
@@ -553,7 +564,7 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl)
// delay_open streams normally have meta==NULL, and 1 virtual stream
int num_streams = 0;
if (tl->delay_open) {
- num_streams = 1;
+ num_streams = tl->num_sh_meta;
} else if (meta) {
num_streams = demux_get_num_stream(meta);
}
@@ -561,9 +572,10 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl)
struct sh_stream *new = NULL;
if (tl->delay_open) {
- assert(tl->sh_meta);
- new = demux_alloc_sh_stream(tl->sh_meta->type);
- new->codec = tl->sh_meta->codec;
+ struct sh_stream *tsh = tl->sh_meta[n];
+ new = demux_alloc_sh_stream(tsh->type);
+ new->codec = tsh->codec;
+ apply_meta(new, tsh);
demuxer->is_network = true;
demuxer->is_streaming = true;
} else {
@@ -571,11 +583,11 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl)
new = demux_alloc_sh_stream(sh->type);
apply_meta(new, sh);
new->codec = sh->codec;
+ struct sh_stream *tsh = find_matching_meta(tl, n);
+ if (tsh)
+ apply_meta(new, tsh);
}
- if (tl->sh_meta)
- apply_meta(new, tl->sh_meta);
-
demux_add_sh_stream(demuxer, new);
struct virtual_stream *vs = talloc_ptrtype(p, vs);
*vs = (struct virtual_stream){