diff --git a/cfg-common.h b/cfg-common.h index 529eeb56aa..836a1f8fa0 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -60,7 +60,6 @@ extern const m_option_t demux_rawaudio_opts[]; extern const m_option_t demux_rawvideo_opts[]; extern const m_option_t cdda_opts[]; -extern char* sub_stream; extern int demuxer_type, audio_demuxer_type, sub_demuxer_type; extern int ts_prog; extern int ts_keep_broken; @@ -195,8 +194,6 @@ extern int rtsp_port; extern char *rtsp_destination; -extern int audio_stream_cache; - extern int sws_chr_vshift; extern int sws_chr_hshift; extern float sws_chr_gblur; @@ -526,14 +523,13 @@ const m_option_t common_opts[] = { #endif // demuxer.c - select audio/sub file/demuxer - { "audiofile", &audio_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "audiofile-cache", &audio_stream_cache, CONF_TYPE_INT, CONF_RANGE, 50, 65536, NULL}, - { "subfile", &sub_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "demuxer", &demuxer_name, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "audio-demuxer", &audio_demuxer_name, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "sub-demuxer", &sub_demuxer_name, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "extbased", &extension_parsing, CONF_TYPE_FLAG, 0, 0, 1, NULL }, - { "noextbased", &extension_parsing, CONF_TYPE_FLAG, 0, 1, 0, NULL }, + OPT_STRING("audiofile", audio_stream, 0), + OPT_INTRANGE("audiofile-cache", audio_stream_cache, 0, 50, 65536), + OPT_STRING("subfile", sub_stream, 0), + OPT_STRING("demuxer", demuxer_name, 0), + OPT_STRING("audio-demuxer", audio_demuxer_name, 0), + OPT_STRING("sub-demuxer", sub_demuxer_name, 0), + OPT_MAKE_FLAGS("extbased", extension_parsing, 0), {"mf", (void *) mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL}, #ifdef CONFIG_RADIO diff --git a/defaultopts.c b/defaultopts.c index 225b06746e..0fc79e4df4 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -30,6 +30,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .audio_id = -1, .video_id = -1, .sub_id = -1, + .extension_parsing = 1, .audio_output_channels = 2, .audio_output_format = -1, // AF_FORMAT_UNKNOWN .playback_speed = 1., diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index f301e4f59e..b73f0c961a 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -920,8 +920,6 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force) return -1; } -int extension_parsing = 1; // 0=off 1=mixed (used only for unstable formats) - static struct demuxer *open_given_type(struct MPOpts *opts, const struct demuxer_desc *desc, struct stream *stream, bool force, @@ -1017,7 +1015,7 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts, // Ok. We're over the stable detectable fileformats, the next ones are // a bit fuzzy. So by default (extension_parsing==1) try extension-based // detection first: - if (filename && extension_parsing == 1) { + 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, @@ -1070,14 +1068,6 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts, return demuxer; } -char *audio_stream = NULL; -char *sub_stream = NULL; -int audio_stream_cache = 0; - -char *demuxer_name = NULL; // parameter from -demuxer -char *audio_demuxer_name = NULL; // parameter from -audio-demuxer -char *sub_demuxer_name = NULL; // parameter from -sub-demuxer - extern int hr_mp3_seek; extern float stream_cache_min_percent; @@ -1096,42 +1086,42 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, int demuxer_force = 0, audio_demuxer_force = 0, sub_demuxer_force = 0; if ((demuxer_type = - get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) { + get_demuxer_type_from_name(opts->demuxer_name, &demuxer_force)) < 0) { mp_msg(MSGT_DEMUXER, MSGL_ERR, "-demuxer %s does not exist.\n", - demuxer_name); + opts->demuxer_name); return NULL; } if ((audio_demuxer_type = - get_demuxer_type_from_name(audio_demuxer_name, + get_demuxer_type_from_name(opts->audio_demuxer_name, &audio_demuxer_force)) < 0) { mp_msg(MSGT_DEMUXER, MSGL_ERR, "-audio-demuxer %s does not exist.\n", - audio_demuxer_name); - if (audio_stream) + opts->audio_demuxer_name); + if (opts->audio_stream) return NULL; } if ((sub_demuxer_type = - get_demuxer_type_from_name(sub_demuxer_name, + get_demuxer_type_from_name(opts->sub_demuxer_name, &sub_demuxer_force)) < 0) { mp_msg(MSGT_DEMUXER, MSGL_ERR, "-sub-demuxer %s does not exist.\n", - sub_demuxer_name); - if (sub_stream) + opts->sub_demuxer_name); + if (opts->sub_stream) return NULL; } - if (audio_stream) { - as = open_stream(audio_stream, 0, &afmt); + if (opts->audio_stream) { + as = open_stream(opts->audio_stream, 0, &afmt); if (!as) { mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "Cannot open audio stream: %s\n", - audio_stream); + opts->audio_stream); return NULL; } - if (audio_stream_cache) { + if (opts->audio_stream_cache) { if (!stream_enable_cache - (as, audio_stream_cache * 1024, - audio_stream_cache * 1024 * (stream_cache_min_percent / - 100.0), - audio_stream_cache * 1024 * (stream_cache_seek_min_percent / - 100.0))) { + (as, opts->audio_stream_cache * 1024, + opts->audio_stream_cache * 1024 * + (stream_cache_min_percent / 100.0), + opts->audio_stream_cache * 1024 * + (stream_cache_seek_min_percent / 100.0))) { free_stream(as); mp_msg(MSGT_DEMUXER, MSGL_ERR, "Can't enable audio stream cache\n"); @@ -1139,18 +1129,18 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, } } } - if (sub_stream) { - ss = open_stream(sub_stream, 0, &sfmt); + if (opts->sub_stream) { + ss = open_stream(opts->sub_stream, 0, &sfmt); if (!ss) { mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "Cannot open subtitle stream: %s\n", - sub_stream); + opts->sub_stream); return NULL; } } vd = demux_open_stream(opts, vs, demuxer_type ? demuxer_type : file_format, - demuxer_force, audio_stream ? -2 : audio_id, - video_id, sub_stream ? -2 : dvdsub_id, filename); + demuxer_force, opts->audio_stream ? -2 : audio_id, + video_id, opts->sub_stream ? -2 : dvdsub_id, filename); if (!vd) { if (as) free_stream(as); @@ -1162,10 +1152,10 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, ad = demux_open_stream(opts, as, audio_demuxer_type ? audio_demuxer_type : afmt, audio_demuxer_force, audio_id, -2, -2, - audio_stream); + opts->audio_stream); if (!ad) { mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "Failed to open audio demuxer: %s\n", - audio_stream); + opts->audio_stream); free_stream(as); } else if (ad->audio->sh && ((sh_audio_t *) ad->audio->sh)->format == 0x55) // MP3 @@ -1175,10 +1165,10 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, sd = demux_open_stream(opts, ss, sub_demuxer_type ? sub_demuxer_type : sfmt, sub_demuxer_force, -2, -2, dvdsub_id, - sub_stream); + opts->sub_stream); if (!sd) { mp_tmsg(MSGT_DEMUXER, MSGL_WARN, - "Failed to open subtitle demuxer: %s\n", sub_stream); + "Failed to open subtitle demuxer: %s\n", opts->sub_stream); free_stream(ss); } } diff --git a/mplayer.c b/mplayer.c index cc5bfb68dc..1c6bf14226 100644 --- a/mplayer.c +++ b/mplayer.c @@ -303,11 +303,6 @@ char **video_codec_list=NULL; // override video codec char **audio_fm_list=NULL; // override audio codec family char **video_fm_list=NULL; // override video codec family -// demuxer: -extern char *demuxer_name; // override demuxer -extern char *audio_demuxer_name; // override audio demuxer -extern char *sub_demuxer_name; // override sub demuxer - // this dvdsub_id was selected via slang // use this to allow dvdnav to follow -slang across stream resets, // in particular the subtitle ID for a language changes @@ -3328,9 +3323,9 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){ opt_exit = 1; } #endif - if((demuxer_name && strcmp(demuxer_name,"help")==0) || - (audio_demuxer_name && strcmp(audio_demuxer_name,"help")==0) || - (sub_demuxer_name && strcmp(sub_demuxer_name,"help")==0)){ + if((opts->demuxer_name && strcmp(opts->demuxer_name,"help")==0) || + (opts->audio_demuxer_name && strcmp(opts->audio_demuxer_name,"help")==0) || + (opts->sub_demuxer_name && strcmp(opts->sub_demuxer_name,"help")==0)){ demuxer_help(); mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); opt_exit = 1; diff --git a/options.h b/options.h index 8450435bba..b81744d248 100644 --- a/options.h +++ b/options.h @@ -45,6 +45,15 @@ typedef struct MPOpts { int sub_id; char *audio_lang; char *sub_lang; + + char *audio_stream; + int audio_stream_cache; + char *sub_stream; + char *demuxer_name; + char *audio_demuxer_name; + char *sub_demuxer_name; + int extension_parsing; + int audio_output_channels; int audio_output_format; float playback_speed; diff --git a/stream/stream.h b/stream/stream.h index 6d56e2adab..24a140d255 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -355,7 +355,6 @@ extern int dvd_title; extern int dvd_angle; extern char *bluray_device; -extern char * audio_stream; typedef struct { int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm