diff options
Diffstat (limited to 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/stream/stream.c b/stream/stream.c index d4abc69343..80e37369f7 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -36,19 +36,20 @@ #endif #include "mp_msg.h" -#include "help_mp.h" #include "osdep/shmem.h" #include "network.h" #include "stream.h" #include "libmpdemux/demuxer.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "m_option.h" #include "m_struct.h" #include "cache2.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; @@ -139,9 +140,11 @@ static const stream_info_t* const auto_open_streams[] = { NULL }; -static stream_t* open_stream_plugin(const stream_info_t* sinfo, const 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, + const char *filename, + int mode, struct MPOpts *options, + int *file_format, int *ret, + char **redirected_url) { void* arg = NULL; stream_t* s; @@ -159,18 +162,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* file 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); @@ -207,7 +201,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* file } -stream_t* open_stream_full(const char* filename,int mode, char** options, int* file_format) { +stream_t *open_stream_full(const char *filename, int mode, + struct MPOpts *options, int *file_format) +{ int i,j,l,r; const stream_info_t* sinfo; stream_t* s; @@ -237,7 +233,7 @@ stream_t* open_stream_full(const char* filename,int mode, char** options, int* f return s; } else if(r != STREAM_UNSUPPORTED) { - mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,filename); + mp_tmsg(MSGT_OPEN,MSGL_ERR, "Failed to open %s.\n",filename); return NULL; } break; @@ -249,7 +245,8 @@ stream_t* open_stream_full(const char* filename,int mode, char** options, int* f return NULL; } -stream_t* open_output_stream(const char* filename, char** options) { +stream_t *open_output_stream(const 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"); @@ -374,18 +371,22 @@ if(newpos==0 || newpos!=s->pos){ // putchar('%');fflush(stdout); } -while(stream_fill_buffer(s) > 0 && pos >= 0) { +s->eof = 0; // EOF reset when seek succeeds. +while (stream_fill_buffer(s) > 0) { if(pos<=s->buf_len){ s->buf_pos=pos; // byte position in sector return 1; } pos -= s->buf_len; } - -// if(pos==s->buf_len) printf("XXX Seek to last byte of file -> EOF\n"); - - mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%"PRIX64" !\n",(int64_t)(pos+newpos)); - return 0; +// Fill failed, but seek still is a success. +s->pos += pos; +s->buf_pos = 0; +s->buf_len = 0; + +mp_msg(MSGT_STREAM,MSGL_V, + "stream_seek: Seek to/past EOF: no buffer preloaded.\n"); +return 1; } @@ -478,13 +479,16 @@ 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); } /** |