mf demuxer only works with mf:// urls, so check for that.
[mplayer/glamo.git] / libmpdemux / muxer.h
blobaa862f9267e2e319fc312bac0463b243e307d812
2 #define MUXER_MAX_STREAMS 16
4 #define MUXER_TYPE_VIDEO 0
5 #define MUXER_TYPE_AUDIO 1
7 #define MUXER_TYPE_AVI 0
8 #define MUXER_TYPE_MPEG 1
9 #define MUXER_TYPE_RAWVIDEO 2
10 #define MUXER_TYPE_LAVF 3
11 #define MUXER_TYPE_RAWAUDIO 4
14 typedef struct {
15 // muxer data:
16 int type; // audio or video
17 int id; // stream no
18 uint32_t ckid; // chunk id (00dc 01wb etc)
19 double timer;
20 off_t size;
21 float aspect; // aspect ratio of this stream (set by ve_*.c)
22 // buffering:
23 unsigned char *buffer;
24 unsigned int buffer_size;
25 unsigned int buffer_len;
26 // mpeg block buffer:
27 unsigned char *b_buffer;
28 unsigned int b_buffer_size; //size of b_buffer
29 unsigned int b_buffer_ptr; //index to next data to write
30 unsigned int b_buffer_len; //len of next data to write
31 // muxer frame buffer:
32 unsigned int muxbuf_seen;
33 // source stream:
34 void* source; // sh_audio or sh_video
35 int codec; // codec used for encoding. 0 means copy
36 // avi stream header:
37 AVIStreamHeader h; // Rate/Scale and SampleSize must be filled by caller!
38 // stream specific:
39 WAVEFORMATEX *wf;
40 BITMAPINFOHEADER *bih; // in format
41 int encoder_delay; // in number of frames
42 int decoder_delay; // in number of frames
43 // mpeg specific:
44 size_t ipb[3]; // sizes of I/P/B frames
45 // muxer of that stream
46 struct muxer_t *muxer;
47 void *priv; // private stream specific data stored by the muxer
49 int vbv_size;
50 int max_rate;
51 int avg_rate;
52 } muxer_stream_t;
54 typedef struct {
55 uint32_t id;
56 char *text;
57 } muxer_info_t;
59 typedef struct muxer_t{
60 // encoding:
61 MainAVIHeader avih;
62 off_t movi_start;
63 off_t movi_end;
64 off_t file_end; // for MPEG it's system timestamp in 1/90000 s
65 float audio_delay_fix;
66 // index:
67 AVIINDEXENTRY *idx;
68 int idx_pos;
69 int idx_size;
70 // streams:
71 int num_videos; // for MPEG recalculations
72 int num_audios;
73 unsigned int sysrate; // max rate in bytes/s
74 //int num_streams;
75 muxer_stream_t* def_v; // default video stream (for general headers)
76 muxer_stream_t* streams[MUXER_MAX_STREAMS];
77 // muxer frame buffer:
78 struct muxbuf_t * muxbuf;
79 int muxbuf_num;
80 int muxbuf_skip_buffer;
81 // functions:
82 stream_t *stream;
83 void (*fix_stream_parameters)(muxer_stream_t *);
84 void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
85 void (*cont_write_header)(struct muxer_t *);
86 void (*cont_write_index)(struct muxer_t *);
87 muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
88 void *priv;
89 } muxer_t;
91 /* muxer frame buffer */
92 typedef struct muxbuf_t {
93 muxer_stream_t *stream; /* pointer back to corresponding stream */
94 double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
95 double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
96 unsigned char *buffer;
97 size_t len;
98 unsigned int flags;
99 } muxbuf_t;
101 extern char *force_fourcc;
103 muxer_t *muxer_new_muxer(int type,stream_t *stream);
104 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
105 #define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
106 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
107 #define muxer_write_header(muxer) muxer->cont_write_header(muxer)
108 #define muxer_write_index(muxer) muxer->cont_write_index(muxer)
110 int muxer_init_muxer_avi(muxer_t *);
111 int muxer_init_muxer_mpeg(muxer_t *);
112 int muxer_init_muxer_rawvideo(muxer_t *);
113 int muxer_init_muxer_lavf(muxer_t *);
114 int muxer_init_muxer_rawaudio(muxer_t *);