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