changeset 12018:2c2fb4457982

Seek in HTTP streams and stdin seek fixes Patch by eviv bulgroz <ebulgroz(at)yahoo(dot)com>
author rtognimp
date Sat, 13 Mar 2004 16:10:02 +0000
parents 21e5cb258a95
children 6ede5366bc47
files libmpdemux/demux_avi.c libmpdemux/network.c libmpdemux/stream.c libmpdemux/stream.h libmpdemux/stream_file.c
diffstat 5 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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") ) {
--- 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;
     }
--- 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);
   }
--- 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->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;
 }