added patch info (I prefer only diff -u) and clear info about my patch copyright...
[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,
47 unsigned char *buf, int size);
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;
65#define AVFMT_NOFILE 0x0001 /* no file should be opened */
66 struct AVFormat *next;
67} AVFormat;
68
69typedef struct AVStream {
70 int id; /* internal stream id */
71 AVCodecContext codec; /* codec context */
72 void *priv_data;
73} AVStream;
74
75#define MAX_STREAMS 20
76
77/* format I/O context */
78typedef struct AVFormatContext {
79 struct AVFormat *format;
80 void *priv_data;
81 ByteIOContext pb;
82 int nb_streams;
83 AVStream *streams[MAX_STREAMS];
84 char filename[1024]; /* input or output filename */
85 /* stream info */
86 char title[512];
87 char author[512];
88 char copyright[512];
89 char comment[512];
90 /* This buffer is only needed when packets were already buffered but
91 not decoded, for example to get the codec parameters in mpeg
92 streams */
93 struct AVPacketList *packet_buffer;
94} AVFormatContext;
95
96typedef struct AVPacketList {
97 AVPacket pkt;
98 struct AVPacketList *next;
99} AVPacketList;
100
101extern AVFormat *first_format;
102
103/* rv10enc.c */
104extern AVFormat rm_format;
105
106/* mpegmux.c */
107extern AVFormat mpeg_mux_format;
108
109/* asfenc.c */
110extern AVFormat asf_format;
111
112/* avienc.c */
113extern AVFormat avi_format;
114
115/* jpegenc.c */
116extern AVFormat mpjpeg_format;
117extern AVFormat jpeg_format;
eea23282 118extern AVFormat single_jpeg_format;
de6d9b64
FB
119
120/* swfenc.c */
121extern AVFormat swf_format;
122
123/* wav.c */
124extern AVFormat wav_format;
125
126/* img.c */
127extern AVFormat pgm_format;
6775c758 128extern AVFormat ppm_format;
de6d9b64
FB
129extern AVFormat pgmyuv_format;
130extern AVFormat imgyuv_format;
6775c758 131
de6d9b64 132extern AVFormat pgmpipe_format;
6775c758
FB
133extern AVFormat pgmyuvpipe_format;
134extern AVFormat ppmpipe_format;
de6d9b64
FB
135
136/* raw.c */
137extern AVFormat mp2_format;
138extern AVFormat ac3_format;
139extern AVFormat h263_format;
140extern AVFormat mpeg1video_format;
eea23282 141extern AVFormat mjpeg_format;
de6d9b64
FB
142extern AVFormat pcm_format;
143extern AVFormat rawvideo_format;
144
145/* ffm.c */
146extern AVFormat ffm_format;
147
148/* formats.c */
149
150#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
151#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
152
153void register_avformat(AVFormat *format);
154AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
155
156int strstart(const char *str, const char *val, const char **ptr);
157void nstrcpy(char *buf, int buf_size, const char *str);
158int match_ext(const char *filename, const char *extensions);
159
160void register_all(void);
161
162INT64 gettime(void);
163
164typedef struct FifoBuffer {
165 UINT8 *buffer;
166 UINT8 *rptr, *wptr, *end;
167} FifoBuffer;
168
169int fifo_init(FifoBuffer *f, int size);
170void fifo_free(FifoBuffer *f);
171int fifo_size(FifoBuffer *f, UINT8 *rptr);
172int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
173void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
174
175AVFormatContext *av_open_input_file(const char *filename, int buf_size);
176int av_read_packet(AVFormatContext *s, AVPacket *pkt);
177void av_close_input_file(AVFormatContext *s);
178
179int av_write_packet(AVFormatContext *s, AVPacket *pkt);
180
181void dump_format(AVFormatContext *ic,
182 int index,
183 const char *url,
184 int is_output);
185int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
186INT64 gettime(void);
187INT64 parse_date(const char *datestr, int duration);
188
189/* ffm specific for ffserver */
190#define FFM_PACKET_SIZE 4096
191offset_t ffm_read_write_index(int fd);
192void ffm_write_write_index(int fd, offset_t pos);
193void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
194
195int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
196