- Versions defined for libav/libavcodec.
[libav.git] / libav / avformat.h
CommitLineData
de6d9b64 1
4b1f4f23
J
2#define LIBAV_VERSION_INT 0x000406
3#define LIBAV_VERSION "0.4.6"
4#define LIBAV_BUILD 4600
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;
18#define PKT_FLAG_KEY 0x0001
4606ac8d 19#define PKT_FLAG_DROPPED_FRAME 0x0002
de6d9b64
FB
20} AVPacket;
21
22int av_new_packet(AVPacket *pkt, int size);
23void av_free_packet(AVPacket *pkt);
24
25/*************************************************/
26/* output formats */
27
28struct AVFormatContext;
29struct AVFormatInputContext;
30
31typedef struct AVFormatParameters {
32 int frame_rate;
33 int sample_rate;
34 int channels;
35 int width;
36 int height;
4606ac8d 37 enum PixelFormat pix_fmt;
de6d9b64
FB
38} AVFormatParameters;
39
40typedef 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,
10bb7023 52 unsigned char *buf, int size, int force_pts);
de6d9b64
FB
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;
813cae4b
FB
70#define AVFMT_NOFILE 0x0001 /* no file should be opened */
71#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
de6d9b64
FB
72 struct AVFormat *next;
73} AVFormat;
74
75typedef 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 */
84typedef 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
102typedef struct AVPacketList {
103 AVPacket pkt;
104 struct AVPacketList *next;
105} AVPacketList;
106
107extern AVFormat *first_format;
108
109/* rv10enc.c */
110extern AVFormat rm_format;
111
112/* mpegmux.c */
113extern AVFormat mpeg_mux_format;
114
115/* asfenc.c */
116extern AVFormat asf_format;
117
118/* avienc.c */
119extern AVFormat avi_format;
120
6cea494e
ZK
121/* mov.c */
122extern AVFormat mov_format;
123extern AVFormat mp4_format;
124
de6d9b64
FB
125/* jpegenc.c */
126extern AVFormat mpjpeg_format;
127extern AVFormat jpeg_format;
eea23282 128extern AVFormat single_jpeg_format;
de6d9b64
FB
129
130/* swfenc.c */
131extern AVFormat swf_format;
132
6cea494e
ZK
133/* gif.c */
134extern AVFormat gif_format;
135/* au.c */
136extern AVFormat au_format;
137
de6d9b64
FB
138/* wav.c */
139extern AVFormat wav_format;
140
141/* img.c */
142extern AVFormat pgm_format;
6775c758 143extern AVFormat ppm_format;
de6d9b64
FB
144extern AVFormat pgmyuv_format;
145extern AVFormat imgyuv_format;
6775c758 146
de6d9b64 147extern AVFormat pgmpipe_format;
6775c758
FB
148extern AVFormat pgmyuvpipe_format;
149extern AVFormat ppmpipe_format;
de6d9b64
FB
150
151/* raw.c */
152extern AVFormat mp2_format;
153extern AVFormat ac3_format;
154extern AVFormat h263_format;
155extern AVFormat mpeg1video_format;
eea23282 156extern AVFormat mjpeg_format;
5ed8fafc
FB
157extern AVFormat pcm_s16le_format;
158extern AVFormat pcm_s16be_format;
159extern AVFormat pcm_u16le_format;
160extern AVFormat pcm_u16be_format;
161extern AVFormat pcm_s8_format;
162extern AVFormat pcm_u8_format;
163extern AVFormat pcm_mulaw_format;
164extern AVFormat pcm_alaw_format;
de6d9b64
FB
165extern AVFormat rawvideo_format;
166
167/* ffm.c */
168extern 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
175void register_avformat(AVFormat *format);
176AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
177
178int strstart(const char *str, const char *val, const char **ptr);
179void nstrcpy(char *buf, int buf_size, const char *str);
180int match_ext(const char *filename, const char *extensions);
181
182void register_all(void);
183
184INT64 gettime(void);
185
186typedef struct FifoBuffer {
187 UINT8 *buffer;
188 UINT8 *rptr, *wptr, *end;
189} FifoBuffer;
190
191int fifo_init(FifoBuffer *f, int size);
192void fifo_free(FifoBuffer *f);
193int fifo_size(FifoBuffer *f, UINT8 *rptr);
194int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
195void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
196
96baaa6a
FB
197AVFormatContext *av_open_input_file(const char *filename,
198 const char *format_name,
199 int buf_size,
200 AVFormatParameters *ap);
de6d9b64
FB
201int av_read_packet(AVFormatContext *s, AVPacket *pkt);
202void av_close_input_file(AVFormatContext *s);
203
10bb7023 204int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
de6d9b64
FB
205
206void dump_format(AVFormatContext *ic,
207 int index,
208 const char *url,
209 int is_output);
210int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
211INT64 gettime(void);
212INT64 parse_date(const char *datestr, int duration);
213
214/* ffm specific for ffserver */
215#define FFM_PACKET_SIZE 4096
216offset_t ffm_read_write_index(int fd);
217void ffm_write_write_index(int fd, offset_t pos);
218void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
219
220int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
221
813cae4b
FB
222int get_frame_filename(char *buf, int buf_size,
223 const char *path, int number);
96baaa6a
FB
224
225/* grab/output specific */
226extern AVFormat video_grab_device_format;
227extern AVFormat audio_device_format;
228
229extern const char *v4l_device;
230extern const char *audio_device;