mirror of https://github.com/mpv-player/mpv
demux: remove file_contents field
Only demux_cue and demux_edl used it. It's a weird field and doesn't
help with anything anymore - by now, it only saves a priv context in the
mentioned demuxers. Reducing the number of confusing things the demuxer
struct has is more important than minimizing the code.
(cherry picked from commit 082371a160
)
This commit is contained in:
parent
3be989dcd0
commit
7ea82eb7bc
|
@ -755,7 +755,6 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src)
|
|||
dst->attachments = src->attachments;
|
||||
dst->num_attachments = src->num_attachments;
|
||||
dst->matroska_data = src->matroska_data;
|
||||
dst->file_contents = src->file_contents;
|
||||
dst->playlist = src->playlist;
|
||||
dst->seekable = src->seekable;
|
||||
dst->partially_seekable = src->partially_seekable;
|
||||
|
|
|
@ -212,8 +212,6 @@ typedef struct demuxer {
|
|||
int num_attachments;
|
||||
|
||||
struct matroska_data matroska_data;
|
||||
// for trivial demuxers which just read the whole file for codec to use
|
||||
struct bstr file_contents;
|
||||
|
||||
// If the file is a playlist file
|
||||
struct playlist *playlist;
|
||||
|
|
|
@ -76,6 +76,10 @@ struct cue_track {
|
|||
struct bstr title;
|
||||
};
|
||||
|
||||
struct priv {
|
||||
bstr data;
|
||||
};
|
||||
|
||||
static enum cue_command read_cmd(struct bstr *data, struct bstr *out_params)
|
||||
{
|
||||
struct bstr line = bstr_strip_linebreaks(bstr_getline(*data, data));
|
||||
|
@ -279,11 +283,13 @@ static double source_get_length(struct demuxer *demuxer)
|
|||
|
||||
static void build_timeline(struct timeline *tl)
|
||||
{
|
||||
struct priv *p = tl->demuxer->priv;
|
||||
|
||||
void *ctx = talloc_new(NULL);
|
||||
|
||||
add_source(tl, tl->demuxer);
|
||||
|
||||
struct bstr data = tl->demuxer->file_contents;
|
||||
struct bstr data = p->data;
|
||||
data = skip_utf8_bom(data);
|
||||
|
||||
struct cue_track *tracks = NULL;
|
||||
|
@ -425,8 +431,10 @@ static int try_open_file(struct demuxer *demuxer, enum demux_check check)
|
|||
if (d.len < 1 || !mp_probe_cue(d))
|
||||
return -1;
|
||||
}
|
||||
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000);
|
||||
if (demuxer->file_contents.start == NULL)
|
||||
struct priv *p = talloc_zero(demuxer, struct priv);
|
||||
demuxer->priv = p;
|
||||
p->data = stream_read_complete(s, demuxer, 1000000);
|
||||
if (p->data.start == NULL)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ struct tl_parts {
|
|||
int num_parts;
|
||||
};
|
||||
|
||||
struct priv {
|
||||
bstr data;
|
||||
};
|
||||
|
||||
// Parse a time (absolute file time or duration). Currently equivalent to a
|
||||
// number. Return false on failure.
|
||||
static bool parse_time(bstr str, double *out_time)
|
||||
|
@ -288,7 +292,9 @@ static void fix_filenames(struct tl_parts *parts, char *source_path)
|
|||
|
||||
static void build_mpv_edl_timeline(struct timeline *tl)
|
||||
{
|
||||
struct tl_parts *parts = parse_edl(tl->demuxer->file_contents);
|
||||
struct priv *p = tl->demuxer->priv;
|
||||
|
||||
struct tl_parts *parts = parse_edl(p->data);
|
||||
if (!parts) {
|
||||
MP_ERR(tl, "Error in EDL.\n");
|
||||
return;
|
||||
|
@ -303,19 +309,22 @@ static void build_mpv_edl_timeline(struct timeline *tl)
|
|||
|
||||
static int try_open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
{
|
||||
struct priv *p = talloc_zero(demuxer, struct priv);
|
||||
demuxer->priv = p;
|
||||
|
||||
struct stream *s = demuxer->stream;
|
||||
if (s->uncached_type == STREAMTYPE_EDL) {
|
||||
demuxer->file_contents = bstr0(s->path);
|
||||
p->data = bstr0(s->path);
|
||||
return 0;
|
||||
}
|
||||
if (check >= DEMUX_CHECK_UNSAFE) {
|
||||
if (!bstr_equals0(stream_peek(s, strlen(HEADER)), HEADER))
|
||||
return -1;
|
||||
}
|
||||
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000);
|
||||
if (demuxer->file_contents.start == NULL)
|
||||
p->data = stream_read_complete(s, demuxer, 1000000);
|
||||
if (p->data.start == NULL)
|
||||
return -1;
|
||||
bstr_eatstart0(&demuxer->file_contents, HEADER);
|
||||
bstr_eatstart0(&p->data, HEADER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue