summaryrefslogtreecommitdiffstats
path: root/demux/demux_edl.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_edl.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_edl.c')
-rw-r--r--demux/demux_edl.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/demux/demux_edl.c b/demux/demux_edl.c
index e71c1dfd99..f72aeb2c03 100644
--- a/demux/demux_edl.c
+++ b/demux/demux_edl.c
@@ -50,7 +50,8 @@ struct tl_parts {
bool disable_chapters;
bool dash, no_clip, delay_open;
char *init_fragment_url;
- struct sh_stream *sh_meta;
+ struct sh_stream **sh_meta;
+ int num_sh_meta;
struct tl_part *parts;
int num_parts;
struct tl_parts *next;
@@ -145,12 +146,22 @@ static bool get_param_time(struct parse_ctx *ctx, const char *name, double *t)
static struct tl_parts *add_part(struct tl_root *root)
{
struct tl_parts *tl = talloc_zero(root, struct tl_parts);
- tl->sh_meta = demux_alloc_sh_stream(STREAM_TYPE_COUNT);
- talloc_steal(tl, tl->sh_meta);
MP_TARRAY_APPEND(root, root->pars, root->num_pars, tl);
return tl;
}
+static struct sh_stream *get_meta(struct tl_parts *tl, int index)
+{
+ for (int n = 0; n < tl->num_sh_meta; n++) {
+ if (tl->sh_meta[n]->index == index)
+ return tl->sh_meta[n];
+ }
+ struct sh_stream *sh = demux_alloc_sh_stream(STREAM_TYPE_COUNT);
+ talloc_steal(tl, sh);
+ MP_TARRAY_APPEND(tl, tl->sh_meta, tl->num_sh_meta, sh);
+ return sh;
+}
+
/* Returns a list of parts, or NULL on parse error.
* Syntax (without file header or URI prefix):
* url ::= <entry> ( (';' | '\n') <entry> )*
@@ -223,12 +234,15 @@ static struct tl_root *parse_edl(bstr str, struct mp_log *log)
} else if (bstr_equals0(f_type, "no_chapters")) {
tl->disable_chapters = true;
} else if (bstr_equals0(f_type, "track_meta")) {
- struct sh_stream *sh = tl->sh_meta;
+ int index = get_param_int(&ctx, "index", -1);
+ struct sh_stream *sh = index < 0 && tl->num_sh_meta
+ ? tl->sh_meta[tl->num_sh_meta - 1]
+ : get_meta(tl, index);
sh->lang = get_param0(&ctx, sh, "lang");
sh->title = get_param0(&ctx, sh, "title");
sh->hls_bitrate = get_param_int(&ctx, "byterate", 0) * 8;
} else if (bstr_equals0(f_type, "delay_open")) {
- struct sh_stream *sh = tl->sh_meta;
+ struct sh_stream *sh = get_meta(tl, tl->num_sh_meta);
bstr mt = get_param(&ctx, "media_type");
if (bstr_equals0(mt, "video")) {
sh->type = sh->codec->type = STREAM_VIDEO;
@@ -371,8 +385,12 @@ static struct timeline_par *build_timeline(struct timeline *root,
tl->delay_open = parts->delay_open;
// There is no copy function for sh_stream, so just steal it.
- tl->sh_meta = talloc_steal(tl, parts->sh_meta);
- parts->sh_meta = NULL;
+ for (int n = 0; n < parts->num_sh_meta; n++) {
+ MP_TARRAY_APPEND(tl, tl->sh_meta, tl->num_sh_meta,
+ talloc_steal(tl, parts->sh_meta[n]));
+ parts->sh_meta[n] = NULL;
+ }
+ parts->num_sh_meta = 0;
if (parts->init_fragment_url && parts->init_fragment_url[0]) {
MP_VERBOSE(root, "Opening init fragment...\n");