# HG changeset patch # User rtognimp # Date 1079194202 0 # Node ID 2c2fb445798254cca14c378ae28e31acce66c761 # Parent 21e5cb258a959ca371d3f12808400b5c6f33dc11 Seek in HTTP streams and stdin seek fixes Patch by eviv bulgroz diff -r 21e5cb258a95 -r 2c2fb4457982 libmpdemux/demux_avi.c --- a/libmpdemux/demux_avi.c Thu Mar 11 17:58:11 2004 +0000 +++ b/libmpdemux/demux_avi.c Sat Mar 13 16:10:02 2004 +0000 @@ -449,7 +449,7 @@ demuxer->priv=(void*)priv; //---- AVI header: - read_avi_header(demuxer,(demuxer->stream->flags & STREAM_SEEK)?index_mode:-2); + read_avi_header(demuxer,(demuxer->stream->flags & STREAM_SEEK_BW)?index_mode:-2); if(demuxer->audio->id>=0 && !demuxer->a_streams[demuxer->audio->id]){ mp_msg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid audio stream ID: %d - ignoring (nosound)\n",demuxer->audio->id); diff -r 21e5cb258a95 -r 2c2fb4457982 libmpdemux/network.c --- a/libmpdemux/network.c Thu Mar 11 17:58:11 2004 +0000 +++ b/libmpdemux/network.c Sat Mar 13 16:10:02 2004 +0000 @@ -754,7 +754,11 @@ streaming_ctrl->data = (void*)http_hdr; // Check if we can make partial content requests and thus seek in http-streams - seekable=(http_hdr!=NULL && http_hdr->status_code==200 && strncmp(http_get_field(http_hdr,"Accept-Ranges"),"bytes",5)==0); + if( http_hdr!=NULL && http_hdr->status_code==200 ) { + char *accept_ranges; + if( (accept_ranges = http_get_field(http_hdr,"Accept-Ranges")) != NULL ) + seekable = strncmp(accept_ranges,"bytes",5)==0; + } // Check if the response is an ICY status_code reason_phrase if( !strcasecmp(http_hdr->protocol, "ICY") ) { diff -r 21e5cb258a95 -r 2c2fb4457982 libmpdemux/stream.c --- a/libmpdemux/stream.c Thu Mar 11 17:58:11 2004 +0000 +++ b/libmpdemux/stream.c Sat Mar 13 16:10:02 2004 +0000 @@ -317,7 +317,7 @@ if(s->seek) { // new stream seek is much cleaner than streaming_ctrl one if(!s->seek(s,newpos)) { mp_msg(MSGT_STREAM,MSGL_ERR, "Seek failed\n"); - return 1; + return 0; } break; } diff -r 21e5cb258a95 -r 2c2fb4457982 libmpdemux/stream.h --- a/libmpdemux/stream.h Thu Mar 11 17:58:11 2004 +0000 +++ b/libmpdemux/stream.h Sat Mar 13 16:10:02 2004 +0000 @@ -229,7 +229,7 @@ } inline static int stream_skip(stream_t *s,off_t len){ - if(len<0 || (len>2*STREAM_BUFFER_SIZE && (s->flags & STREAM_SEEK))) { + if( (len<0 && (s->flags & STREAM_SEEK_BW)) || (len>2*STREAM_BUFFER_SIZE && (s->flags & STREAM_SEEK_FW)) ) { // negative or big skip! return stream_seek(s,stream_tell(s)+len); } diff -r 21e5cb258a95 -r 2c2fb4457982 libmpdemux/stream_file.c --- a/libmpdemux/stream_file.c Thu Mar 11 17:58:11 2004 +0000 +++ b/libmpdemux/stream_file.c Sat Mar 13 16:10:02 2004 +0000 @@ -56,7 +56,11 @@ return 0; } while(s->posfill_buffer(s,s->buffer,STREAM_BUFFER_SIZE)<=0) break; // EOF + int len=s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE); + if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; break; } // EOF + s->buf_pos=0; + s->buf_len=len; + s->pos+=len; } return 1; }