- Versions defined for libav/libavcodec.
[libav.git] / libav / avformat.h
1
2 #define LIBAV_VERSION_INT 0x000406
3 #define LIBAV_VERSION "0.4.6"
4 #define LIBAV_BUILD 4600
5
6 #include "avcodec.h"
7
8 #include "avio.h"
9
10 /* packet functions */
11
12 typedef struct AVPacket {
13 INT64 pts;
14 UINT8 *data;
15 int size;
16 int stream_index;
17 int flags;
18 #define PKT_FLAG_KEY 0x0001
19 #define PKT_FLAG_DROPPED_FRAME 0x0002
20 } AVPacket;
21
22 int av_new_packet(AVPacket *pkt, int size);
23 void av_free_packet(AVPacket *pkt);
24
25 /*************************************************/
26 /* output formats */
27
28 struct AVFormatContext;
29 struct AVFormatInputContext;
30
31 typedef struct AVFormatParameters {
32 int frame_rate;
33 int sample_rate;
34 int channels;
35 int width;
36 int height;
37 enum PixelFormat pix_fmt;
38 } AVFormatParameters;
39
40 typedef struct AVFormat {
41 const char *name;
42 const char *long_name;
43 const char *mime_type;
44 const char *extensions; /* comma separated extensions */
45
46 /* output support */
47 enum CodecID audio_codec; /* default audio codec */
48 enum CodecID video_codec; /* default video codec */
49 int (*write_header)(struct AVFormatContext *);
50 int (*write_packet)(struct AVFormatContext *,
51 int stream_index,
52 unsigned char *buf, int size, int force_pts);
53 int (*write_trailer)(struct AVFormatContext *);
54
55 /* optional input support */
56 /* read the format header and initialize the AVFormatInputContext
57 structure. Return 0 if OK. 'ap' if non NULL contains
58 additionnal paramters. Only used in raw format right now */
59 int (*read_header)(struct AVFormatContext *,
60 AVFormatParameters *ap);
61 /* read one packet and put it in 'pkt'. pts and flags are also set */
62 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
63 /* close the stream. The AVFormatContext and AVStreams are not
64 freed by this function */
65 int (*read_close)(struct AVFormatContext *);
66 /* seek at or before a given pts (given in microsecond). The pts
67 origin is defined by the stream */
68 int (*read_seek)(struct AVFormatContext *, INT64 pts);
69 int flags;
70 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
71 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
72 struct AVFormat *next;
73 } AVFormat;
74
75 typedef struct AVStream {
76 int id; /* internal stream id */
77 AVCodecContext codec; /* codec context */
78 void *priv_data;
79 } AVStream;
80
81 #define MAX_STREAMS 20
82
83 /* format I/O context */
84 typedef struct AVFormatContext {
85 struct AVFormat *format;
86 void *priv_data;
87 ByteIOContext pb;
88 int nb_streams;
89 AVStream *streams[MAX_STREAMS];
90 char filename[1024]; /* input or output filename */
91 /* stream info */
92 char title[512];
93 char author[512];
94 char copyright[512];
95 char comment[512];
96 /* This buffer is only needed when packets were already buffered but
97 not decoded, for example to get the codec parameters in mpeg
98 streams */
99 struct AVPacketList *packet_buffer;
100 } AVFormatContext;
101
102 typedef struct AVPacketList {
103 AVPacket pkt;
104 struct AVPacketList *next;
105 } AVPacketList;
106
107 extern AVFormat *first_format;
108
109 /* rv10enc.c */
110 extern AVFormat rm_format;
111
112 /* mpegmux.c */
113 extern AVFormat mpeg_mux_format;
114
115 /* asfenc.c */
116 extern AVFormat asf_format;
117
118 /* avienc.c */
119 extern AVFormat avi_format;
120
121 /* mov.c */
122 extern AVFormat mov_format;
123 extern AVFormat mp4_format;
124
125 /* jpegenc.c */
126 extern AVFormat mpjpeg_format;
127 extern AVFormat jpeg_format;
128 extern AVFormat single_jpeg_format;
129
130 /* swfenc.c */
131 extern AVFormat swf_format;
132
133 /* gif.c */
134 extern AVFormat gif_format;
135 /* au.c */
136 extern AVFormat au_format;
137
138 /* wav.c */
139 extern AVFormat wav_format;
140
141 /* img.c */
142 extern AVFormat pgm_format;
143 extern AVFormat ppm_format;
144 extern AVFormat pgmyuv_format;
145 extern AVFormat imgyuv_format;
146
147 extern AVFormat pgmpipe_format;
148 extern AVFormat pgmyuvpipe_format;
149 extern AVFormat ppmpipe_format;
150
151 /* raw.c */
152 extern AVFormat mp2_format;
153 extern AVFormat ac3_format;
154 extern AVFormat h263_format;
155 extern AVFormat mpeg1video_format;
156 extern AVFormat mjpeg_format;
157 extern AVFormat pcm_s16le_format;
158 extern AVFormat pcm_s16be_format;
159 extern AVFormat pcm_u16le_format;
160 extern AVFormat pcm_u16be_format;
161 extern AVFormat pcm_s8_format;
162 extern AVFormat pcm_u8_format;
163 extern AVFormat pcm_mulaw_format;
164 extern AVFormat pcm_alaw_format;
165 extern AVFormat rawvideo_format;
166
167 /* ffm.c */
168 extern AVFormat ffm_format;
169
170 /* formats.c */
171
172 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
173 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
174
175 void register_avformat(AVFormat *format);
176 AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
177
178 int strstart(const char *str, const char *val, const char **ptr);
179 void nstrcpy(char *buf, int buf_size, const char *str);
180 int match_ext(const char *filename, const char *extensions);
181
182 void register_all(void);
183
184 INT64 gettime(void);
185
186 typedef struct FifoBuffer {
187 UINT8 *buffer;
188 UINT8 *rptr, *wptr, *end;
189 } FifoBuffer;
190
191 int fifo_init(FifoBuffer *f, int size);
192 void fifo_free(FifoBuffer *f);
193 int fifo_size(FifoBuffer *f, UINT8 *rptr);
194 int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
195 void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
196
197 AVFormatContext *av_open_input_file(const char *filename,
198 const char *format_name,
199 int buf_size,
200 AVFormatParameters *ap);
201 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
202 void av_close_input_file(AVFormatContext *s);
203
204 int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
205
206 void dump_format(AVFormatContext *ic,
207 int index,
208 const char *url,
209 int is_output);
210 int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
211 INT64 gettime(void);
212 INT64 parse_date(const char *datestr, int duration);
213
214 /* ffm specific for ffserver */
215 #define FFM_PACKET_SIZE 4096
216 offset_t ffm_read_write_index(int fd);
217 void ffm_write_write_index(int fd, offset_t pos);
218 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
219
220 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
221
222 int get_frame_filename(char *buf, int buf_size,
223 const char *path, int number);
224
225 /* grab/output specific */
226 extern AVFormat video_grab_device_format;
227 extern AVFormat audio_device_format;
228
229 extern const char *v4l_device;
230 extern const char *audio_device;