1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

demux: simplify demux_open() calls

The demux_open as well as demux_open_withparams calls don't use the
stream selection parameters anymore, so remove them everywhere.
Completes the previous commit.
This commit is contained in:
wm4 2013-07-08 01:37:30 +02:00
parent 05ae5afd62
commit 73c76de91e
6 changed files with 15 additions and 47 deletions

View File

@ -3890,20 +3890,12 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
stream_enable_cache_percent(&stream, stream_cache,
opts->stream_cache_min_percent,
opts->stream_cache_seek_min_percent);
// deal with broken demuxers: preselect streams
int vs = -2, as = -2, ss = -2;
switch (filter) {
case STREAM_VIDEO: vs = -1; break;
case STREAM_AUDIO: as = -1; break;
case STREAM_SUB: ss = -1; break;
}
vs = -1; // avi can't go without video
struct demuxer_params params = {
.ass_library = mpctx->ass_library, // demux_libass requires it
};
struct demuxer *demuxer =
demux_open_withparams(&mpctx->opts, stream, format, demuxer_name,
as, vs, ss, filename, &params);
filename, &params);
if (!demuxer) {
free_stream(stream);
goto err_out;
@ -4219,7 +4211,6 @@ goto_reopen_demuxer: ;
mpctx->audio_delay = opts->audio_delay;
mpctx->demuxer = demux_open(opts, mpctx->stream, file_format,
opts->audio_id, opts->video_id, opts->sub_id,
mpctx->filename);
mpctx->master_demuxer = mpctx->demuxer;

View File

@ -192,11 +192,7 @@ static bool try_open(struct MPContext *mpctx, char *filename)
struct stream *s = open_stream(filename, &mpctx->opts, &format);
if (!s)
return false;
struct demuxer *d = demux_open(&mpctx->opts, s, format,
mpctx->opts.audio_id,
mpctx->opts.video_id,
mpctx->opts.sub_id,
filename);
struct demuxer *d = demux_open(&mpctx->opts, s, format, filename);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
@ -205,11 +201,7 @@ static bool try_open(struct MPContext *mpctx, char *filename)
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n");
d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO,
mpctx->opts.audio_id,
mpctx->opts.video_id,
mpctx->opts.sub_id,
filename);
d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO, filename);
}
if (d) {
add_source(mpctx, d);

View File

@ -360,9 +360,6 @@ void build_edl_timeline(struct MPContext *mpctx)
if (!s)
goto openfail;
struct demuxer *d = demux_open(&mpctx->opts, s, format,
mpctx->opts.audio_id,
mpctx->opts.video_id,
mpctx->opts.sub_id,
edl_ids[i].filename);
if (!d) {
free_stream(s);

View File

@ -117,8 +117,7 @@ static struct demuxer *open_demuxer(struct stream *stream,
struct MPContext *mpctx, char *filename, struct demuxer_params *params)
{
return demux_open_withparams(&mpctx->opts, stream,
DEMUXER_TYPE_MATROSKA, NULL, mpctx->opts.audio_id,
mpctx->opts.video_id, mpctx->opts.sub_id, filename, params);
DEMUXER_TYPE_MATROSKA, NULL, filename, params);
}
static int enable_cache(struct MPContext *mpctx, struct stream **stream,

View File

@ -236,7 +236,7 @@ static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format)
static demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
int a_id, int v_id, int s_id, char *filename)
char *filename)
{
struct demuxer *d = talloc_zero(NULL, struct demuxer);
d->stream = stream;
@ -687,15 +687,13 @@ static int get_demuxer_type_from_name(char *demuxer_name, int *force)
static struct demuxer *open_given_type(struct MPOpts *opts,
const struct demuxer_desc *desc,
struct stream *stream, bool force,
int audio_id, int video_id, int sub_id,
char *filename,
struct demuxer_params *params)
{
struct demuxer *demuxer;
int fformat;
mp_msg(MSGT_DEMUXER, MSGL_V, "Trying demuxer: %s\n", desc->name);
demuxer = new_demuxer(opts, stream, desc->type, audio_id,
video_id, sub_id, filename);
demuxer = new_demuxer(opts, stream, desc->type, filename);
demuxer->params = params;
if (desc->check_file)
fformat = desc->check_file(demuxer);
@ -748,8 +746,7 @@ static struct demuxer *open_given_type(struct MPOpts *opts,
"BUG: recursion to nonexistent file format\n");
return NULL;
}
return open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
return open_given_type(opts, desc, stream, false, filename, params);
}
fail:
free_demuxer(demuxer);
@ -758,8 +755,7 @@ static struct demuxer *open_given_type(struct MPOpts *opts,
struct demuxer *demux_open_withparams(struct MPOpts *opts,
struct stream *stream, int file_format,
char *force_format, int audio_id,
int video_id, int sub_id, char *filename,
char *force_format, char *filename,
struct demuxer_params *params)
{
struct demuxer *demuxer = NULL;
@ -781,15 +777,13 @@ struct demuxer *demux_open_withparams(struct MPOpts *opts,
if (!desc)
// should only happen with obsolete -demuxer 99 numeric format
return NULL;
return open_given_type(opts, desc, stream, force, audio_id,
video_id, sub_id, filename, params);
return open_given_type(opts, desc, stream, force, filename, params);
}
// Test demuxers with safe file checks
for (int i = 0; (desc = demuxer_list[i]); i++) {
if (desc->safe_check) {
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
demuxer = open_given_type(opts, desc, stream, false, filename, params);
if (demuxer)
return demuxer;
}
@ -801,8 +795,7 @@ struct demuxer *demux_open_withparams(struct MPOpts *opts,
if (filename && opts->extension_parsing == 1) {
desc = get_demuxer_desc_from_type(demuxer_type_by_filename(filename));
if (desc)
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
demuxer = open_given_type(opts, desc, stream, false, filename, params);
if (demuxer)
return demuxer;
}
@ -810,8 +803,7 @@ struct demuxer *demux_open_withparams(struct MPOpts *opts,
// Finally try detection for demuxers with unsafe checks
for (int i = 0; (desc = demuxer_list[i]); i++) {
if (!desc->safe_check && desc->check_file) {
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
demuxer = open_given_type(opts, desc, stream, false, filename, params);
if (demuxer)
return demuxer;
}
@ -821,11 +813,10 @@ struct demuxer *demux_open_withparams(struct MPOpts *opts,
}
struct demuxer *demux_open(struct MPOpts *opts, stream_t *vs, int file_format,
int audio_id, int video_id, int sub_id,
char *filename)
{
return demux_open_withparams(opts, vs, file_format, opts->demuxer_name,
audio_id, video_id, sub_id, filename, NULL);
filename, NULL);
}
void demux_flush(demuxer_t *demuxer)

View File

@ -280,13 +280,11 @@ struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last);
double ds_get_next_pts(struct demux_stream *ds);
struct demuxer *demux_open(struct MPOpts *opts, struct stream *stream,
int file_format, int aid, int vid, int sid,
char *filename);
int file_format, char *filename);
struct demuxer *demux_open_withparams(struct MPOpts *opts,
struct stream *stream, int file_format,
char *force_format, int audio_id,
int video_id, int sub_id, char *filename,
char *force_format, char *filename,
struct demuxer_params *params);
void demux_flush(struct demuxer *demuxer);