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