diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/asf_mmst_streaming.c | 3 | ||||
-rw-r--r-- | stream/asf_streaming.c | 18 | ||||
-rw-r--r-- | stream/cache2.c | 11 | ||||
-rw-r--r-- | stream/network.h | 3 | ||||
-rw-r--r-- | stream/open.c | 3 | ||||
-rw-r--r-- | stream/stream.c | 37 | ||||
-rw-r--r-- | stream/stream.h | 32 | ||||
-rw-r--r-- | stream/stream_dvd.c | 6 | ||||
-rw-r--r-- | stream/stream_netstream.c | 6 | ||||
-rw-r--r-- | stream/stream_radio.c | 18 | ||||
-rw-r--r-- | stream/stream_radio.h | 12 | ||||
-rw-r--r-- | stream/stream_rtsp.c | 2 | ||||
-rw-r--r-- | stream/stream_vstream.c | 4 | ||||
-rw-r--r-- | stream/tv.c | 2 |
14 files changed, 82 insertions, 75 deletions
diff --git a/stream/asf_mmst_streaming.c b/stream/asf_mmst_streaming.c index 36021af35c..ad9b3e97ee 100644 --- a/stream/asf_mmst_streaming.c +++ b/stream/asf_mmst_streaming.c @@ -35,7 +35,7 @@ #include <inttypes.h> #include "config.h" - +#include "options.h" #include "mp_msg.h" #include "help_mp.h" @@ -646,6 +646,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; diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c index a937c23432..98859cfe9e 100644 --- a/stream/asf_streaming.c +++ b/stream/asf_streaming.c @@ -8,6 +8,7 @@ #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #ifdef HAVE_WINSOCK2_H #include <winsock2.h> @@ -144,9 +145,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; @@ -362,24 +360,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; @@ -815,6 +813,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); diff --git a/stream/cache2.c b/stream/cache2.c index d211ba483b..c9d5539035 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -39,9 +39,6 @@ static void *ThreadProc(void *s); #include "cache2.h" extern int use_gui; -int stream_fill_buffer(stream_t *s); -int stream_seek_long(stream_t *s,off_t pos); - typedef struct { // constats: unsigned char *buffer; // base pointer of the alllocated buffer memory @@ -74,13 +71,13 @@ static int min_fill=0; int cache_fill_status=0; -void cache_stats(cache_vars_t* s){ +static void cache_stats(cache_vars_t* s){ int newb=s->max_filepos-s->read_filepos; // new bytes in the buffer mp_msg(MSGT_CACHE,MSGL_INFO,"0x%06X [0x%06X] 0x%06X ",(int)s->min_filepos,(int)s->read_filepos,(int)s->max_filepos); mp_msg(MSGT_CACHE,MSGL_INFO,"%3d %% (%3d%%)\n",100*newb/s->buffer_size,100*min_fill/s->buffer_size); } -int cache_read(cache_vars_t* s,unsigned char* buf,int size){ +static int cache_read(cache_vars_t* s,unsigned char* buf,int size){ int total=0; while(size>0){ int pos,newb,len; @@ -126,7 +123,7 @@ int cache_read(cache_vars_t* s,unsigned char* buf,int size){ return total; } -int cache_fill(cache_vars_t* s){ +static int cache_fill(cache_vars_t* s){ int back,back2,newb,space,len,pos; off_t read=s->read_filepos; @@ -246,7 +243,7 @@ static int cache_execute_control(cache_vars_t *s) { return res; } -cache_vars_t* cache_init(int size,int sector){ +static cache_vars_t* cache_init(int size,int sector){ int num; #if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__) cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t)); diff --git a/stream/network.h b/stream/network.h index 36b470dfe4..2f8d4123ab 100644 --- a/stream/network.h +++ b/stream/network.h @@ -53,6 +53,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 ); diff --git a/stream/open.c b/stream/open.c index 0ec0222c32..dad7c49db7 100644 --- a/stream/open.c +++ b/stream/open.c @@ -30,7 +30,8 @@ int dvd_title=0; // Open a new stream (stdin/file/vcd/url) -stream_t* open_stream(char* filename,char** options, int* file_format){ +stream_t* open_stream(char* filename, struct MPOpts *options, int* file_format) +{ // Check if playlist or unknown if (*file_format != DEMUXER_TYPE_PLAYLIST){ *file_format=DEMUXER_TYPE_UNKNOWN; diff --git a/stream/stream.c b/stream/stream.c index bcf4836717..1431fa123a 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -32,7 +32,9 @@ //#include "vcd_read_bincue.h" -static int (*stream_check_interrupt_cb)(int time) = NULL; +struct input_ctx; +static int (*stream_check_interrupt_cb)(struct input_ctx *ctx, int time); +static struct input_ctx *stream_check_interrupt_ctx; extern const stream_info_t stream_info_vcd; extern const stream_info_t stream_info_cdda; @@ -119,9 +121,11 @@ static const stream_info_t* const auto_open_streams[] = { NULL }; -stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode, - char** options, int* file_format, int* ret, - char** redirected_url) { +static stream_t *open_stream_plugin(const stream_info_t *sinfo, char *filename, + int mode, struct MPOpts *options, + int *file_format, int *ret, + char **redirected_url) +{ void* arg = NULL; stream_t* s; m_struct_t* desc = (m_struct_t*)sinfo->opts; @@ -138,18 +142,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode, return NULL; } } - if(options) { - int i; - for(i = 0 ; options[i] != NULL ; i += 2) { - mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n", - options[i],options[i+1]); - if(!m_struct_set(desc,arg,options[i],options[i+1])) - mp_msg(MSGT_OPEN,MSGL_WARN, "Failed to set stream option %s=%s\n", - options[i],options[i+1]); - } - } } s = new_stream(-2,-2); + s->opts = options; s->url=strdup(filename); s->flags |= mode; *ret = sinfo->open(s,mode,arg,file_format); @@ -186,7 +181,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode, } -stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format) { +stream_t *open_stream_full(char *filename,int mode, struct MPOpts *options, + int* file_format) +{ int i,j,l,r; const stream_info_t* sinfo; stream_t* s; @@ -228,7 +225,8 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo return NULL; } -stream_t* open_output_stream(char* filename,char** options) { +stream_t *open_output_stream(char *filename, struct MPOpts *options) +{ int file_format; //unused if(!filename) { mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n"); @@ -460,11 +458,14 @@ stream_t* new_ds_stream(demux_stream_t *ds) { return s; } -void stream_set_interrupt_callback(int (*cb)(int)) { +void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int), + struct input_ctx *ctx) +{ stream_check_interrupt_cb = cb; + stream_check_interrupt_ctx = ctx; } int stream_check_interrupt(int time) { if(!stream_check_interrupt_cb) return 0; - return stream_check_interrupt_cb(time); + return stream_check_interrupt_cb(stream_check_interrupt_ctx, time); } diff --git a/stream/stream.h b/stream/stream.h index 686288071f..87cda3637a 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -70,7 +70,7 @@ #include "network.h" #endif -struct stream_st; +struct stream; typedef struct stream_info_st { const char *info; const char *name; @@ -79,7 +79,7 @@ typedef struct stream_info_st { /// mode isn't used atm (ie always READ) but it shouldn't be ignored /// opts is at least in it's defaults settings and may have been /// altered by url parsing if enabled and the options string parsing. - int (*open)(struct stream_st* st, int mode, void* opts, int* file_format); + int (*open)(struct stream* st, int mode, void* opts, int* file_format); const char* protocols[MAX_STREAM_PROTOCOLS]; const void* opts; int opts_url; /* If this is 1 we will parse the url as an option string @@ -87,19 +87,19 @@ typedef struct stream_info_st { * options string given to open_stream_plugin */ } stream_info_t; -typedef struct stream_st { +typedef struct stream { // Read - int (*fill_buffer)(struct stream_st *s, char* buffer, int max_len); + int (*fill_buffer)(struct stream *s, char* buffer, int max_len); // Write - int (*write_buffer)(struct stream_st *s, char* buffer, int len); + int (*write_buffer)(struct stream *s, char* buffer, int len); // Seek - int (*seek)(struct stream_st *s,off_t pos); + int (*seek)(struct stream *s,off_t pos); // Control // Will be later used to let streams like dvd and cdda report // their structure (ie tracks, chapters, etc) - int (*control)(struct stream_st *s,int cmd,void* arg); + int (*control)(struct stream *s,int cmd,void* arg); // Close - void (*close)(struct stream_st *s); + void (*close)(struct stream *s); int fd; // file descriptor, see man open(2) int type; // see STREAMTYPE_* @@ -113,20 +113,21 @@ typedef struct stream_st { void* cache_data; void* priv; // used for DVD, TV, RTSP etc char* url; // strdup() of filename/url + struct MPOpts *opts; #ifdef CONFIG_NETWORK streaming_ctrl_t *streaming_ctrl; #endif unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE]; } stream_t; +int stream_fill_buffer(stream_t *s); +int stream_seek_long(stream_t *s,off_t pos); #ifdef CONFIG_STREAM_CACHE int stream_enable_cache(stream_t *stream,int size,int min,int prefill); int cache_stream_fill_buffer(stream_t *s); int cache_stream_seek_long(stream_t *s,off_t pos); #else // no cache, define wrappers: -int stream_fill_buffer(stream_t *s); -int stream_seek_long(stream_t *s,off_t pos); #define cache_stream_fill_buffer(x) stream_fill_buffer(x) #define cache_stream_seek_long(x,y) stream_seek_long(x,y) #define stream_enable_cache(x,y,z,w) 1 @@ -289,17 +290,20 @@ inline static int stream_skip(stream_t *s,off_t len){ return 1; } +struct MPOpts; void stream_reset(stream_t *s); int stream_control(stream_t *s, int cmd, void *arg); stream_t* new_stream(int fd,int type); void free_stream(stream_t *s); stream_t* new_memory_stream(unsigned char* data,int len); -stream_t* open_stream(char* filename,char** options,int* file_format); -stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format); -stream_t* open_output_stream(char* filename,char** options); +stream_t* open_stream(char* filename, struct MPOpts *options,int* file_format); +stream_t* open_stream_full(char* filename,int mode, struct MPOpts *options, int* file_format); +stream_t* open_output_stream(char* filename,struct MPOpts *options); /// Set the callback to be used by libstream to check for user /// interruption during long blocking operations (cache filling, etc). -void stream_set_interrupt_callback(int (*cb)(int)); +struct input_ctx; +void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int), + struct input_ctx *ctx); /// Call the interrupt checking callback if there is one. int stream_check_interrupt(int time); diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index ae07239ad5..05f9c411ab 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -324,7 +324,7 @@ static int dvd_next_cell(dvd_priv_t *d) { return next_cell; } -int dvd_read_sector(dvd_priv_t *d,unsigned char* data) { +static int dvd_read_sector(dvd_priv_t *d,unsigned char* data) { int len; if(d->packs_left==0) { @@ -444,7 +444,7 @@ read_next: return d->cur_pack-1; } -void dvd_seek(dvd_priv_t *d,int pos) { +static void dvd_seek(dvd_priv_t *d,int pos) { d->packs_left=-1; d->cur_pack=pos; @@ -482,7 +482,7 @@ void dvd_seek(dvd_priv_t *d,int pos) { d->angle_seek=1; } -void dvd_close(dvd_priv_t *d) { +static void dvd_close(dvd_priv_t *d) { ifoClose(d->vts_file); ifoClose(d->vmg_file); DVDCloseFile(d->title); diff --git a/stream/stream_netstream.c b/stream/stream_netstream.c index 84e10a2c81..5c68defe73 100644 --- a/stream/stream_netstream.c +++ b/stream/stream_netstream.c @@ -201,7 +201,7 @@ static int seek(stream_t *s,off_t newpos) { return 1; } -static int net_stream_reset(struct stream_st *s) { +static int net_stream_reset(struct stream *s) { mp_net_stream_packet_t* pack; pack = send_net_stream_cmd(s,NET_STREAM_RESET,NULL,0); @@ -212,7 +212,7 @@ static int net_stream_reset(struct stream_st *s) { return 1; } -static int control(struct stream_st *s,int cmd,void* arg) { +static int control(struct stream *s,int cmd,void* arg) { switch(cmd) { case STREAM_CTRL_RESET: return net_stream_reset(s); @@ -220,7 +220,7 @@ static int control(struct stream_st *s,int cmd,void* arg) { return STREAM_UNSUPPORTED; } -static void close_s(struct stream_st *s) { +static void close_s(struct stream *s) { mp_net_stream_packet_t* pack; pack = send_net_stream_cmd(s,NET_STREAM_CLOSE,NULL,0); diff --git a/stream/stream_radio.c b/stream/stream_radio.c index 9792fb142c..f0b9745a5f 100644 --- a/stream/stream_radio.c +++ b/stream/stream_radio.c @@ -155,7 +155,7 @@ static const struct m_struct_st stream_opts = { stream_opts_fields }; -static void close_s(struct stream_st * stream); +static void close_s(struct stream *stream); #ifdef CONFIG_RADIO_CAPTURE static int clear_buffer(radio_priv_t* priv); #endif @@ -900,7 +900,7 @@ static int init_audio(radio_priv_t *priv) * \parameter frequency pointer to float, which will contain frequency in MHz * \return 1 if success,0 - otherwise */ -int radio_get_freq(struct stream_st *stream, float* frequency){ +int radio_get_freq(struct stream *stream, float *frequency){ radio_priv_t* priv=(radio_priv_t*)stream->priv; if (!frequency) @@ -915,7 +915,7 @@ int radio_get_freq(struct stream_st *stream, float* frequency){ * \parameter frequency frequency in MHz * \return 1 if success,0 - otherwise */ -int radio_set_freq(struct stream_st *stream, float frequency){ +int radio_set_freq(struct stream *stream, float frequency){ radio_priv_t* priv=(radio_priv_t*)stream->priv; if (set_frequency(priv,frequency)!=STREAM_OK){ @@ -934,7 +934,7 @@ int radio_set_freq(struct stream_st *stream, float frequency){ * \return 1 if success,0 - otherwise * */ -int radio_step_freq(struct stream_st *stream, float step_interval){ +int radio_step_freq(struct stream *stream, float step_interval){ float frequency; radio_priv_t* priv=(radio_priv_t*)stream->priv; @@ -957,7 +957,7 @@ int radio_step_freq(struct stream_st *stream, float step_interval){ * if channel parameter is NULL function prints error message and does nothing, otherwise * changes channel to prev or next in list */ -int radio_step_channel(struct stream_st *stream, int direction) { +int radio_step_channel(struct stream *stream, int direction) { radio_priv_t* priv=(radio_priv_t*)stream->priv; if (priv->radio_channel_list) { @@ -999,7 +999,7 @@ int radio_step_channel(struct stream_st *stream, int direction) { * if channel parameter is NULL function prints error message and does nothing, otherwise * changes channel to given */ -int radio_set_channel(struct stream_st *stream, char *channel) { +int radio_set_channel(struct stream *stream, char *channel) { radio_priv_t* priv=(radio_priv_t*)stream->priv; int i, channel_int; radio_channels_t* tmp; @@ -1047,7 +1047,7 @@ int radio_set_channel(struct stream_st *stream, char *channel) { * * NOTE: return value may be NULL (e.g. when channel list not initialized) */ -char* radio_get_channel_name(struct stream_st *stream){ +char* radio_get_channel_name(struct stream *stream){ radio_priv_t* priv=(radio_priv_t*)stream->priv; if (priv->radio_channel_current) { return priv->radio_channel_current->name; @@ -1059,7 +1059,7 @@ char* radio_get_channel_name(struct stream_st *stream){ * \brief fills given buffer with audio data * \return number of bytes, written into buffer */ -static int fill_buffer_s(struct stream_st *s, char* buffer, int max_len){ +static int fill_buffer_s(struct stream *s, char *buffer, int max_len){ int len=max_len; #ifdef CONFIG_RADIO_CAPTURE @@ -1220,7 +1220,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { /***************************************************************** * Close stream. Clear structures. */ -static void close_s(struct stream_st * stream){ +static void close_s(struct stream *stream){ radio_priv_t* priv=(radio_priv_t*)stream->priv; radio_channels_t * tmp; if (!priv) return; diff --git a/stream/stream_radio.h b/stream/stream_radio.h index e77f4aa05e..69066970e3 100644 --- a/stream/stream_radio.h +++ b/stream/stream_radio.h @@ -36,11 +36,11 @@ typedef struct radio_param_s{ extern radio_param_t stream_radio_defaults; -int radio_set_freq(struct stream_st *stream, float freq); -int radio_get_freq(struct stream_st *stream, float* freq); -char* radio_get_channel_name(struct stream_st *stream); -int radio_set_channel(struct stream_st *stream, char *channel); -int radio_step_channel(struct stream_st *stream, int direction); -int radio_step_freq(struct stream_st *stream, float step_interval); +int radio_set_freq(struct stream *stream, float freq); +int radio_get_freq(struct stream *stream, float* freq); +char* radio_get_channel_name(struct stream *stream); +int radio_set_channel(struct stream *stream, char *channel); +int radio_step_channel(struct stream *stream, int direction); +int radio_step_freq(struct stream *stream, float step_interval); #endif /* MPLAYER_STREAM_RADIO_H */ diff --git a/stream/stream_rtsp.c b/stream/stream_rtsp.c index c45f3aad86..1edc172549 100644 --- a/stream/stream_rtsp.c +++ b/stream/stream_rtsp.c @@ -130,7 +130,7 @@ rtsp_streaming_start (stream_t *stream) } static void -rtsp_streaming_close (struct stream_st *s) +rtsp_streaming_close (struct stream *s) { rtsp_session_t *rtsp = NULL; diff --git a/stream/stream_vstream.c b/stream/stream_vstream.c index 4d0d972ebf..adc8d89d1d 100644 --- a/stream/stream_vstream.c +++ b/stream/stream_vstream.c @@ -95,11 +95,11 @@ static int seek(stream_t *s,off_t newpos) { return 1; } -static int control(struct stream_st *s,int cmd,void* arg) { +static int control(struct stream *s,int cmd,void *arg) { return STREAM_UNSUPPORTED; } -static void close_s(struct stream_st *s) { +static void close_s(struct stream *s) { } static int open_s(stream_t *stream, int mode, void* opts, int* file_format) { diff --git a/stream/tv.c b/stream/tv.c index 58321d5302..641737a9f1 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -337,7 +337,7 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm) return 1; } -int tv_set_norm_i(tvi_handle_t *tvh, int norm) +static int tv_set_norm_i(tvi_handle_t *tvh, int norm) { tvh->norm = norm; |