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