Add osd_show_progression: Show progress bar and elapsed/total time.
[mplayer/greg.git] / libmpdemux / muxer.h
blob48b132b85fbd59d04eb2a2da38f90182ce9d9f0d
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_MUXER_H
20 #define MPLAYER_MUXER_H
22 #include <stdint.h>
23 #include <sys/types.h>
24 #include "aviheader.h"
25 #include "ms_hdr.h"
26 #include "stream/stream.h"
28 #define MUXER_MAX_STREAMS 16
30 #define MUXER_TYPE_VIDEO 0
31 #define MUXER_TYPE_AUDIO 1
33 #define MUXER_TYPE_AVI 0
34 #define MUXER_TYPE_MPEG 1
35 #define MUXER_TYPE_RAWVIDEO 2
36 #define MUXER_TYPE_LAVF 3
37 #define MUXER_TYPE_RAWAUDIO 4
40 typedef struct {
41 // muxer data:
42 int type; // audio or video
43 int id; // stream no
44 uint32_t ckid; // chunk id (00dc 01wb etc)
45 double timer;
46 off_t size;
47 float aspect; // aspect ratio of this stream (set by ve_*.c)
48 // buffering:
49 unsigned char *buffer;
50 unsigned int buffer_size;
51 unsigned int buffer_len;
52 // mpeg block buffer:
53 unsigned char *b_buffer;
54 unsigned int b_buffer_size; //size of b_buffer
55 unsigned int b_buffer_ptr; //index to next data to write
56 unsigned int b_buffer_len; //len of next data to write
57 // muxer frame buffer:
58 unsigned int muxbuf_seen;
59 // source stream:
60 void* source; // sh_audio or sh_video
61 int codec; // codec used for encoding. 0 means copy
62 // avi stream header:
63 AVIStreamHeader h; // Rate/Scale and SampleSize must be filled by caller!
64 // stream specific:
65 WAVEFORMATEX *wf;
66 BITMAPINFOHEADER *bih; // in format
67 int encoder_delay; // in number of frames
68 int decoder_delay; // in number of frames
69 int imgfmt;
70 // mpeg specific:
71 size_t ipb[3]; // sizes of I/P/B frames
72 // muxer of that stream
73 struct muxer_t *muxer;
74 void *priv; // private stream specific data stored by the muxer
76 int vbv_size;
77 int max_rate;
78 int avg_rate;
79 } muxer_stream_t;
81 typedef struct {
82 uint32_t id;
83 char *text;
84 } muxer_info_t;
86 typedef struct muxer_t{
87 // encoding:
88 MainAVIHeader avih;
89 off_t movi_start;
90 off_t movi_end;
91 off_t file_end; // for MPEG it's system timestamp in 1/90000 s
92 float audio_delay_fix;
93 // index:
94 AVIINDEXENTRY *idx;
95 int idx_pos;
96 int idx_size;
97 // streams:
98 int num_videos; // for MPEG recalculations
99 int num_audios;
100 unsigned int sysrate; // max rate in bytes/s
101 //int num_streams;
102 muxer_stream_t* def_v; // default video stream (for general headers)
103 muxer_stream_t* streams[MUXER_MAX_STREAMS];
104 // muxer frame buffer:
105 struct muxbuf_t * muxbuf;
106 int muxbuf_num;
107 int muxbuf_skip_buffer;
108 // functions:
109 stream_t *stream;
110 void (*fix_stream_parameters)(muxer_stream_t *);
111 void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
112 void (*cont_write_header)(struct muxer_t *);
113 void (*cont_write_index)(struct muxer_t *);
114 muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
115 void *priv;
116 } muxer_t;
118 /* muxer frame buffer */
119 typedef struct muxbuf_t {
120 muxer_stream_t *stream; /* pointer back to corresponding stream */
121 double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
122 double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
123 unsigned char *buffer;
124 size_t len;
125 unsigned int flags;
126 } muxbuf_t;
128 extern char *force_fourcc;
130 muxer_t *muxer_new_muxer(int type,stream_t *stream);
131 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
132 #define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
133 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
134 #define muxer_write_header(muxer) muxer->cont_write_header(muxer)
135 #define muxer_write_index(muxer) muxer->cont_write_index(muxer)
137 int muxer_init_muxer_avi(muxer_t *);
138 int muxer_init_muxer_mpeg(muxer_t *);
139 int muxer_init_muxer_rawvideo(muxer_t *);
140 int muxer_init_muxer_lavf(muxer_t *);
141 int muxer_init_muxer_rawaudio(muxer_t *);
143 #endif /* MPLAYER_MUXER_H */