Initial revision
[libav.git] / libav / avformat.h
CommitLineData
de6d9b64
FB
1
2#include "avcodec.h"
3
4#define FFMPEG_VERSION "0.4.5"
5
6#include "avio.h"
7
8/* packet functions */
9
10typedef struct AVPacket {
11 INT64 pts;
12 UINT8 *data;
13 int size;
14 int stream_index;
15 int flags;
16#define PKT_FLAG_KEY 0x0001
17} AVPacket;
18
19int av_new_packet(AVPacket *pkt, int size);
20void av_free_packet(AVPacket *pkt);
21
22/*************************************************/
23/* output formats */
24
25struct AVFormatContext;
26struct AVFormatInputContext;
27
28typedef struct AVFormatParameters {
29 int frame_rate;
30 int sample_rate;
31 int channels;
32 int width;
33 int height;
34 int pix_fmt;
35} AVFormatParameters;
36
37typedef struct AVFormat {
38 const char *name;
39 const char *long_name;
40 const char *mime_type;
41 const char *extensions; /* comma separated extensions */
42
43 /* output support */
44 enum CodecID audio_codec; /* default audio codec */
45 enum CodecID video_codec; /* default video codec */
46 int (*write_header)(struct AVFormatContext *);
47 int (*write_packet)(struct AVFormatContext *,
48 int stream_index,
49 unsigned char *buf, int size);
50 int (*write_trailer)(struct AVFormatContext *);
51
52 /* optional input support */
53 /* read the format header and initialize the AVFormatInputContext
54 structure. Return 0 if OK. 'ap' if non NULL contains
55 additionnal paramters. Only used in raw format right now */
56 int (*read_header)(struct AVFormatContext *,
57 AVFormatParameters *ap);
58 /* read one packet and put it in 'pkt'. pts and flags are also set */
59 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
60 /* close the stream. The AVFormatContext and AVStreams are not
61 freed by this function */
62 int (*read_close)(struct AVFormatContext *);
63 /* seek at or before a given pts (given in microsecond). The pts
64 origin is defined by the stream */
65 int (*read_seek)(struct AVFormatContext *, INT64 pts);
66 int flags;
67#define AVFMT_NOFILE 0x0001 /* no file should be opened */
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
117/* jpegenc.c */
118extern AVFormat mpjpeg_format;
119extern AVFormat jpeg_format;
120
121/* swfenc.c */
122extern AVFormat swf_format;
123
124/* wav.c */
125extern AVFormat wav_format;
126
127/* img.c */
128extern AVFormat pgm_format;
129extern AVFormat pgmyuv_format;
130extern AVFormat imgyuv_format;
131extern AVFormat pgmpipe_format;
132
133/* raw.c */
134extern AVFormat mp2_format;
135extern AVFormat ac3_format;
136extern AVFormat h263_format;
137extern AVFormat mpeg1video_format;
138extern AVFormat pcm_format;
139extern AVFormat rawvideo_format;
140
141/* ffm.c */
142extern AVFormat ffm_format;
143
144/* formats.c */
145
146#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
147#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
148
149void register_avformat(AVFormat *format);
150AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
151
152int strstart(const char *str, const char *val, const char **ptr);
153void nstrcpy(char *buf, int buf_size, const char *str);
154int match_ext(const char *filename, const char *extensions);
155
156void register_all(void);
157
158INT64 gettime(void);
159
160typedef struct FifoBuffer {
161 UINT8 *buffer;
162 UINT8 *rptr, *wptr, *end;
163} FifoBuffer;
164
165int fifo_init(FifoBuffer *f, int size);
166void fifo_free(FifoBuffer *f);
167int fifo_size(FifoBuffer *f, UINT8 *rptr);
168int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
169void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
170
171AVFormatContext *av_open_input_file(const char *filename, int buf_size);
172int av_read_packet(AVFormatContext *s, AVPacket *pkt);
173void av_close_input_file(AVFormatContext *s);
174
175int av_write_packet(AVFormatContext *s, AVPacket *pkt);
176
177void dump_format(AVFormatContext *ic,
178 int index,
179 const char *url,
180 int is_output);
181int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
182INT64 gettime(void);
183INT64 parse_date(const char *datestr, int duration);
184
185/* ffm specific for ffserver */
186#define FFM_PACKET_SIZE 4096
187offset_t ffm_read_write_index(int fd);
188void ffm_write_write_index(int fd, offset_t pos);
189void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
190
191int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
192