1
mirror of https://github.com/mpv-player/mpv synced 2024-07-11 23:47:56 +02:00

cleanup config option handling in libmpdemux.

removed overcompilacted m_config_register_options() mess - export the
subconfig structs instead


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7868 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-10-23 17:21:01 +00:00
parent a2dfc7a766
commit f9e3a4bf88
16 changed files with 62 additions and 185 deletions

View File

@ -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

View File

@ -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

View File

@ -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},

View File

@ -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", &paranoia_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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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",

View File

@ -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);
}

View File

@ -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");

View File

@ -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);
}

View File

@ -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