mirror of https://github.com/mpv-player/mpv
Move audio_id and video_id to options struct
This commit is contained in:
parent
f518cf7ea9
commit
c0c914effd
|
@ -115,10 +115,10 @@
|
|||
{"loadidx", &index_file_load, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
|
||||
// select audio/video/subtitle stream
|
||||
{"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
|
||||
{"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
|
||||
INTRANGE("aid", audio_id, 0, 8190, 0),
|
||||
INTRANGE("vid", video_id, 0, 8190, 0),
|
||||
{"sid", &dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
|
||||
{"novideo", &video_id, CONF_TYPE_FLAG, 0, -1, -2, NULL},
|
||||
FLAG_CONSTANTS("novideo", video_id, -1, -2, 0),
|
||||
|
||||
{ "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },
|
||||
{ "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
||||
|
@ -196,8 +196,8 @@
|
|||
#endif
|
||||
|
||||
// disable audio
|
||||
{"sound", &audio_id, CONF_TYPE_FLAG, 0, -2, -1, NULL},
|
||||
{"nosound", &audio_id, CONF_TYPE_FLAG, 0, -1, -2, NULL},
|
||||
FLAG_CONSTANTS("sound", audio_id, -2, -1, 0),
|
||||
FLAG_CONSTANTS("nosound", audio_id, -1, -2, 0),
|
||||
|
||||
{"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
|
||||
{"af-adv", audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
|
||||
|
|
40
command.c
40
command.c
|
@ -793,6 +793,7 @@ static int mp_property_balance(m_option_t * prop, int action, void *arg,
|
|||
static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
||||
MPContext * mpctx)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
int current_id = -1, tmp;
|
||||
|
||||
switch (action) {
|
||||
|
@ -801,7 +802,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
return M_PROPERTY_UNAVAILABLE;
|
||||
if (!arg)
|
||||
return M_PROPERTY_ERROR;
|
||||
*(int *) arg = audio_id;
|
||||
*(int *) arg = opts->audio_id;
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_PRINT:
|
||||
if (!mpctx->sh_audio)
|
||||
|
@ -809,7 +810,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
if (!arg)
|
||||
return M_PROPERTY_ERROR;
|
||||
|
||||
if (audio_id < 0)
|
||||
if (opts->audio_id < 0)
|
||||
*(char **) arg = strdup(MSGTR_Disabled);
|
||||
else {
|
||||
char lang[40] = MSGTR_Unknown;
|
||||
|
@ -818,7 +819,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
av_strlcpy(lang, sh->lang, 40);
|
||||
#ifdef USE_DVDREAD
|
||||
else if (mpctx->stream->type == STREAMTYPE_DVD) {
|
||||
int code = dvd_lang_from_aid(mpctx->stream, audio_id);
|
||||
int code = dvd_lang_from_aid(mpctx->stream, opts->audio_id);
|
||||
if (code) {
|
||||
lang[0] = code >> 8;
|
||||
lang[1] = code;
|
||||
|
@ -829,10 +830,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
|
||||
#ifdef USE_DVDNAV
|
||||
else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
|
||||
dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
|
||||
dvdnav_lang_from_aid(mpctx->stream, opts->audio_id, lang);
|
||||
#endif
|
||||
*(char **) arg = malloc(64);
|
||||
snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang);
|
||||
snprintf(*(char **) arg, 64, "(%d) %s", opts->audio_id, lang);
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
|
||||
|
@ -843,12 +844,12 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
else
|
||||
tmp = -1;
|
||||
current_id = mpctx->demuxer->audio->id;
|
||||
audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
|
||||
if (audio_id == -2
|
||||
|| (audio_id > -1
|
||||
opts->audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
|
||||
if (opts->audio_id == -2
|
||||
|| (opts->audio_id > -1
|
||||
&& mpctx->demuxer->audio->id != current_id && current_id != -2))
|
||||
uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC);
|
||||
if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
|
||||
if (opts->audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
|
||||
sh_audio_t *sh2;
|
||||
sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
|
||||
if (sh2) {
|
||||
|
@ -857,7 +858,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
reinit_audio_chain(mpctx);
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", opts->audio_id);
|
||||
return M_PROPERTY_OK;
|
||||
default:
|
||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||
|
@ -869,6 +870,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
|
|||
static int mp_property_video(m_option_t * prop, int action, void *arg,
|
||||
MPContext * mpctx)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
int current_id = -1, tmp;
|
||||
|
||||
switch (action) {
|
||||
|
@ -877,7 +879,7 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
|
|||
return M_PROPERTY_UNAVAILABLE;
|
||||
if (!arg)
|
||||
return M_PROPERTY_ERROR;
|
||||
*(int *) arg = video_id;
|
||||
*(int *) arg = opts->video_id;
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_PRINT:
|
||||
if (!mpctx->sh_video)
|
||||
|
@ -885,12 +887,12 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
|
|||
if (!arg)
|
||||
return M_PROPERTY_ERROR;
|
||||
|
||||
if (video_id < 0)
|
||||
if (opts->video_id < 0)
|
||||
*(char **) arg = strdup(MSGTR_Disabled);
|
||||
else {
|
||||
char lang[40] = MSGTR_Unknown;
|
||||
*(char **) arg = malloc(64);
|
||||
snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang);
|
||||
snprintf(*(char **) arg, 64, "(%d) %s", opts->video_id, lang);
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
|
||||
|
@ -901,13 +903,13 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
|
|||
tmp = *((int *) arg);
|
||||
else
|
||||
tmp = -1;
|
||||
video_id = demuxer_switch_video(mpctx->demuxer, tmp);
|
||||
if (video_id == -2
|
||||
|| (video_id > -1 && mpctx->demuxer->video->id != current_id
|
||||
opts->video_id = demuxer_switch_video(mpctx->demuxer, tmp);
|
||||
if (opts->video_id == -2
|
||||
|| (opts->video_id > -1 && mpctx->demuxer->video->id != current_id
|
||||
&& current_id != -2))
|
||||
uninit_player(mpctx, INITIALIZED_VCODEC |
|
||||
(mpctx->opts.fixed_vo && video_id != -2 ? 0 : INITIALIZED_VO));
|
||||
if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
|
||||
(mpctx->opts.fixed_vo && opts->video_id != -2 ? 0 : INITIALIZED_VO));
|
||||
if (opts->video_id > -1 && mpctx->demuxer->video->id != current_id) {
|
||||
sh_video_t *sh2;
|
||||
sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
|
||||
if (sh2) {
|
||||
|
@ -916,7 +918,7 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
|
|||
reinit_video_chain(mpctx);
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", opts->video_id);
|
||||
return M_PROPERTY_OK;
|
||||
|
||||
default:
|
||||
|
|
|
@ -10,6 +10,8 @@ void set_default_mplayer_options(struct MPOpts *opts)
|
|||
.fixed_vo = 0,
|
||||
.loop_times = -1,
|
||||
.user_correct_pts = -1,
|
||||
.audio_id = -1,
|
||||
.video_id = -1,
|
||||
.playback_speed = 1.,
|
||||
};
|
||||
}
|
||||
|
|
16
mencoder.c
16
mencoder.c
|
@ -112,8 +112,6 @@ float stream_cache_seek_min_percent=50.0;
|
|||
#define cache_fill_status 0
|
||||
#endif
|
||||
|
||||
int audio_id=-1;
|
||||
int video_id=-1;
|
||||
int dvdsub_id=-2;
|
||||
int vobsub_id=-1;
|
||||
char* audio_lang=NULL;
|
||||
|
@ -584,14 +582,14 @@ play_next_file:
|
|||
|
||||
#ifdef USE_DVDREAD
|
||||
if(stream->type==STREAMTYPE_DVD){
|
||||
if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);
|
||||
if(audio_lang && opts.audio_id==-1) opts.audio_id=dvd_aid_from_lang(stream,audio_lang);
|
||||
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_DVDNAV
|
||||
if(stream->type==STREAMTYPE_DVDNAV){
|
||||
if(audio_lang && audio_id==-1) audio_id=dvdnav_aid_from_lang(stream,audio_lang);
|
||||
if(audio_lang && opts.audio_id==-1) opts.audio_id=dvdnav_aid_from_lang(stream,audio_lang);
|
||||
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=dvdnav_sid_from_lang(stream,dvdsub_lang);
|
||||
}
|
||||
#endif
|
||||
|
@ -600,17 +598,17 @@ if(stream->type==STREAMTYPE_DVDNAV){
|
|||
|
||||
if(stream_cache_size>0) stream_enable_cache(stream,stream_cache_size*1024,0,0);
|
||||
|
||||
if(demuxer2) audio_id=-2; /* do NOT read audio packets... */
|
||||
if(demuxer2) opts.audio_id=-2; /* do NOT read audio packets... */
|
||||
|
||||
//demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id);
|
||||
demuxer=demux_open(&opts, stream,file_format,audio_id,video_id,dvdsub_id,filename);
|
||||
//demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,dvdsub_id);
|
||||
demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,dvdsub_id,filename);
|
||||
if(!demuxer){
|
||||
mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_FormatNotRecognized);
|
||||
mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer);
|
||||
mencoder_exit(1,NULL);
|
||||
}
|
||||
|
||||
select_audio(demuxer, audio_id, audio_lang);
|
||||
select_audio(demuxer, opts.audio_id, audio_lang);
|
||||
|
||||
if (dvdsub_id < 0 && dvdsub_lang)
|
||||
dvdsub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
|
||||
|
@ -662,7 +660,7 @@ sh_video=d_video->sh;
|
|||
}
|
||||
|
||||
if(sh_audio && out_audio_codec<0){
|
||||
if(audio_id==-2)
|
||||
if(opts.audio_id==-2)
|
||||
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_DemuxerDoesntSupportNosound);
|
||||
mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioEncoderSelected);
|
||||
mencoder_exit(1,NULL);
|
||||
|
|
11
mplayer.c
11
mplayer.c
|
@ -243,9 +243,6 @@ extern char *demuxer_name; // override demuxer
|
|||
extern char *audio_demuxer_name; // override audio demuxer
|
||||
extern char *sub_demuxer_name; // override sub demuxer
|
||||
|
||||
// streaming:
|
||||
int audio_id=-1;
|
||||
int video_id=-1;
|
||||
int dvdsub_id=-2;
|
||||
int vobsub_id=-1;
|
||||
char* audio_lang=NULL;
|
||||
|
@ -3209,7 +3206,7 @@ if(stream_dump_type==5){
|
|||
#ifdef USE_DVDREAD
|
||||
if(mpctx->stream->type==STREAMTYPE_DVD){
|
||||
current_module="dvd lang->id";
|
||||
if(audio_id==-1) audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
|
||||
if(opts->audio_id==-1) opts->audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
|
||||
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1;
|
||||
if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
|
||||
// setup global sub numbering
|
||||
|
@ -3222,7 +3219,7 @@ if(mpctx->stream->type==STREAMTYPE_DVD){
|
|||
#ifdef USE_DVDNAV
|
||||
if(mpctx->stream->type==STREAMTYPE_DVDNAV){
|
||||
current_module="dvdnav lang->id";
|
||||
if(audio_id==-1) audio_id=dvdnav_aid_from_lang(mpctx->stream,audio_lang);
|
||||
if(opts->audio_id==-1) opts->audio_id=dvdnav_aid_from_lang(mpctx->stream,audio_lang);
|
||||
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1;
|
||||
if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
|
||||
// setup global sub numbering
|
||||
|
@ -3245,7 +3242,7 @@ if(stream_cache_size>0){
|
|||
//============ Open DEMUXERS --- DETECT file type =======================
|
||||
current_module="demux_open";
|
||||
|
||||
mpctx->demuxer=demux_open(opts, mpctx->stream,mpctx->file_format,audio_id,video_id,dvdsub_id,filename);
|
||||
mpctx->demuxer=demux_open(opts, mpctx->stream,mpctx->file_format,opts->audio_id,opts->video_id,dvdsub_id,filename);
|
||||
|
||||
// HACK to get MOV Reference Files working
|
||||
|
||||
|
@ -3350,7 +3347,7 @@ mpctx->d_video=mpctx->demuxer->video;
|
|||
mpctx->d_sub=mpctx->demuxer->sub;
|
||||
|
||||
// select audio stream
|
||||
select_audio(mpctx->demuxer, audio_id, audio_lang);
|
||||
select_audio(mpctx->demuxer, opts->audio_id, audio_lang);
|
||||
|
||||
// DUMP STREAMS:
|
||||
if((stream_dump_type)&&(stream_dump_type<4)){
|
||||
|
|
|
@ -44,8 +44,6 @@ extern int frame_dropping;
|
|||
|
||||
extern int auto_quality;
|
||||
|
||||
extern int audio_id;
|
||||
extern int video_id;
|
||||
extern int dvdsub_id;
|
||||
extern int vobsub_id;
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ typedef struct MPOpts {
|
|||
int correct_pts;
|
||||
int loop_times;
|
||||
int user_correct_pts;
|
||||
int audio_id;
|
||||
int video_id;
|
||||
float playback_speed;
|
||||
} MPOpts;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "options.h"
|
||||
#include "mp_msg.h"
|
||||
#include "help_mp.h"
|
||||
|
||||
|
@ -648,6 +648,7 @@ int asf_mmst_streaming_start(stream_t *stream)
|
|||
|
||||
memset (data, 0, 40);
|
||||
|
||||
int audio_id = stream->opts->audio_id;
|
||||
if (audio_id > 0) {
|
||||
data[2] = 0xFF;
|
||||
data[3] = 0xFF;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "config.h"
|
||||
#include "mp_msg.h"
|
||||
#include "help_mp.h"
|
||||
#include "options.h"
|
||||
|
||||
#ifndef HAVE_WINSOCK2
|
||||
#define closesocket close
|
||||
|
@ -146,9 +147,6 @@ printf("0x%02X\n", stream_chunck->type );
|
|||
return stream_chunck->size+4;
|
||||
}
|
||||
|
||||
extern int audio_id;
|
||||
extern int video_id;
|
||||
|
||||
static void close_s(stream_t *stream) {
|
||||
close(stream->fd);
|
||||
stream->fd=-1;
|
||||
|
@ -364,24 +362,24 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (audio_id > 0)
|
||||
if (*streaming_ctrl->audio_id_ptr > 0)
|
||||
// a audio stream was forced
|
||||
asf_ctrl->audio_id = audio_id;
|
||||
asf_ctrl->audio_id = *streaming_ctrl->audio_id_ptr;
|
||||
else if (a_idx >= 0)
|
||||
asf_ctrl->audio_id = asf_ctrl->audio_streams[a_idx];
|
||||
else if (asf_ctrl->n_audio) {
|
||||
mp_msg(MSGT_NETWORK, MSGL_WARN, MSGTR_MPDEMUX_ASF_Bandwidth2SmallDeselectedAudio);
|
||||
audio_id = -2;
|
||||
*streaming_ctrl->audio_id_ptr = -2;
|
||||
}
|
||||
|
||||
if (video_id > 0)
|
||||
if (*streaming_ctrl->video_id_ptr > 0)
|
||||
// a video stream was forced
|
||||
asf_ctrl->video_id = video_id;
|
||||
asf_ctrl->video_id = *streaming_ctrl->video_id_ptr;
|
||||
else if (v_idx >= 0)
|
||||
asf_ctrl->video_id = asf_ctrl->video_streams[v_idx];
|
||||
else if (asf_ctrl->n_video) {
|
||||
mp_msg(MSGT_NETWORK, MSGL_WARN, MSGTR_MPDEMUX_ASF_Bandwidth2SmallDeselectedVideo);
|
||||
video_id = -2;
|
||||
*streaming_ctrl->video_id_ptr = -2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -817,6 +815,8 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
|
|||
if( stream->streaming_ctrl==NULL ) {
|
||||
return STREAM_ERROR;
|
||||
}
|
||||
stream->streaming_ctrl->audio_id_ptr = &stream->opts->audio_id;
|
||||
stream->streaming_ctrl->video_id_ptr = &stream->opts->video_id;
|
||||
stream->streaming_ctrl->bandwidth = network_bandwidth;
|
||||
url = url_new(stream->url);
|
||||
stream->streaming_ctrl->url = check4proxies(url);
|
||||
|
|
|
@ -46,6 +46,9 @@ typedef struct streaming_control {
|
|||
int (*streaming_read)( int fd, char *buffer, int buffer_size, struct streaming_control *stream_ctrl );
|
||||
int (*streaming_seek)( int fd, off_t pos, struct streaming_control *stream_ctrl );
|
||||
void *data;
|
||||
// hacks for asf
|
||||
int *audio_id_ptr;
|
||||
int *video_id_ptr;
|
||||
} streaming_ctrl_t;
|
||||
|
||||
//int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url );
|
||||
|
|
Loading…
Reference in New Issue