[MPlayer-cvslog] r21675 - trunk/stream/stream.c

nicodvb subversion at mplayerhq.hu
Mon Dec 18 21:56:24 CET 2006


Author: nicodvb
Date: Mon Dec 18 21:56:24 2006
New Revision: 21675

Modified:
   trunk/stream/stream.c

Log:
support functions for writing to streams

Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c	(original)
+++ trunk/stream/stream.c	Mon Dec 18 21:56:24 2006
@@ -189,6 +189,7 @@
   if(s->seek && !(s->flags & STREAM_SEEK))
     s->flags |= STREAM_SEEK;
   
+  s->mode = mode;
 
   mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename);
   mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info);
@@ -232,6 +233,16 @@
   return NULL;
 }
 
+stream_t* open_output_stream(char* filename,char** options) {
+  int file_format; //unused
+  if(!filename) {
+    mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n");
+    return NULL;
+  }
+
+  return open_stream_full(filename,STREAM_WRITE,options,&file_format);
+}
+
 //=================== STREAMER =========================
 
 int stream_fill_buffer(stream_t *s){
@@ -264,6 +275,17 @@
   return len;
 }
 
+int stream_write_buffer(stream_t *s, unsigned char *buf, int len) {
+  int rd;
+  if(!s->write_buffer)
+    return -1;
+  rd = s->write_buffer(s, buf, len);
+  if(rd < 0)
+    return -1;
+  s->pos += rd;
+  return rd;
+}
+
 int stream_seek_long(stream_t *s,off_t pos){
 off_t newpos=0;
 
@@ -271,6 +293,12 @@
 
   s->buf_pos=s->buf_len=0;
 
+  if(s->mode == STREAM_WRITE) {
+    if(!s->seek || !s->seek(s,pos))
+      return 0;
+    return 1;
+  }
+
   switch(s->type){
   case STREAMTYPE_STREAM:
 #ifdef _LARGEFILE_SOURCE



More information about the MPlayer-cvslog mailing list