support functions for writing to streams

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21675 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nicodvb 2006-12-18 20:56:24 +00:00
parent fc2b02cf7e
commit ac94650597
1 changed files with 28 additions and 0 deletions

View File

@ -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