comparison libmpdemux/muxer_lavf.c @ 21660:ca9da45d13e9

muxers now write to output muxer->stream rather than to muxer->file
author nicodvb
date Mon, 18 Dec 2006 21:03:59 +0000
parents 1767c271d710
children 4f317822d1fc
comparison
equal deleted inserted replaced
21659:da09e69a0f01 21660:ca9da45d13e9
10 #include "help_mp.h" 10 #include "help_mp.h"
11 11
12 #include "aviheader.h" 12 #include "aviheader.h"
13 #include "ms_hdr.h" 13 #include "ms_hdr.h"
14 14
15 #include "stream.h"
15 #include "muxer.h" 16 #include "muxer.h"
16 #include "stream.h"
17 #include "demuxer.h" 17 #include "demuxer.h"
18 #include "stheader.h" 18 #include "stheader.h"
19 #include "m_option.h" 19 #include "m_option.h"
20 #ifdef USE_LIBAVFORMAT_SO 20 #ifdef USE_LIBAVFORMAT_SO
21 #include <ffmpeg/avformat.h> 21 #include <ffmpeg/avformat.h>
87 } 87 }
88 88
89 static int mp_write(URLContext *h, unsigned char *buf, int size) 89 static int mp_write(URLContext *h, unsigned char *buf, int size)
90 { 90 {
91 muxer_t *muxer = (muxer_t*)h->priv_data; 91 muxer_t *muxer = (muxer_t*)h->priv_data;
92 return fwrite(buf, 1, size, muxer->file); 92 return stream_write_buffer(muxer->stream, buf, size);
93 } 93 }
94 94
95 static offset_t mp_seek(URLContext *h, offset_t pos, int whence) 95 static offset_t mp_seek(URLContext *h, offset_t pos, int whence)
96 { 96 {
97 muxer_t *muxer = (muxer_t*)h->priv_data; 97 muxer_t *muxer = (muxer_t*)h->priv_data;
98 if(whence == SEEK_CUR)
99 {
100 off_t cur = stream_tell(muxer->stream);
101 if(cur == -1)
102 return -1;
103 pos += cur;
104 }
105 else if(whence == SEEK_END)
106 {
107 off_t size=0;
108 if(stream_control(muxer->stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_UNSUPORTED || size < pos)
109 return -1;
110 pos = size - pos;
111 }
98 mp_msg(MSGT_MUXER, MSGL_DBG2, "SEEK %"PRIu64"\n", (int64_t)pos); 112 mp_msg(MSGT_MUXER, MSGL_DBG2, "SEEK %"PRIu64"\n", (int64_t)pos);
99 return fseeko(muxer->file, pos, whence); 113 if(!stream_seek(muxer->stream, pos))
114 return -1;
115 return 0;
100 } 116 }
101 117
102 118
103 static URLProtocol mp_protocol = { 119 static URLProtocol mp_protocol = {
104 "menc", 120 "menc",