mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 12:55:16 +00:00
Seek in HTTP streams and stdin seek fixes
Patch by eviv bulgroz <ebulgroz(at)yahoo(dot)com> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12019 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
e61fb5349a
commit
2aa6acd974
@ -449,7 +449,7 @@ demuxer_t* demux_open_avi(demuxer_t* demuxer){
|
||||
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);
|
||||
|
@ -754,7 +754,11 @@ extension=NULL;
|
||||
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") ) {
|
||||
|
@ -317,7 +317,7 @@ if(newpos==0 || newpos!=s->pos){
|
||||
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;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ inline static int stream_seek(stream_t *s,off_t pos){
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -56,7 +56,11 @@ static int seek_forward(stream_t *s,off_t newpos) {
|
||||
return 0;
|
||||
}
|
||||
while(s->pos<newpos){
|
||||
if(s->fill_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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user