Mercurial > mplayer.hg
changeset 7867:3dc0b71630ff
cleanup config option handling in libmpdemux.
removed overcompilacted m_config_register_options() mess - export the
subconfig structs instead
author | arpi |
---|---|
date | Wed, 23 Oct 2002 17:21:01 +0000 |
parents | 732a8bfc7681 |
children | b9df487bef09 |
files | Makefile cfg-common.h cfg-mplayer.h libmpdemux/cdda.c libmpdemux/demux_audio.c libmpdemux/demux_rawaudio.c libmpdemux/demuxer.c libmpdemux/network.c libmpdemux/opt-reg.c libmpdemux/test.c libvo/video_out.c libvo/vo_dxr2.c me-opt-reg.c mencoder.c mp-opt-reg.c mplayer.c |
diffstat | 16 files changed, 62 insertions(+), 185 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Wed Oct 23 16:52:54 2002 +0000 +++ b/Makefile Wed Oct 23 17:21:01 2002 +0000 @@ -27,8 +27,8 @@ 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
--- a/cfg-common.h Wed Oct 23 16:52:54 2002 +0000 +++ b/cfg-common.h Wed Oct 23 17:21:01 2002 +0000 @@ -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 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
--- a/cfg-mplayer.h Wed Oct 23 16:52:54 2002 +0000 +++ b/cfg-mplayer.h Wed Oct 23 17:21:01 2002 +0000 @@ -89,6 +89,10 @@ 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 @@ {"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},
--- a/libmpdemux/cdda.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/cdda.c Wed Oct 23 17:21:01 2002 +0000 @@ -19,7 +19,7 @@ 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 @@ {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;
--- a/libmpdemux/demux_audio.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/demux_audio.c Wed Oct 23 17:21:01 2002 +0000 @@ -29,7 +29,7 @@ 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 @@ 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); -}
--- a/libmpdemux/demux_rawaudio.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/demux_rawaudio.c Wed Oct 23 17:21:01 2002 +0000 @@ -17,7 +17,7 @@ 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 @@ {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);
--- a/libmpdemux/demuxer.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/demuxer.c Wed Oct 23 17:21:01 2002 +0000 @@ -1037,9 +1037,10 @@ } 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 @@ 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 @@ 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); -} -
--- a/libmpdemux/network.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/network.c Wed Oct 23 17:21:01 2002 +0000 @@ -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 @@ } 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 @@ 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_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;
--- a/libmpdemux/opt-reg.c Wed Oct 23 16:52:54 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - -#include "config.h" -#include <stdlib.h> -#include <stdio.h> -#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 -}
--- a/libmpdemux/test.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libmpdemux/test.c Wed Oct 23 17:21:01 2002 +0000 @@ -20,7 +20,7 @@ } int mp_input_check_interrupt(int time){ - if(time) usec_sleep(time); + if(time) usleep(time); return 0; }
--- a/libvo/video_out.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libvo/video_out.c Wed Oct 23 17:21:01 2002 +0000 @@ -184,16 +184,6 @@ 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);
--- a/libvo/vo_dxr2.c Wed Oct 23 16:52:54 2002 +0000 +++ b/libvo/vo_dxr2.c Wed Oct 23 17:21:01 2002 +0000 @@ -61,7 +61,7 @@ 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 @@ { 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",
--- a/me-opt-reg.c Wed Oct 23 16:52:54 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - -#include "config.h" -#include <stdlib.h> -#include <stdio.h> -#include "cfgparser.h" - -extern void libmpdemux_register_options(m_config_t* cfg); - -void -me_register_options(m_config_t* cfg) { - - libmpdemux_register_options(cfg); - -}
--- a/mencoder.c Wed Oct 23 16:52:54 2002 +0000 +++ b/mencoder.c Wed Oct 23 17:21:01 2002 +0000 @@ -77,7 +77,7 @@ //-------------------------- // 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 @@ return size; } -extern void me_register_options(m_config_t* cfg); - //--------------------------------------------------------------------------- static int at_eof=0; @@ -370,7 +368,6 @@ 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");
--- a/mp-opt-reg.c Wed Oct 23 16:52:54 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#include "config.h" -#include <stdlib.h> -#include <stdio.h> -#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); -}
--- a/mplayer.c Wed Oct 23 16:52:54 2002 +0000 +++ b/mplayer.c Wed Oct 23 17:21:01 2002 +0000 @@ -431,7 +431,7 @@ //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 @@ 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