mirror of
https://github.com/mpv-player/mpv
synced 2025-04-19 13:47:06 +00:00
Add option pointer to stream struct (at least temporarily)
The stream code does not access many option variables directly, but it does access some such as audio_id and network_bandwidth (and does that without including proper headers for them). Add option pointer to the stream struct to allow access to those variables. Remove the unused (always NULL) and clumsy-looking char** options parameter in the open_stream call and replace it with the option pointer. The parameter is currently only set in the main open_stream() call in MPlayer.c and not in any other locations that can open a stream. In the long term it might be better to pass a more limited set of values somehow, but this should do for now.
This commit is contained in:
parent
9e7dfe3fa3
commit
f518cf7ea9
@ -3150,7 +3150,7 @@ if (edl_output_filename) {
|
|||||||
mpctx->sh_video=NULL;
|
mpctx->sh_video=NULL;
|
||||||
|
|
||||||
current_module="open_stream";
|
current_module="open_stream";
|
||||||
mpctx->stream=open_stream(filename,0,&mpctx->file_format);
|
mpctx->stream = open_stream(filename, opts, &mpctx->file_format);
|
||||||
if(!mpctx->stream) { // error...
|
if(!mpctx->stream) { // error...
|
||||||
mpctx->eof = libmpdemux_was_interrupted(mpctx, PT_NEXT_ENTRY);
|
mpctx->eof = libmpdemux_was_interrupted(mpctx, PT_NEXT_ENTRY);
|
||||||
goto goto_next_file;
|
goto goto_next_file;
|
||||||
|
@ -30,7 +30,8 @@ int dvd_title=0;
|
|||||||
|
|
||||||
// Open a new stream (stdin/file/vcd/url)
|
// 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
|
// Check if playlist or unknown
|
||||||
if (*file_format != DEMUXER_TYPE_PLAYLIST){
|
if (*file_format != DEMUXER_TYPE_PLAYLIST){
|
||||||
*file_format=DEMUXER_TYPE_UNKNOWN;
|
*file_format=DEMUXER_TYPE_UNKNOWN;
|
||||||
|
@ -121,9 +121,11 @@ static const stream_info_t* const auto_open_streams[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode,
|
static stream_t *open_stream_plugin(const stream_info_t *sinfo, char *filename,
|
||||||
char** options, int* file_format, int* ret,
|
int mode, struct MPOpts *options,
|
||||||
char** redirected_url) {
|
int *file_format, int *ret,
|
||||||
|
char **redirected_url)
|
||||||
|
{
|
||||||
void* arg = NULL;
|
void* arg = NULL;
|
||||||
stream_t* s;
|
stream_t* s;
|
||||||
m_struct_t* desc = (m_struct_t*)sinfo->opts;
|
m_struct_t* desc = (m_struct_t*)sinfo->opts;
|
||||||
@ -140,18 +142,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,in
|
|||||||
return NULL;
|
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 = new_stream(-2,-2);
|
||||||
|
s->opts = options;
|
||||||
s->url=strdup(filename);
|
s->url=strdup(filename);
|
||||||
s->flags |= mode;
|
s->flags |= mode;
|
||||||
*ret = sinfo->open(s,mode,arg,file_format);
|
*ret = sinfo->open(s,mode,arg,file_format);
|
||||||
@ -188,7 +181,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
int i,j,l,r;
|
||||||
const stream_info_t* sinfo;
|
const stream_info_t* sinfo;
|
||||||
stream_t* s;
|
stream_t* s;
|
||||||
@ -230,7 +225,8 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
|
|||||||
return NULL;
|
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
|
int file_format; //unused
|
||||||
if(!filename) {
|
if(!filename) {
|
||||||
mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n");
|
mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n");
|
||||||
|
@ -112,6 +112,7 @@ typedef struct stream_st {
|
|||||||
void* cache_data;
|
void* cache_data;
|
||||||
void* priv; // used for DVD, TV, RTSP etc
|
void* priv; // used for DVD, TV, RTSP etc
|
||||||
char* url; // strdup() of filename/url
|
char* url; // strdup() of filename/url
|
||||||
|
struct MPOpts *opts;
|
||||||
#ifdef MPLAYER_NETWORK
|
#ifdef MPLAYER_NETWORK
|
||||||
streaming_ctrl_t *streaming_ctrl;
|
streaming_ctrl_t *streaming_ctrl;
|
||||||
#endif
|
#endif
|
||||||
@ -288,14 +289,15 @@ inline static int stream_skip(stream_t *s,off_t len){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MPOpts;
|
||||||
void stream_reset(stream_t *s);
|
void stream_reset(stream_t *s);
|
||||||
int stream_control(stream_t *s, int cmd, void *arg);
|
int stream_control(stream_t *s, int cmd, void *arg);
|
||||||
stream_t* new_stream(int fd,int type);
|
stream_t* new_stream(int fd,int type);
|
||||||
void free_stream(stream_t *s);
|
void free_stream(stream_t *s);
|
||||||
stream_t* new_memory_stream(unsigned char* data,int len);
|
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(char* filename, struct MPOpts *options,int* file_format);
|
||||||
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);
|
||||||
stream_t* open_output_stream(char* filename,char** options);
|
stream_t* open_output_stream(char* filename,struct MPOpts *options);
|
||||||
/// Set the callback to be used by libstream to check for user
|
/// Set the callback to be used by libstream to check for user
|
||||||
/// interruption during long blocking operations (cache filling, etc).
|
/// interruption during long blocking operations (cache filling, etc).
|
||||||
void stream_set_interrupt_callback(int (*cb)(int));
|
void stream_set_interrupt_callback(int (*cb)(int));
|
||||||
|
Loading…
Reference in New Issue
Block a user