summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-18 20:56:24 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-18 20:56:24 +0000
commitac9465059730747f59b07ad00b5daebbbece8c9f (patch)
tree5f457a8d1fe7747ce6e83c4a3c0cf9de5c83fcd9 /stream/stream.c
parentfc2b02cf7eae734aa9892983a75bdd2f903ceb80 (diff)
downloadmpv-ac9465059730747f59b07ad00b5daebbbece8c9f.tar.bz2
mpv-ac9465059730747f59b07ad00b5daebbbece8c9f.tar.xz
support functions for writing to streams
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21675 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 7b4a108b89..2a8338ddb9 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -189,6 +189,7 @@ stream_t* open_stream_plugin(stream_info_t* sinfo,char* filename,int mode,
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 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
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 @@ int stream_fill_buffer(stream_t *s){
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 @@ off_t newpos=0;
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