changeset 3044:606bb6943ae9

Added a network read function call and a seek network function call.
author bertrand
date Tue, 20 Nov 2001 22:22:21 +0000
parents 02a43ca97b52
children 6c14fd789ba5
files libmpdemux/stream.c
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/stream.c	Tue Nov 20 22:21:20 2001 +0000
+++ b/libmpdemux/stream.c	Tue Nov 20 22:22:21 2001 +0000
@@ -36,7 +36,15 @@
   switch(s->type){
   case STREAMTYPE_FILE:
   case STREAMTYPE_STREAM:
+#ifdef STREAMING
+    if( s->streaming_ctrl!=NULL ) {
+	    len=s->streaming_ctrl->streaming_read(s->fd,s->buffer,STREAM_BUFFER_SIZE, s->streaming_ctrl);break;
+    } else {
+      len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
+    }
+#else
     len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
+#endif
   case STREAMTYPE_VCD:
 #ifdef VCD_CACHE
     len=vcd_cache_read(s->fd,s->buffer);break;
@@ -125,6 +133,17 @@
 #endif
   case STREAMTYPE_STREAM:
     //s->pos=newpos; // real seek
+    // Some streaming protocol allow to seek backward and forward
+    // A function call that return -1 can tell that the protocol
+    // doesn't support seeking.
+#ifdef STREAMING
+    if( s->streaming_ctrl!=NULL ) {
+      if( s->streaming_ctrl->streaming_seek( s->fd, pos, s->streaming_ctrl )<0 ) {
+        mp_msg(MSGT_STREAM,MSGL_INFO,"Stream not seekable!\n");
+        return 1;
+      }
+    } 
+#else
     if(newpos<s->pos){
       mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek backward in linear streams!\n");
       return 1;
@@ -132,6 +151,7 @@
     while(s->pos<newpos){
       if(stream_fill_buffer(s)<=0) break; // EOF
     }
+#endif
     break;
 #ifdef USE_TV
   case STREAMTYPE_TV: