1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 05:22:23 +00:00

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.
This commit is contained in:
wm4 2015-02-17 23:49:38 +01:00
parent d7a4cb14ff
commit 082371a160
4 changed files with 25 additions and 11 deletions

View File

@ -813,7 +813,6 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src)
dst->attachments = src->attachments; dst->attachments = src->attachments;
dst->num_attachments = src->num_attachments; dst->num_attachments = src->num_attachments;
dst->matroska_data = src->matroska_data; dst->matroska_data = src->matroska_data;
dst->file_contents = src->file_contents;
dst->playlist = src->playlist; dst->playlist = src->playlist;
dst->seekable = src->seekable; dst->seekable = src->seekable;
dst->partially_seekable = src->partially_seekable; dst->partially_seekable = src->partially_seekable;

View File

@ -218,8 +218,6 @@ typedef struct demuxer {
int num_attachments; int num_attachments;
struct matroska_data matroska_data; 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 // If the file is a playlist file
struct playlist *playlist; struct playlist *playlist;

View File

@ -76,6 +76,10 @@ struct cue_track {
struct bstr title; struct bstr title;
}; };
struct priv {
bstr data;
};
static enum cue_command read_cmd(struct bstr *data, struct bstr *out_params) static enum cue_command read_cmd(struct bstr *data, struct bstr *out_params)
{ {
struct bstr line = bstr_strip_linebreaks(bstr_getline(*data, data)); 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) static void build_timeline(struct timeline *tl)
{ {
struct priv *p = tl->demuxer->priv;
void *ctx = talloc_new(NULL); void *ctx = talloc_new(NULL);
add_source(tl, tl->demuxer); add_source(tl, tl->demuxer);
struct bstr data = tl->demuxer->file_contents; struct bstr data = p->data;
data = skip_utf8_bom(data); data = skip_utf8_bom(data);
struct cue_track *tracks = NULL; 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)) if (d.len < 1 || !mp_probe_cue(d))
return -1; return -1;
} }
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000); struct priv *p = talloc_zero(demuxer, struct priv);
if (demuxer->file_contents.start == NULL) demuxer->priv = p;
p->data = stream_read_complete(s, demuxer, 1000000);
if (p->data.start == NULL)
return -1; return -1;
return 0; return 0;
} }

View File

@ -50,6 +50,10 @@ struct tl_parts {
int num_parts; int num_parts;
}; };
struct priv {
bstr data;
};
// Parse a time (absolute file time or duration). Currently equivalent to a // Parse a time (absolute file time or duration). Currently equivalent to a
// number. Return false on failure. // number. Return false on failure.
static bool parse_time(bstr str, double *out_time) 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) 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) { if (!parts) {
MP_ERR(tl, "Error in EDL.\n"); MP_ERR(tl, "Error in EDL.\n");
return; 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) 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; struct stream *s = demuxer->stream;
if (s->uncached_type == STREAMTYPE_EDL) { if (s->uncached_type == STREAMTYPE_EDL) {
demuxer->file_contents = bstr0(s->path); p->data = bstr0(s->path);
return 0; return 0;
} }
if (check >= DEMUX_CHECK_UNSAFE) { if (check >= DEMUX_CHECK_UNSAFE) {
if (!bstr_equals0(stream_peek(s, strlen(HEADER)), HEADER)) if (!bstr_equals0(stream_peek(s, strlen(HEADER)), HEADER))
return -1; return -1;
} }
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000); p->data = stream_read_complete(s, demuxer, 1000000);
if (demuxer->file_contents.start == NULL) if (p->data.start == NULL)
return -1; return -1;
bstr_eatstart0(&demuxer->file_contents, HEADER); bstr_eatstart0(&p->data, HEADER);
return 0; return 0;
} }