Mercurial > mplayer.hg
changeset 21659:da09e69a0f01
support functions for writing to streams
author | nicodvb |
---|---|
date | Mon, 18 Dec 2006 20:56:24 +0000 |
parents | 110286e8bbec |
children | ca9da45d13e9 |
files | stream/stream.c |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream.c Mon Dec 18 20:55:12 2006 +0000 +++ b/stream/stream.c Mon Dec 18 20:56:24 2006 +0000 @@ -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