diff --git a/Makefile b/Makefile index fe57cc9596..d32e7d9b27 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ endif INSTALL = install SRCS_COMMON = cpudetect.c codec-cfg.c cfgparser.c my_profile.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c -SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c me-opt-reg.c xvid_vbr.c -SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c mp-opt-reg.c +SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c +SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c ifeq ($(UNRARLIB),yes) SRCS_COMMON += unrarlib.c diff --git a/cfg-common.h b/cfg-common.h index 941d9b8348..7fe5476194 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -71,6 +71,22 @@ {"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, {"sid", &dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, + { "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}, + + { "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, + +#ifdef HAVE_CDDA + { "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, +#endif + + // demuxer.c - select audio/sub file/demuxer + { "audiofile", &audio_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "subfile", &sub_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "demuxer", &demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, + { "audio-demuxer", &audio_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, + { "sub-demuxer", &sub_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, + {"mf", mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL}, #ifdef USE_TV {"tv", tvopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, @@ -199,6 +215,15 @@ extern char *network_password; extern int network_bandwidth; #endif +/* defined in libmpdemux: */ +extern int hr_mp3_seek; +extern config_t demux_rawaudio_opts[]; +extern config_t cdda_opts[]; + +extern char* audio_stream; +extern char* sub_stream; +extern int demuxer_type, audio_demuxer_type, sub_demuxer_type; + #include "libmpdemux/tv.h" #ifdef USE_TV diff --git a/cfg-mplayer.h b/cfg-mplayer.h index aa25f62723..4e405697f2 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -89,6 +89,10 @@ extern int vo_zr_parseoption(struct config * conf, char *opt, char * param); extern void vo_zr_revertoption(config_t* opt,char* pram); #endif +#ifdef HAVE_DXR2 +extern config_t dxr2_opts[]; +#endif + #ifdef STREAMING_LIVE_DOT_COM extern int isSDPFile; extern int rtspStreamOverTCP; @@ -304,6 +308,10 @@ static config_t mplayer_opts[]={ {"zr*", vo_zr_parseoption, CONF_TYPE_FUNC_FULL, 0, 0, 0, &vo_zr_revertoption }, #endif +#ifdef HAVE_DXR2 + {"dxr2", &dxr2_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, +#endif + #ifdef STREAMING_LIVE_DOT_COM // -sdp option, specifying that the source is a SDP file {"sdp", &isSDPFile, CONF_TYPE_FLAG, 0, 0, 1, NULL}, diff --git a/libmpdemux/cdda.c b/libmpdemux/cdda.c index 7e44f93824..b6dd1742ec 100644 --- a/libmpdemux/cdda.c +++ b/libmpdemux/cdda.c @@ -19,7 +19,7 @@ static int toc_bias = 0; static int toc_offset = 0; static int no_skip = 0; -static config_t cdda_opts[] = { +config_t cdda_opts[] = { { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, NULL }, { "paranoia", ¶noia_mode, CONF_TYPE_INT,CONF_RANGE, 0, 2, NULL }, { "generic-dev", &generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, @@ -32,15 +32,6 @@ static config_t cdda_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -static config_t cdda_conf[] = { - { "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, - { NULL,NULL, 0, 0, 0, 0, NULL} -}; - -void cdda_register_options(m_config_t* cfg) { - m_config_register_options(cfg,cdda_conf); -} - stream_t* open_cdda(char* dev,char* track) { stream_t* st; int start_track = 0; diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index ee6c89dd9b..f507fab6b7 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -29,7 +29,7 @@ typedef struct da_priv { extern void free_sh_audio(sh_audio_t* sh); extern void resync_audio_stream(sh_audio_t *sh_audio); -static int hr_mp3_seek = 0; +int hr_mp3_seek = 0; int demux_audio_open(demuxer_t* demuxer) { stream_t *s; @@ -337,16 +337,3 @@ void demux_close_audio(demuxer_t* demuxer) { free(priv); } -/****************** Options stuff ******************/ - -#include "../cfgparser.h" - -static config_t demux_audio_opts[] = { - { "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}, - {NULL, NULL, 0, 0, 0, 0, NULL} -}; - -void demux_audio_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demux_audio_opts); -} diff --git a/libmpdemux/demux_rawaudio.c b/libmpdemux/demux_rawaudio.c index d1ff7514b2..f92bd8e423 100644 --- a/libmpdemux/demux_rawaudio.c +++ b/libmpdemux/demux_rawaudio.c @@ -17,7 +17,7 @@ static int samplerate = 44100; static int samplesize = 2; static int format = 0x1; // Raw PCM -static config_t demux_rawaudio_opts[] = { +config_t demux_rawaudio_opts[] = { { "on", &use_rawaudio, CONF_TYPE_FLAG, 0,0, 1, NULL }, { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, NULL }, { "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, NULL }, @@ -26,14 +26,6 @@ static config_t demux_rawaudio_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -static config_t demux_rawaudio_conf[] = { - { "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, - { NULL,NULL, 0, 0, 0, 0, NULL} -}; - -void demux_rwaudio_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demux_rawaudio_conf); -} extern void resync_audio_stream(sh_audio_t *sh_audio); diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 08a235fcf9..a41378c061 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1037,9 +1037,10 @@ return demuxer; } char* audio_stream = NULL; -static char* sub_stream = NULL; -static int demuxer_type = 0, audio_demuxer_type = 0, sub_demuxer_type = 0; -extern m_config_t* mconfig; +char* sub_stream = NULL; +int demuxer_type = 0, audio_demuxer_type = 0, sub_demuxer_type = 0; + +extern int hr_mp3_seek; demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int dvdsub_id){ stream_t *as = NULL,*ss = NULL; @@ -1069,7 +1070,7 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int if(!ad) mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream); else if(ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3 - m_config_set_flag(mconfig,"hr-mp3-seek",1); // Enable high res seeking + hr_mp3_seek=1; // Enable high res seeking } if(ss) { sd = demux_open_stream(ss,sub_demuxer_type ? sub_demuxer_type : sfmt,-2,-2,dvdsub_id); @@ -1245,18 +1246,3 @@ char* demux_info_get(demuxer_t *demuxer, char *opt) { return NULL; } -/******************* Options stuff **********************/ - -static config_t demuxer_opts[] = { - { "audiofile", &audio_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "subfile", &sub_stream, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "demuxer", &demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { "audio-demuxer", &audio_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { "sub-demuxer", &sub_demuxer_type, CONF_TYPE_INT, CONF_RANGE, 1, DEMUXER_TYPE_MAX, NULL }, - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -void demuxer_register_options(m_config_t* cfg) { - m_config_register_options(cfg,demuxer_opts); -} - diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 522b25b6c1..d49515cb13 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -31,14 +31,14 @@ #include "../version.h" extern int verbose; -extern m_config_t *mconfig; +extern int stream_cache_size; extern int mp_input_check_interrupt(int time); /* Variables for the command line option -user, -passwd & -bandwidth */ -char *network_username; -char *network_password; -int network_bandwidth; +char *network_username=NULL; +char *network_password=NULL; +int network_bandwidth=0; static struct { @@ -381,34 +381,24 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) { } else { mp_msg(MSGT_NETWORK,MSGL_INFO,"Authentication required\n"); } - ret = m_config_is_option_set(mconfig,"user"); - if( ret==1 ) { - char *username; - username = *((char**)m_config_get_option_ptr(mconfig, "user")); - if( username==NULL ) return -1; - url->username = (char*)malloc(strlen(username)+1); + if( network_username ) { + url->username = strdup(network_username); if( url->username==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); return -1; } - strcpy(url->username, username); } else { mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to read the username\n"); mp_msg(MSGT_NETWORK,MSGL_ERR,"Please use the option -user and -passwd to provide your username/password for a list of URLs,\n"); mp_msg(MSGT_NETWORK,MSGL_ERR,"or form an URL like: http://username:password@hostname/file\n"); return -1; } - ret = m_config_is_option_set(mconfig,"passwd"); - if( ret==1 ) { - char *password; - password = *((char**)m_config_get_option_ptr(mconfig, "passwd")); - if( password==NULL ) return -1; - url->password = (char*)malloc(strlen(password)+1); + if( network_password ) { + url->password = strdup(network_password); if( url->password==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); return -1; } - strcpy(url->password, password); } else { mp_msg(MSGT_NETWORK,MSGL_INFO,"No password provided, trying blank password\n"); } @@ -830,18 +820,7 @@ streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { ret = -1; // Get the bandwidth available - ret = m_config_is_option_set(mconfig,"bandwidth"); - if(ret < 0) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to know if the bandwidth limit was set\n"); - } else { - val = m_config_get_int( mconfig, "bandwidth", NULL); - if( val<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to retrieve the bandwidth option value\n"); - stream->streaming_ctrl->bandwidth = 0; // Don't limit bandwidth - } else { - stream->streaming_ctrl->bandwidth = val; - } - } + stream->streaming_ctrl->bandwidth = network_bandwidth; #ifndef STREAMING_LIVE_DOT_COM // For RTP streams, we usually don't know the stream type until we open it. @@ -905,31 +884,14 @@ streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { streaming_ctrl_free( stream->streaming_ctrl ); stream->streaming_ctrl = NULL; } else if( stream->streaming_ctrl->buffering ) { - int cache_size = 0; - int cache_opt, val; - cache_opt = m_config_is_option_set(mconfig,"cache"); - if(cache_opt < 0) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to know if cache size option was set\n"); - } else if(!cache_opt) { + int cache_size = stream_cache_size; + if(!stream_cache_size) { // cache option not set, will use our computed value. // buffer in KBytes, *5 because the prefill is 20% of the buffer. - val = (stream->streaming_ctrl->prebuffer_size/1024)*5; - if( val<16 ) val = 16; // 16KBytes min buffer - if( m_config_set_int( mconfig, "cache", val )<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to set the cache size option\n"); - } else { - cache_size = val; - } - } else { - // cache option set, will use the given one. - val = m_config_get_int( mconfig, "cache", NULL ); - if( val<0 ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Unable to retrieve the cache option value\n"); - } else { - cache_size = val; - } + stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5; + if( stream_cache_size<16 ) stream_cache_size = 16; // 16KBytes min buffer } - mp_msg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", cache_size ); + mp_msg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", stream_cache_size); } return ret; diff --git a/libmpdemux/opt-reg.c b/libmpdemux/opt-reg.c deleted file mode 100644 index 8c241934b8..0000000000 --- a/libmpdemux/opt-reg.c +++ /dev/null @@ -1,22 +0,0 @@ - -#include "config.h" -#include -#include -#include "../cfgparser.h" - -extern void demux_audio_register_options(m_config_t* cfg); -extern void demuxer_register_options(m_config_t* cfg); -extern void demux_rwaudio_register_options(m_config_t* cfg); -#ifdef HAVE_CDDA -extern void cdda_register_options(m_config_t* cfg); -#endif - -void libmpdemux_register_options(m_config_t* cfg) { - - demux_audio_register_options(cfg); - demuxer_register_options(cfg); - demux_rwaudio_register_options(cfg); -#ifdef HAVE_CDDA - cdda_register_options(cfg); -#endif -} diff --git a/libmpdemux/test.c b/libmpdemux/test.c index 478c03da4e..bee727e84a 100644 --- a/libmpdemux/test.c +++ b/libmpdemux/test.c @@ -20,7 +20,7 @@ void resync_audio_stream(sh_audio_t *sh_audio){ } int mp_input_check_interrupt(int time){ - if(time) usec_sleep(time); + if(time) usleep(time); return 0; } diff --git a/libvo/video_out.c b/libvo/video_out.c index 5793aff8b9..ce0b3d9130 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -184,16 +184,6 @@ vo_functions_t* video_out_drivers[] = NULL }; -#ifdef HAVE_DXR2 -extern void vo_dxr2_register_options(void*); -#endif - -void libvo_register_options(void* cfg) { -#ifdef HAVE_DXR2 - vo_dxr2_register_options(cfg); -#endif -} - void list_video_out(){ int i=0; mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers); diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c index 535501865e..933e6fcfe4 100644 --- a/libvo/vo_dxr2.c +++ b/libvo/vo_dxr2.c @@ -61,7 +61,7 @@ static int mute_mode = DXR2_AUDIO_MUTE_OFF; static int ignore_cache = 0; static int update_cache = 0; -static config_t dxr2_opts[] = { +config_t dxr2_opts[] = { { "overlay", &use_ol, CONF_TYPE_FLAG, 0, 0, 1, NULL}, { "nooverlay", &use_ol, CONF_TYPE_FLAG, 0, 1, 0, NULL}, { "overlay-ratio", &ol_ratio, CONF_TYPE_INT, CONF_RANGE, 1, 2500, NULL }, @@ -96,15 +96,6 @@ static config_t dxr2_opts[] = { { NULL,NULL, 0, 0, 0, 0, NULL} }; -static config_t dxr2_opt[] = { - { "dxr2", &dxr2_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, - { NULL,NULL, 0, 0, 0, 0, NULL} -}; - -void vo_dxr2_register_options(m_config_t* cfg) { - m_config_register_options(cfg,dxr2_opt); -} - static vo_info_t vo_info = { "DXR2 video out", "dxr2", diff --git a/me-opt-reg.c b/me-opt-reg.c deleted file mode 100644 index 7b0c6012e8..0000000000 --- a/me-opt-reg.c +++ /dev/null @@ -1,14 +0,0 @@ - -#include "config.h" -#include -#include -#include "cfgparser.h" - -extern void libmpdemux_register_options(m_config_t* cfg); - -void -me_register_options(m_config_t* cfg) { - - libmpdemux_register_options(cfg); - -} diff --git a/mencoder.c b/mencoder.c index a3c21a21ab..fd57a6f576 100644 --- a/mencoder.c +++ b/mencoder.c @@ -77,7 +77,7 @@ int vo_config_count=0; //-------------------------- // cache2: -static int stream_cache_size=0; +int stream_cache_size=0; #ifdef USE_STREAM_CACHE extern int cache_fill_status; #else @@ -269,8 +269,6 @@ static int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){ return size; } -extern void me_register_options(m_config_t* cfg); - //--------------------------------------------------------------------------- static int at_eof=0; @@ -370,7 +368,6 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){ playtree = play_tree_new(); mconfig = m_config_new(playtree); m_config_register_options(mconfig,mencoder_opts); - me_register_options(mconfig); parse_cfgfiles(mconfig); if(m_config_parse_command_line(mconfig, argc, argv) < 0) mencoder_exit(1, "error parsing cmdline"); diff --git a/mp-opt-reg.c b/mp-opt-reg.c deleted file mode 100644 index 2eda11ec78..0000000000 --- a/mp-opt-reg.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "config.h" -#include -#include -#include "cfgparser.h" - -extern void mp_input_register_options(m_config_t* cfg); -extern void libmpdemux_register_options(m_config_t* cfg); -extern void libvo_register_options(m_config_t* cfg); - -void -mp_register_options(m_config_t* cfg) { - - mp_input_register_options(cfg); - libmpdemux_register_options(cfg); - libvo_register_options(cfg); -} diff --git a/mplayer.c b/mplayer.c index 0a0e178c1f..4c0f87f9de 100644 --- a/mplayer.c +++ b/mplayer.c @@ -431,7 +431,7 @@ static void exit_sighandler(int x){ //extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); -extern void mp_register_options(m_config_t* cfg); +extern void mp_input_register_options(m_config_t* cfg); #include "mixer.h" #include "cfg-mplayer.h" @@ -580,7 +580,7 @@ int gui_no_filename=0; mconfig = m_config_new(playtree); m_config_register_options(mconfig,mplayer_opts); // TODO : add something to let modules register their options - mp_register_options(mconfig); + mp_input_register_options(mconfig); parse_cfgfiles(mconfig); #ifdef HAVE_NEW_GUI