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