new video grab device for ATI All-In-Wonder cards based on the GATOS km driver patch...
[libav.git] / libav / avformat.h
CommitLineData
fb025625
FB
1#ifndef AVFORMAT_H
2#define AVFORMAT_H
de6d9b64 3
94988531
FB
4#define LIBAVFORMAT_VERSION_INT 0x000406
5#define LIBAVFORMAT_VERSION "0.4.6"
2a10020b 6#define LIBAVFORMAT_BUILD 4602
4b1f4f23 7
de6d9b64
FB
8#include "avcodec.h"
9
de6d9b64
FB
10#include "avio.h"
11
12/* packet functions */
13
fb025625
FB
14#define AV_NOPTS_VALUE 0
15
de6d9b64
FB
16typedef struct AVPacket {
17 INT64 pts;
18 UINT8 *data;
19 int size;
20 int stream_index;
21 int flags;
6d9872f4 22 int duration;
de6d9b64 23#define PKT_FLAG_KEY 0x0001
4606ac8d 24#define PKT_FLAG_DROPPED_FRAME 0x0002
de6d9b64
FB
25} AVPacket;
26
27int av_new_packet(AVPacket *pkt, int size);
28void av_free_packet(AVPacket *pkt);
29
30/*************************************************/
b9a281db 31/* input/output formats */
de6d9b64
FB
32
33struct AVFormatContext;
b9a281db
FB
34
35/* this structure contains the data a format has to probe a file */
36typedef struct AVProbeData {
37 char *filename;
38 unsigned char *buf;
39 int buf_size;
40} AVProbeData;
41
42#define AVPROBE_SCORE_MAX 100
de6d9b64
FB
43
44typedef struct AVFormatParameters {
45 int frame_rate;
46 int sample_rate;
47 int channels;
48 int width;
49 int height;
4606ac8d 50 enum PixelFormat pix_fmt;
de6d9b64
FB
51} AVFormatParameters;
52
b9a281db
FB
53#define AVFMT_NOFILE 0x0001 /* no file should be opened */
54#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
55#define AVFMT_NOHEADER 0x0004 /* signal that no header is present
56 (streams are added dynamically) */
57#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
58#define AVFMT_RGB24 0x0010 /* force RGB24 output for ppm (hack
59 - need better api) */
fb025625
FB
60#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
61 raw picture data */
b9a281db
FB
62
63typedef struct AVOutputFormat {
de6d9b64
FB
64 const char *name;
65 const char *long_name;
66 const char *mime_type;
67 const char *extensions; /* comma separated extensions */
b9a281db
FB
68 /* size of private data so that it can be allocated in the wrapper */
69 int priv_data_size;
de6d9b64
FB
70 /* output support */
71 enum CodecID audio_codec; /* default audio codec */
72 enum CodecID video_codec; /* default video codec */
73 int (*write_header)(struct AVFormatContext *);
74 int (*write_packet)(struct AVFormatContext *,
75 int stream_index,
10bb7023 76 unsigned char *buf, int size, int force_pts);
de6d9b64 77 int (*write_trailer)(struct AVFormatContext *);
b9a281db
FB
78 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
79 int flags;
80 /* private fields */
81 struct AVOutputFormat *next;
82} AVOutputFormat;
de6d9b64 83
b9a281db
FB
84typedef struct AVInputFormat {
85 const char *name;
86 const char *long_name;
87 /* size of private data so that it can be allocated in the wrapper */
88 int priv_data_size;
89 /* tell if a given file has a chance of being parsing by this format */
90 int (*read_probe)(AVProbeData *);
91 /* read the format header and initialize the AVFormatContext
de6d9b64 92 structure. Return 0 if OK. 'ap' if non NULL contains
b9a281db
FB
93 additionnal paramters. Only used in raw format right
94 now. 'av_new_stream' should be called to create new streams. */
de6d9b64
FB
95 int (*read_header)(struct AVFormatContext *,
96 AVFormatParameters *ap);
b9a281db
FB
97 /* read one packet and put it in 'pkt'. pts and flags are also
98 set. 'av_new_stream' can be called only if the flag
99 AVFMT_NOHEADER is used. */
de6d9b64
FB
100 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
101 /* close the stream. The AVFormatContext and AVStreams are not
102 freed by this function */
103 int (*read_close)(struct AVFormatContext *);
104 /* seek at or before a given pts (given in microsecond). The pts
105 origin is defined by the stream */
106 int (*read_seek)(struct AVFormatContext *, INT64 pts);
b9a281db 107 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
de6d9b64 108 int flags;
b9a281db
FB
109 /* if extensions are defined, then no probe is done. You should
110 usually not use extension format guessing because it is not
111 reliable enough */
112 const char *extensions;
113 /* general purpose read only value that the format can use */
114 int value;
115 /* private fields */
116 struct AVInputFormat *next;
117} AVInputFormat;
de6d9b64
FB
118
119typedef struct AVStream {
b9a281db
FB
120 int index; /* stream index in AVFormatContext */
121 int id; /* format specific stream id */
de6d9b64 122 AVCodecContext codec; /* codec context */
76c0441b 123 int r_frame_rate; /* real frame rate of the stream */
2a10020b
ZK
124 uint64_t time_length; /* real length of the stream in miliseconds */
125 void* extra_data; /* some extra data - i.e. longer WAVEFORMATEX */
126 int extra_data_size; /* size of extra data chunk */
de6d9b64 127 void *priv_data;
b9a281db
FB
128 /* internal data used in av_find_stream_info() */
129 int codec_info_state;
130 int codec_info_nb_repeat_frames;
131 int codec_info_nb_real_frames;
a48b7a6b
FB
132 /* ffmpeg.c private use */
133 int stream_copy; /* if TRUE, just copy stream */
de6d9b64
FB
134} AVStream;
135
136#define MAX_STREAMS 20
137
138/* format I/O context */
139typedef struct AVFormatContext {
b9a281db
FB
140 /* can only be iformat or oformat, not both at the same time */
141 struct AVInputFormat *iformat;
142 struct AVOutputFormat *oformat;
de6d9b64
FB
143 void *priv_data;
144 ByteIOContext pb;
145 int nb_streams;
146 AVStream *streams[MAX_STREAMS];
147 char filename[1024]; /* input or output filename */
148 /* stream info */
149 char title[512];
150 char author[512];
151 char copyright[512];
152 char comment[512];
92b3e125 153 int flags; /* format specific flags */
de6d9b64
FB
154 /* This buffer is only needed when packets were already buffered but
155 not decoded, for example to get the codec parameters in mpeg
156 streams */
157 struct AVPacketList *packet_buffer;
158} AVFormatContext;
159
160typedef struct AVPacketList {
161 AVPacket pkt;
162 struct AVPacketList *next;
163} AVPacketList;
164
b9a281db
FB
165extern AVInputFormat *first_iformat;
166extern AVOutputFormat *first_oformat;
de6d9b64 167
b9a281db
FB
168/* XXX: use automatic init with either ELF sections or C file parser */
169/* modules */
de6d9b64 170
b9a281db 171/* mpeg.c */
b9a281db
FB
172int mpegps_init(void);
173
174/* mpegts.c */
175extern AVInputFormat mpegts_demux;
176int mpegts_init(void);
de6d9b64 177
b9a281db
FB
178/* rm.c */
179int rm_init(void);
180
181/* crc.c */
182int crc_init(void);
183
184/* img.c */
185int img_init(void);
186
187/* asf.c */
188int asf_init(void);
de6d9b64
FB
189
190/* avienc.c */
b9a281db 191int avienc_init(void);
de6d9b64 192
b9a281db
FB
193/* avidec.c */
194int avidec_init(void);
6cea494e 195
b9a281db
FB
196/* swf.c */
197int swf_init(void);
198
199/* mov.c */
200int mov_init(void);
de6d9b64 201
b9a281db
FB
202/* jpeg.c */
203int jpeg_init(void);
de6d9b64 204
6cea494e 205/* gif.c */
b9a281db
FB
206int gif_init(void);
207
6cea494e 208/* au.c */
b9a281db 209int au_init(void);
6cea494e 210
de6d9b64 211/* wav.c */
b9a281db 212int wav_init(void);
de6d9b64
FB
213
214/* raw.c */
b9a281db 215int raw_init(void);
de6d9b64 216
81e0d0b4
MH
217/* ogg.c */
218int ogg_init(void);
219
f20dca40
FB
220/* dv.c */
221int dv_init(void);
222
de6d9b64 223/* ffm.c */
b9a281db 224int ffm_init(void);
de6d9b64 225
fb025625
FB
226/* rtsp.c */
227extern AVInputFormat redir_demux;
228int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
229
230#include "rtp.h"
231
232#include "rtsp.h"
233
b9a281db 234/* utils.c */
de6d9b64
FB
235#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
236#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
237
b9a281db
FB
238void av_register_input_format(AVInputFormat *format);
239void av_register_output_format(AVOutputFormat *format);
36ada60c
PG
240AVOutputFormat *guess_stream_format(const char *short_name,
241 const char *filename, const char *mime_type);
b9a281db
FB
242AVOutputFormat *guess_format(const char *short_name,
243 const char *filename, const char *mime_type);
de6d9b64 244
b9a281db 245void av_hex_dump(UINT8 *buf, int size);
de6d9b64 246
94988531 247void av_register_all(void);
de6d9b64
FB
248
249typedef struct FifoBuffer {
250 UINT8 *buffer;
251 UINT8 *rptr, *wptr, *end;
252} FifoBuffer;
253
254int fifo_init(FifoBuffer *f, int size);
255void fifo_free(FifoBuffer *f);
256int fifo_size(FifoBuffer *f, UINT8 *rptr);
257int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
258void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
259
b9a281db
FB
260/* media file input */
261AVInputFormat *av_find_input_format(const char *short_name);
94988531 262AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
b9a281db
FB
263int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
264 AVInputFormat *fmt,
265 int buf_size,
266 AVFormatParameters *ap);
267
268#define AVERROR_UNKNOWN (-1) /* unknown error */
269#define AVERROR_IO (-2) /* i/o error */
270#define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
271#define AVERROR_INVALIDDATA (-4) /* invalid data found */
272#define AVERROR_NOMEM (-5) /* not enough memory */
273#define AVERROR_NOFMT (-6) /* unknown format */
274
275int av_find_stream_info(AVFormatContext *ic);
de6d9b64
FB
276int av_read_packet(AVFormatContext *s, AVPacket *pkt);
277void av_close_input_file(AVFormatContext *s);
b9a281db 278AVStream *av_new_stream(AVFormatContext *s, int id);
de6d9b64 279
b9a281db
FB
280/* media file output */
281int av_write_header(AVFormatContext *s);
10bb7023 282int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
b9a281db 283int av_write_trailer(AVFormatContext *s);
de6d9b64
FB
284
285void dump_format(AVFormatContext *ic,
286 int index,
287 const char *url,
288 int is_output);
289int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
de6d9b64
FB
290INT64 parse_date(const char *datestr, int duration);
291
94988531
FB
292INT64 av_gettime(void);
293
de6d9b64
FB
294/* ffm specific for ffserver */
295#define FFM_PACKET_SIZE 4096
296offset_t ffm_read_write_index(int fd);
297void ffm_write_write_index(int fd, offset_t pos);
298void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
299
300int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
301
813cae4b
FB
302int get_frame_filename(char *buf, int buf_size,
303 const char *path, int number);
b9a281db 304int filename_number_test(const char *filename);
96baaa6a 305
b9a281db
FB
306/* grab specific */
307int video_grab_init(void);
308int audio_init(void);
96baaa6a
FB
309
310extern const char *v4l_device;
311extern const char *audio_device;
fb025625
FB
312
313#ifdef HAVE_AV_CONFIG_H
314int strstart(const char *str, const char *val, const char **ptr);
315int stristart(const char *str, const char *val, const char **ptr);
316void pstrcpy(char *buf, int buf_size, const char *str);
317char *pstrcat(char *buf, int buf_size, const char *s);
318int match_ext(const char *filename, const char *extensions);
319
320struct in_addr;
321int resolve_host(struct in_addr *sin_addr, const char *hostname);
322
323void url_split(char *proto, int proto_size,
324 char *hostname, int hostname_size,
325 int *port_ptr,
326 char *path, int path_size,
327 const char *url);
328
329#endif /* HAVE_AV_CONFIG_H */
330
331#endif /* AVFORMAT_H */