Statistics
| Branch: | Revision:

ffmpeg / libav / avformat.h @ 6775c758

History | View | Annotate | Download (5.32 KB)

1

    
2
#include "avcodec.h"
3

    
4
#define FFMPEG_VERSION "0.4.5"
5

    
6
#include "avio.h"
7

    
8
/* packet functions */
9

    
10
typedef 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

    
19
int av_new_packet(AVPacket *pkt, int size);
20
void av_free_packet(AVPacket *pkt);
21

    
22
/*************************************************/
23
/* output formats */
24

    
25
struct AVFormatContext;
26
struct AVFormatInputContext;
27

    
28
typedef 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

    
37
typedef 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

    
71
typedef 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 */
80
typedef 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

    
98
typedef struct AVPacketList {
99
    AVPacket pkt;
100
    struct AVPacketList *next;
101
} AVPacketList;
102

    
103
extern AVFormat *first_format;
104

    
105
/* rv10enc.c */
106
extern AVFormat rm_format;
107

    
108
/* mpegmux.c */
109
extern AVFormat mpeg_mux_format;
110

    
111
/* asfenc.c */
112
extern AVFormat asf_format;
113

    
114
/* avienc.c */
115
extern AVFormat avi_format;
116

    
117
/* jpegenc.c */
118
extern AVFormat mpjpeg_format;
119
extern AVFormat jpeg_format;
120

    
121
/* swfenc.c */
122
extern AVFormat swf_format;
123

    
124
/* wav.c */
125
extern AVFormat wav_format;
126

    
127
/* img.c */
128
extern AVFormat pgm_format;
129
extern AVFormat ppm_format;
130
extern AVFormat pgmyuv_format;
131
extern AVFormat imgyuv_format;
132

    
133
extern AVFormat pgmpipe_format;
134
extern AVFormat pgmyuvpipe_format;
135
extern AVFormat ppmpipe_format;
136

    
137
/* raw.c */
138
extern AVFormat mp2_format;
139
extern AVFormat ac3_format;
140
extern AVFormat h263_format;
141
extern AVFormat mpeg1video_format;
142
extern AVFormat pcm_format;
143
extern AVFormat rawvideo_format;
144

    
145
/* ffm.c */
146
extern 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

    
153
void register_avformat(AVFormat *format);
154
AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
155

    
156
int strstart(const char *str, const char *val, const char **ptr);
157
void nstrcpy(char *buf, int buf_size, const char *str);
158
int match_ext(const char *filename, const char *extensions);
159

    
160
void register_all(void);
161

    
162
INT64 gettime(void);
163

    
164
typedef struct FifoBuffer {
165
    UINT8 *buffer;
166
    UINT8 *rptr, *wptr, *end;
167
} FifoBuffer;
168

    
169
int fifo_init(FifoBuffer *f, int size);
170
void fifo_free(FifoBuffer *f);
171
int fifo_size(FifoBuffer *f, UINT8 *rptr);
172
int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
173
void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
174

    
175
AVFormatContext *av_open_input_file(const char *filename, int buf_size);
176
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
177
void av_close_input_file(AVFormatContext *s);
178

    
179
int av_write_packet(AVFormatContext *s, AVPacket *pkt);
180

    
181
void dump_format(AVFormatContext *ic,
182
                 int index, 
183
                 const char *url,
184
                 int is_output);
185
int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
186
INT64 gettime(void);
187
INT64 parse_date(const char *datestr, int duration);
188

    
189
/* ffm specific for ffserver */
190
#define FFM_PACKET_SIZE 4096
191
offset_t ffm_read_write_index(int fd);
192
void ffm_write_write_index(int fd, offset_t pos);
193
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
194

    
195
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
196