Statistics
| Branch: | Revision:

ffmpeg / libavformat / avformat.h @ 57011a13

History | View | Annotate | Download (43.8 KB)

1 04d7f601 Diego Biurrun
/*
2
 * copyright (c) 2001 Fabrice Bellard
3
 *
4 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7 04d7f601 Diego Biurrun
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
10 04d7f601 Diego Biurrun
 *
11 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
12 04d7f601 Diego Biurrun
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
18 04d7f601 Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
21 98790382 Stefano Sabatini
#ifndef AVFORMAT_AVFORMAT_H
22
#define AVFORMAT_AVFORMAT_H
23 de6d9b64 Fabrice Bellard
24 800c289a Måns Rullgård
#define LIBAVFORMAT_VERSION_MAJOR 52
25 57011a13 Baptiste Coudurier
#define LIBAVFORMAT_VERSION_MINOR 36
26 af122d6a Baptiste Coudurier
#define LIBAVFORMAT_VERSION_MICRO  0
27 e97ac1e6 Måns Rullgård
28 800c289a Måns Rullgård
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
29
                                               LIBAVFORMAT_VERSION_MINOR, \
30
                                               LIBAVFORMAT_VERSION_MICRO)
31
#define LIBAVFORMAT_VERSION     AV_VERSION(LIBAVFORMAT_VERSION_MAJOR,   \
32
                                           LIBAVFORMAT_VERSION_MINOR,   \
33
                                           LIBAVFORMAT_VERSION_MICRO)
34 5aa083ee Michael Niedermayer
#define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
35 8026c3b5 Alex Beregszaszi
36 5aa083ee Michael Niedermayer
#define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
37 4b1f4f23 Juanjo
38 c97429e2 Stefano Sabatini
/**
39
 * Returns the LIBAVFORMAT_VERSION_INT constant.
40
 */
41
unsigned avformat_version(void);
42
43 f71869a4 Fabrice Bellard
#include <time.h>
44 67070e4f Zdenek Kabelac
#include <stdio.h>  /* FILE */
45 76a448ed Måns Rullgård
#include "libavcodec/avcodec.h"
46 de6d9b64 Fabrice Bellard
47
#include "avio.h"
48
49 f610a9f2 Aurelien Jacobs
struct AVFormatContext;
50
51 a6d18a0e Michael Niedermayer
52
/*
53 ea29242c Mike Melanson
 * Public Metadata API.
54
 * The metadata API allows libavformat to export metadata tags to a client
55
 * application using a sequence of key/value pairs.
56
 * Important concepts to keep in mind:
57
 * 1. Keys are unique; there can never be 2 tags with the same key. This is
58
 *    also meant semantically, i.e., a demuxer should not knowingly produce
59
 *    several keys that are literally different but semantically identical.
60
 *    E.g., key=Author5, key=Author6. In this example, all authors must be
61
 *    placed in the same tag.
62
 * 2. Metadata is flat, not hierarchical; there are no subtags. If you
63
 *    want to store, e.g., the email address of the child of producer Alice
64
 *    and actor Bob, that could have key=alice_and_bobs_childs_email_address.
65
 * 3. A tag whose value is localized for a particular language is appended
66 7e030c47 Michael Niedermayer
 *    with a dash character ('-') and the ISO 639-2/B 3-letter language code.
67 ea29242c Mike Melanson
 *    For example: Author-ger=Michael, Author-eng=Mike
68
 *    The original/default language is in the unqualified "Author" tag.
69 a6d18a0e Michael Niedermayer
 *    A demuxer should set a default if it sets any translated tag.
70
 */
71
72 48a81c0f Aurelien Jacobs
#define AV_METADATA_MATCH_CASE      1
73 a6d18a0e Michael Niedermayer
#define AV_METADATA_IGNORE_SUFFIX   2
74
75
typedef struct {
76
    char *key;
77
    char *value;
78 bc1d2afb Aurelien Jacobs
}AVMetadataTag;
79 a6d18a0e Michael Niedermayer
80 e232c252 Aurelien Jacobs
typedef struct AVMetadata AVMetadata;
81 f610a9f2 Aurelien Jacobs
typedef struct AVMetadataConv AVMetadataConv;
82 a6d18a0e Michael Niedermayer
83
/**
84 22e77e44 Diego Biurrun
 * Gets a metadata element with matching key.
85
 * @param prev Set to the previous matching element to find the next.
86
 * @param flags Allows case as well as suffix-insensitive comparisons.
87
 * @return Found tag or NULL, changing key or value leads to undefined behavior.
88 a6d18a0e Michael Niedermayer
 */
89 bc1d2afb Aurelien Jacobs
AVMetadataTag *
90 e232c252 Aurelien Jacobs
av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
91 a6d18a0e Michael Niedermayer
92
/**
93 22e77e44 Diego Biurrun
 * Sets the given tag in m, overwriting an existing tag.
94
 * @param key tag key to add to m (will be av_strduped)
95
 * @param value tag value to add to m (will be av_strduped)
96
 * @return >= 0 on success otherwise an error code <0
97 a6d18a0e Michael Niedermayer
 */
98 5ea7ce88 Aurelien Jacobs
int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
99 a6d18a0e Michael Niedermayer
100 094d9df7 Aurelien Jacobs
/**
101 f610a9f2 Aurelien Jacobs
 * Convert all the metadata sets from ctx according to the source and
102
 * destination conversion tables.
103
 * @param d_conv destination tags format conversion table
104
 * @param s_conv source tags format conversion table
105
 */
106
void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
107
                                                  const AVMetadataConv *s_conv);
108
109
/**
110 22e77e44 Diego Biurrun
 * Frees all the memory allocated for an AVMetadata struct.
111 094d9df7 Aurelien Jacobs
 */
112
void av_metadata_free(AVMetadata **m);
113
114 a6d18a0e Michael Niedermayer
115 de6d9b64 Fabrice Bellard
/* packet functions */
116
117 3217cb42 Panagiotis Issaris
118
/**
119 4f57fa8c Diego Biurrun
 * Allocate and read the payload of a packet and initialize its fields with
120
 * default values.
121 3217cb42 Panagiotis Issaris
 *
122
 * @param pkt packet
123 4f57fa8c Diego Biurrun
 * @param size desired payload size
124
 * @return >0 (read size) if OK, AVERROR_xxx otherwise
125 3217cb42 Panagiotis Issaris
 */
126 2692067a Michael Niedermayer
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
127 3217cb42 Panagiotis Issaris
128 de6d9b64 Fabrice Bellard
129
/*************************************************/
130 916c80e9 Fabrice Bellard
/* fractional numbers for exact pts handling */
131
132 671adb17 Mark Cox
/**
133 4f57fa8c Diego Biurrun
 * The exact value of the fractional number is: 'val + num / den'.
134
 * num is assumed to be 0 <= num < den.
135 4c08b2bd Stefano Sabatini
 */
136 916c80e9 Fabrice Bellard
typedef struct AVFrac {
137 115329f1 Diego Biurrun
    int64_t val, num, den;
138 52e57500 Diego Biurrun
} AVFrac;
139 916c80e9 Fabrice Bellard
140
/*************************************************/
141 b9a281db Fabrice Bellard
/* input/output formats */
142 de6d9b64 Fabrice Bellard
143 7caf0cc6 Michael Niedermayer
struct AVCodecTag;
144
145 4f57fa8c Diego Biurrun
/** This structure contains the data a format has to probe a file. */
146 b9a281db Fabrice Bellard
typedef struct AVProbeData {
147 5c91a675 Zdenek Kabelac
    const char *filename;
148 b9a281db Fabrice Bellard
    unsigned char *buf;
149
    int buf_size;
150
} AVProbeData;
151
152 22e77e44 Diego Biurrun
#define AVPROBE_SCORE_MAX 100               ///< maximum score, half of that is used for file-extension-based detection
153 87e87886 Michael Niedermayer
#define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
154 de6d9b64 Fabrice Bellard
155
typedef struct AVFormatParameters {
156 c0df9d75 Michael Niedermayer
    AVRational time_base;
157 de6d9b64 Fabrice Bellard
    int sample_rate;
158
    int channels;
159
    int width;
160
    int height;
161 4606ac8d Zdenek Kabelac
    enum PixelFormat pix_fmt;
162 4f57fa8c Diego Biurrun
    int channel; /**< Used to select DV channel. */
163
    const char *standard; /**< TV standard, NTSC, PAL, SECAM */
164
    unsigned int mpeg2ts_raw:1;  /**< Force raw MPEG-2 transport stream output, if possible. */
165
    unsigned int mpeg2ts_compute_pcr:1; /**< Compute exact PCR for each transport
166 72e043dd Erik Hovland
                                            stream packet (only meaningful if
167 4f57fa8c Diego Biurrun
                                            mpeg2ts_raw is TRUE). */
168
    unsigned int initial_pause:1;       /**< Do not begin to play the stream
169
                                            immediately (RTSP only). */
170 72e043dd Erik Hovland
    unsigned int prealloced_context:1;
171 71957315 Michael Niedermayer
#if LIBAVFORMAT_VERSION_INT < (53<<16)
172 5b6d5596 Michael Niedermayer
    enum CodecID video_codec_id;
173
    enum CodecID audio_codec_id;
174 71957315 Michael Niedermayer
#endif
175 de6d9b64 Fabrice Bellard
} AVFormatParameters;
176
177 4f57fa8c Diego Biurrun
//! Demuxer will use url_fopen, no opened file should be provided by the caller.
178 40d9c544 Reimar Döffinger
#define AVFMT_NOFILE        0x0001
179 4f57fa8c Diego Biurrun
#define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
180
#define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
181
#define AVFMT_RAWPICTURE    0x0020 /**< Format wants AVPicture structure for
182
                                      raw picture data. */
183
#define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
184
#define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
185
#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
186
#define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. */
187 25918212 Michael Niedermayer
#define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
188 b9a281db Fabrice Bellard
189
typedef struct AVOutputFormat {
190 de6d9b64 Fabrice Bellard
    const char *name;
191 bde15e74 Stefano Sabatini
    /**
192
     * Descriptive name for the format, meant to be more human-readable
193 819174fa Stefano Sabatini
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
194 bde15e74 Stefano Sabatini
     * to define it.
195
     */
196 de6d9b64 Fabrice Bellard
    const char *long_name;
197
    const char *mime_type;
198 4f57fa8c Diego Biurrun
    const char *extensions; /**< comma-separated filename extensions */
199 22e77e44 Diego Biurrun
    /** size of private data so that it can be allocated in the wrapper */
200 b9a281db Fabrice Bellard
    int priv_data_size;
201 de6d9b64 Fabrice Bellard
    /* output support */
202 43d414ba Panagiotis Issaris
    enum CodecID audio_codec; /**< default audio codec */
203
    enum CodecID video_codec; /**< default video codec */
204 de6d9b64 Fabrice Bellard
    int (*write_header)(struct AVFormatContext *);
205 e928649b Michael Niedermayer
    int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
206 de6d9b64 Fabrice Bellard
    int (*write_trailer)(struct AVFormatContext *);
207 43d414ba Panagiotis Issaris
    /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
208 b9a281db Fabrice Bellard
    int flags;
209 4f57fa8c Diego Biurrun
    /** Currently only used to set pixel format if not YUV420P. */
210 290c5fa6 Fabrice Bellard
    int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
211 78cb7273 Diego Biurrun
    int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
212
                             AVPacket *in, int flush);
213 7caf0cc6 Michael Niedermayer
214
    /**
215 78cb7273 Diego Biurrun
     * List of supported codec_id-codec_tag pairs, ordered by "better
216 22e77e44 Diego Biurrun
     * choice first". The arrays are all terminated by CODEC_ID_NONE.
217 7caf0cc6 Michael Niedermayer
     */
218 c1854592 Reimar Döffinger
    const struct AVCodecTag * const *codec_tag;
219 7caf0cc6 Michael Niedermayer
220 11bf3847 Aurelien Jacobs
    enum CodecID subtitle_codec; /**< default subtitle codec */
221
222 719e721a Aurelien Jacobs
    const AVMetadataConv *metadata_conv;
223 f610a9f2 Aurelien Jacobs
224 b9a281db Fabrice Bellard
    /* private fields */
225
    struct AVOutputFormat *next;
226
} AVOutputFormat;
227 de6d9b64 Fabrice Bellard
228 b9a281db Fabrice Bellard
typedef struct AVInputFormat {
229
    const char *name;
230 bde15e74 Stefano Sabatini
    /**
231
     * Descriptive name for the format, meant to be more human-readable
232 819174fa Stefano Sabatini
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
233 bde15e74 Stefano Sabatini
     * to define it.
234
     */
235 b9a281db Fabrice Bellard
    const char *long_name;
236 4f57fa8c Diego Biurrun
    /** Size of private data so that it can be allocated in the wrapper. */
237 b9a281db Fabrice Bellard
    int priv_data_size;
238 65d7d68b Michael Niedermayer
    /**
239 22e77e44 Diego Biurrun
     * Tell if a given file has a chance of being parsed as this format.
240 5d81d641 Diego Biurrun
     * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
241
     * big so you do not have to check for that unless you need more.
242 65d7d68b Michael Niedermayer
     */
243 b9a281db Fabrice Bellard
    int (*read_probe)(AVProbeData *);
244 4f57fa8c Diego Biurrun
    /** Read the format header and initialize the AVFormatContext
245
       structure. Return 0 if OK. 'ap' if non-NULL contains
246
       additional parameters. Only used in raw format right
247 b9a281db Fabrice Bellard
       now. 'av_new_stream' should be called to create new streams.  */
248 de6d9b64 Fabrice Bellard
    int (*read_header)(struct AVFormatContext *,
249
                       AVFormatParameters *ap);
250 4f57fa8c Diego Biurrun
    /** Read one packet and put it in 'pkt'. pts and flags are also
251 b9a281db Fabrice Bellard
       set. 'av_new_stream' can be called only if the flag
252 6883ebe4 Reimar Döffinger
       AVFMTCTX_NOHEADER is used.
253
       @return 0 on success, < 0 on error.
254
               When returning an error, pkt must not have been allocated
255
               or must be freed before returning */
256 de6d9b64 Fabrice Bellard
    int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
257 4f57fa8c Diego Biurrun
    /** Close the stream. The AVFormatContext and AVStreams are not
258 de6d9b64 Fabrice Bellard
       freed by this function */
259
    int (*read_close)(struct AVFormatContext *);
260 1de2db8f Michael Niedermayer
261
#if LIBAVFORMAT_VERSION_MAJOR < 53
262 115329f1 Diego Biurrun
    /**
263 4f57fa8c Diego Biurrun
     * Seek to a given timestamp relative to the frames in
264
     * stream component stream_index.
265 22e77e44 Diego Biurrun
     * @param stream_index Must not be -1.
266
     * @param flags Selects which direction should be preferred if no exact
267
     *              match is available.
268 05ce0f11 Maksym Veremeyenko
     * @return >= 0 on success (but not necessarily the new offset)
269 3ba1438d Michael Niedermayer
     */
270 115329f1 Diego Biurrun
    int (*read_seek)(struct AVFormatContext *,
271 3ba1438d Michael Niedermayer
                     int stream_index, int64_t timestamp, int flags);
272 1de2db8f Michael Niedermayer
#endif
273 8d14a25c Michael Niedermayer
    /**
274 4f57fa8c Diego Biurrun
     * Gets the next timestamp in stream[stream_index].time_base units.
275 d9526386 Diego Biurrun
     * @return the timestamp or AV_NOPTS_VALUE if an error occurred
276 8d14a25c Michael Niedermayer
     */
277
    int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
278
                              int64_t *pos, int64_t pos_limit);
279 4f57fa8c Diego Biurrun
    /** Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER. */
280 de6d9b64 Fabrice Bellard
    int flags;
281 4f57fa8c Diego Biurrun
    /** If extensions are defined, then no probe is done. You should
282 b9a281db Fabrice Bellard
       usually not use extension format guessing because it is not
283
       reliable enough */
284
    const char *extensions;
285 4f57fa8c Diego Biurrun
    /** General purpose read-only value that the format can use. */
286 b9a281db Fabrice Bellard
    int value;
287 fb2758c8 Fabrice Bellard
288 4f57fa8c Diego Biurrun
    /** Start/resume playing - only meaningful if using a network-based format
289
       (RTSP). */
290 fb2758c8 Fabrice Bellard
    int (*read_play)(struct AVFormatContext *);
291
292 4f57fa8c Diego Biurrun
    /** Pause playing - only meaningful if using a network-based format
293
       (RTSP). */
294 fb2758c8 Fabrice Bellard
    int (*read_pause)(struct AVFormatContext *);
295
296 c1854592 Reimar Döffinger
    const struct AVCodecTag * const *codec_tag;
297 7caf0cc6 Michael Niedermayer
298 1de2db8f Michael Niedermayer
    /**
299
     * Seek to timestamp ts.
300
     * Seeking will be done so that the point from which all active streams
301
     * can be presented successfully will be closest to ts and within min/max_ts.
302
     * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
303
     */
304 882fb0a3 Michael Niedermayer
    int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
305 1de2db8f Michael Niedermayer
306 719e721a Aurelien Jacobs
    const AVMetadataConv *metadata_conv;
307 f610a9f2 Aurelien Jacobs
308 b9a281db Fabrice Bellard
    /* private fields */
309
    struct AVInputFormat *next;
310
} AVInputFormat;
311 de6d9b64 Fabrice Bellard
312 57004ff1 Aurelien Jacobs
enum AVStreamParseType {
313
    AVSTREAM_PARSE_NONE,
314
    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
315 4f57fa8c Diego Biurrun
    AVSTREAM_PARSE_HEADERS,    /**< Only parse headers, do not repack. */
316 78cb7273 Diego Biurrun
    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
317 57004ff1 Aurelien Jacobs
};
318
319 fb2758c8 Fabrice Bellard
typedef struct AVIndexEntry {
320
    int64_t pos;
321
    int64_t timestamp;
322
#define AVINDEX_KEYFRAME 0x0001
323 30a43f2d Michael Niedermayer
    int flags:2;
324 4f57fa8c Diego Biurrun
    int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
325
    int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
326 fb2758c8 Fabrice Bellard
} AVIndexEntry;
327
328 90c2295b Evgeniy Stepanov
#define AV_DISPOSITION_DEFAULT   0x0001
329
#define AV_DISPOSITION_DUB       0x0002
330
#define AV_DISPOSITION_ORIGINAL  0x0004
331
#define AV_DISPOSITION_COMMENT   0x0008
332
#define AV_DISPOSITION_LYRICS    0x0010
333
#define AV_DISPOSITION_KARAOKE   0x0020
334
335 ba66ae94 Michael Niedermayer
/**
336
 * Stream structure.
337
 * New fields can be added to the end with minor version bumps.
338 8bfb108b Diego Biurrun
 * Removal, reordering and changes to existing fields require a major
339 ba66ae94 Michael Niedermayer
 * version bump.
340 8bfb108b Diego Biurrun
 * sizeof(AVStream) must not be used outside libav*.
341 ba66ae94 Michael Niedermayer
 */
342 de6d9b64 Fabrice Bellard
typedef struct AVStream {
343 43d414ba Panagiotis Issaris
    int index;    /**< stream index in AVFormatContext */
344 4f57fa8c Diego Biurrun
    int id;       /**< format-specific stream ID */
345 43d414ba Panagiotis Issaris
    AVCodecContext *codec; /**< codec context */
346 b4b87d48 Michael Niedermayer
    /**
347 22e77e44 Diego Biurrun
     * Real base framerate of the stream.
348
     * This is the lowest framerate with which all timestamps can be
349 864ff8c1 Ramiro Polla
     * represented accurately (it is the least common multiple of all
350 22e77e44 Diego Biurrun
     * framerates in the stream). Note, this value is just a guess!
351
     * For example, if the time base is 1/90000 and all frames have either
352 4f57fa8c Diego Biurrun
     * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
353 b4b87d48 Michael Niedermayer
     */
354
    AVRational r_frame_rate;
355 de6d9b64 Fabrice Bellard
    void *priv_data;
356 82583548 Michael Niedermayer
357 b9a281db Fabrice Bellard
    /* internal data used in av_find_stream_info() */
358 82583548 Michael Niedermayer
    int64_t first_dts;
359 4f57fa8c Diego Biurrun
    /** encoding: pts generation when outputting stream */
360 a9fd2b19 Måns Rullgård
    struct AVFrac pts;
361 5b28c8c3 Michael Niedermayer
362
    /**
363 8bfb108b Diego Biurrun
     * This is the fundamental unit of time (in seconds) in terms
364
     * of which frame timestamps are represented. For fixed-fps content,
365 22e77e44 Diego Biurrun
     * time base should be 1/framerate and timestamp increments should be 1.
366 5b28c8c3 Michael Niedermayer
     */
367 9ee91c2f Michael Niedermayer
    AVRational time_base;
368 43d414ba Panagiotis Issaris
    int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
369 a48b7a6b Fabrice Bellard
    /* ffmpeg.c private use */
370 4f57fa8c Diego Biurrun
    int stream_copy; /**< If set, just copy stream. */
371
    enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
372 b4aea108 Michael Niedermayer
    //FIXME move stuff to a flags field?
373 4f57fa8c Diego Biurrun
    /** Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
374 755bfeab Diego Biurrun
     * MN: dunno if that is the right place for it */
375 115329f1 Diego Biurrun
    float quality;
376 6d96a9b9 Michael Niedermayer
    /**
377 8bfb108b Diego Biurrun
     * Decoding: pts of the first frame of the stream, in stream time base.
378
     * Only set this if you are absolutely 100% sure that the value you set
379
     * it to really is the pts of the first frame.
380 4854c253 Neil Brown
     * This may be undefined (AV_NOPTS_VALUE).
381 8bfb108b Diego Biurrun
     * @note The ASF header does NOT contain a correct start_time the ASF
382
     * demuxer must NOT set this.
383 6d96a9b9 Michael Niedermayer
     */
384 115329f1 Diego Biurrun
    int64_t start_time;
385 e26381b6 Neil Brown
    /**
386 8bfb108b Diego Biurrun
     * Decoding: duration of the stream, in stream time base.
387 e26381b6 Neil Brown
     * If a source file does not specify a duration, but does specify
388 4f57fa8c Diego Biurrun
     * a bitrate, this value will be estimated from bitrate and file size.
389 e26381b6 Neil Brown
     */
390 ee404803 Fabrice Bellard
    int64_t duration;
391 fb2758c8 Fabrice Bellard
392 827f7e28 Aurelien Jacobs
#if LIBAVFORMAT_VERSION_INT < (53<<16)
393 7e030c47 Michael Niedermayer
    char language[4]; /** ISO 639-2/B 3-letter language code (empty string if undefined) */
394 827f7e28 Aurelien Jacobs
#endif
395 09730260 Fabrice Bellard
396 fb2758c8 Fabrice Bellard
    /* av_read_frame() support */
397 57004ff1 Aurelien Jacobs
    enum AVStreamParseType need_parsing;
398 fb2758c8 Fabrice Bellard
    struct AVCodecParserContext *parser;
399 6ec87caa Fabrice Bellard
400 fb2758c8 Fabrice Bellard
    int64_t cur_dts;
401 635fbcb1 Michael Niedermayer
    int last_IP_duration;
402
    int64_t last_IP_pts;
403 fb2758c8 Fabrice Bellard
    /* av_seek_frame() support */
404 4f57fa8c Diego Biurrun
    AVIndexEntry *index_entries; /**< Only used if the format does not
405
                                    support seeking natively. */
406 fb2758c8 Fabrice Bellard
    int nb_index_entries;
407 191e8ca7 Måns Rullgård
    unsigned int index_entries_allocated_size;
408 115329f1 Diego Biurrun
409 b4b87d48 Michael Niedermayer
    int64_t nb_frames;                 ///< number of frames in this stream if known or 0
410 504ee036 Michael Niedermayer
411 0d84a8f6 Baptiste Coudurier
#if LIBAVFORMAT_VERSION_INT < (53<<16)
412
    int64_t unused[4+1];
413 f8d7c9d3 Evgeniy Stepanov
414
    char *filename; /**< source filename of the stream */
415 827f7e28 Aurelien Jacobs
#endif
416 90c2295b Evgeniy Stepanov
417 4f57fa8c Diego Biurrun
    int disposition; /**< AV_DISPOSITION_* bit field */
418 0bef08e5 Michael Niedermayer
419
    AVProbeData probe_data;
420 0d84a8f6 Baptiste Coudurier
#define MAX_REORDER_DELAY 16
421
    int64_t pts_buffer[MAX_REORDER_DELAY+1];
422 c30a4489 Aurelien Jacobs
423
    /**
424
     * sample aspect ratio (0 if unknown)
425
     * - encoding: Set by user.
426
     * - decoding: Set by libavformat.
427
     */
428
    AVRational sample_aspect_ratio;
429 f526adaf Aurelien Jacobs
430 e232c252 Aurelien Jacobs
    AVMetadata *metadata;
431 3a41c2f7 Michael Niedermayer
432
    /* av_read_frame() support */
433
    const uint8_t *cur_ptr;
434
    int cur_len;
435
    AVPacket cur_pkt;
436 27ca0a79 Ivan Schreter
437
    // Timestamp generation support:
438
    /**
439
     * Timestamp corresponding to the last dts sync point.
440
     *
441
     * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
442
     * a DTS is received from the underlying container. Otherwise set to
443
     * AV_NOPTS_VALUE by default.
444
     */
445
    int64_t reference_dts;
446 86cb7e33 Baptiste Coudurier
447
    /**
448
     * Number of packets to buffer for codec probing
449
     * NOT PART OF PUBLIC API
450
     */
451
#define MAX_PROBE_PACKETS 100
452
    int probe_packets;
453 de6d9b64 Fabrice Bellard
} AVStream;
454
455 15afa396 Nico Sabbi
#define AV_PROGRAM_RUNNING 1
456
457 ba66ae94 Michael Niedermayer
/**
458
 * New fields can be added to the end with minor version bumps.
459 8bfb108b Diego Biurrun
 * Removal, reordering and changes to existing fields require a major
460 ba66ae94 Michael Niedermayer
 * version bump.
461 8bfb108b Diego Biurrun
 * sizeof(AVProgram) must not be used outside libav*.
462 ba66ae94 Michael Niedermayer
 */
463 15afa396 Nico Sabbi
typedef struct AVProgram {
464
    int            id;
465 827f7e28 Aurelien Jacobs
#if LIBAVFORMAT_VERSION_INT < (53<<16)
466 4f57fa8c Diego Biurrun
    char           *provider_name; ///< network name for DVB streams
467
    char           *name;          ///< service name for DVB streams
468 827f7e28 Aurelien Jacobs
#endif
469 15afa396 Nico Sabbi
    int            flags;
470
    enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
471 526efa10 Nico Sabbi
    unsigned int   *stream_index;
472
    unsigned int   nb_stream_indexes;
473 e232c252 Aurelien Jacobs
    AVMetadata *metadata;
474 15afa396 Nico Sabbi
} AVProgram;
475
476 43d414ba Panagiotis Issaris
#define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
477 da24c5e3 Fabrice Bellard
                                         (streams are added dynamically) */
478
479 79d7836a Anton Khirnov
typedef struct AVChapter {
480 4f57fa8c Diego Biurrun
    int id;                 ///< unique ID to identify the chapter
481
    AVRational time_base;   ///< time base in which the start/end timestamps are specified
482 8931e7b4 Michael Niedermayer
    int64_t start, end;     ///< chapter start/end time in time_base units
483 827f7e28 Aurelien Jacobs
#if LIBAVFORMAT_VERSION_INT < (53<<16)
484 c2fb6be4 Michael Niedermayer
    char *title;            ///< chapter title
485 827f7e28 Aurelien Jacobs
#endif
486 e232c252 Aurelien Jacobs
    AVMetadata *metadata;
487 79d7836a Anton Khirnov
} AVChapter;
488
489 de6d9b64 Fabrice Bellard
#define MAX_STREAMS 20
490
491 252f17e2 Michael Niedermayer
/**
492 4f57fa8c Diego Biurrun
 * Format I/O context.
493 252f17e2 Michael Niedermayer
 * New fields can be added to the end with minor version bumps.
494 8bfb108b Diego Biurrun
 * Removal, reordering and changes to existing fields require a major
495 252f17e2 Michael Niedermayer
 * version bump.
496 8bfb108b Diego Biurrun
 * sizeof(AVFormatContext) must not be used outside libav*.
497 252f17e2 Michael Niedermayer
 */
498 de6d9b64 Fabrice Bellard
typedef struct AVFormatContext {
499 1447aac4 avcoder
    const AVClass *av_class; /**< Set by avformat_alloc_context. */
500 4f57fa8c Diego Biurrun
    /* Can only be iformat or oformat, not both at the same time. */
501 b9a281db Fabrice Bellard
    struct AVInputFormat *iformat;
502
    struct AVOutputFormat *oformat;
503 de6d9b64 Fabrice Bellard
    void *priv_data;
504 899681cd Björn Axelsson
    ByteIOContext *pb;
505 db69c2e5 Diego Biurrun
    unsigned int nb_streams;
506 de6d9b64 Fabrice Bellard
    AVStream *streams[MAX_STREAMS];
507 43d414ba Panagiotis Issaris
    char filename[1024]; /**< input or output filename */
508 de6d9b64 Fabrice Bellard
    /* stream info */
509 4568325a Roman Shaposhnik
    int64_t timestamp;
510 827f7e28 Aurelien Jacobs
#if LIBAVFORMAT_VERSION_INT < (53<<16)
511 de6d9b64 Fabrice Bellard
    char title[512];
512
    char author[512];
513
    char copyright[512];
514
    char comment[512];
515 6a58e151 Fabrice Bellard
    char album[512];
516 43d414ba Panagiotis Issaris
    int year;  /**< ID3 year, 0 if none */
517
    int track; /**< track number, 0 if none */
518
    char genre[32]; /**< ID3 genre */
519 827f7e28 Aurelien Jacobs
#endif
520 6a58e151 Fabrice Bellard
521 4f57fa8c Diego Biurrun
    int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
522
    /* private data for pts handling (do not modify directly). */
523 43d414ba Panagiotis Issaris
    /** This buffer is only needed when packets were already buffered but
524 4f57fa8c Diego Biurrun
       not decoded, for example to get the codec parameters in MPEG
525
       streams. */
526 ee404803 Fabrice Bellard
    struct AVPacketList *packet_buffer;
527
528 4f57fa8c Diego Biurrun
    /** Decoding: position of the first frame of the component, in
529 ee404803 Fabrice Bellard
       AV_TIME_BASE fractional seconds. NEVER set this value directly:
530 4f57fa8c Diego Biurrun
       It is deduced from the AVStream values.  */
531 115329f1 Diego Biurrun
    int64_t start_time;
532 4f57fa8c Diego Biurrun
    /** Decoding: duration of the stream, in AV_TIME_BASE fractional
533 ee404803 Fabrice Bellard
       seconds. NEVER set this value directly: it is deduced from the
534
       AVStream values.  */
535
    int64_t duration;
536 4f57fa8c Diego Biurrun
    /** decoding: total file size, 0 if unknown */
537 ee404803 Fabrice Bellard
    int64_t file_size;
538 4f57fa8c Diego Biurrun
    /** Decoding: total stream bitrate in bit/s, 0 if not
539 ee404803 Fabrice Bellard
       available. Never set it directly if the file_size and the
540 22e77e44 Diego Biurrun
       duration are known as FFmpeg can compute it automatically. */
541 ee404803 Fabrice Bellard
    int bit_rate;
542 fb2758c8 Fabrice Bellard
543
    /* av_read_frame() support */
544
    AVStream *cur_st;
545 3a41c2f7 Michael Niedermayer
#if LIBAVFORMAT_VERSION_INT < (53<<16)
546
    const uint8_t *cur_ptr_deprecated;
547
    int cur_len_deprecated;
548
    AVPacket cur_pkt_deprecated;
549
#endif
550 fb2758c8 Fabrice Bellard
551
    /* av_seek_frame() support */
552 43d414ba Panagiotis Issaris
    int64_t data_offset; /** offset of the first packet */
553 fb2758c8 Fabrice Bellard
    int index_built;
554 115329f1 Diego Biurrun
555 2db3c638 Michael Niedermayer
    int mux_rate;
556 92400be2 Ronald S. Bultje
    unsigned int packet_size;
557 17c88cb0 Michael Niedermayer
    int preload;
558
    int max_delay;
559 8108551a Todd Kirby
560 115329f1 Diego Biurrun
#define AVFMT_NOOUTPUTLOOP -1
561
#define AVFMT_INFINITEOUTPUTLOOP 0
562 43d414ba Panagiotis Issaris
    /** number of times to loop output in formats that support it */
563 8108551a Todd Kirby
    int loop_output;
564 115329f1 Diego Biurrun
565 30bc6613 Michael Niedermayer
    int flags;
566 22e77e44 Diego Biurrun
#define AVFMT_FLAG_GENPTS       0x0001 ///< Generate missing pts even if it requires parsing future frames.
567 4f57fa8c Diego Biurrun
#define AVFMT_FLAG_IGNIDX       0x0002 ///< Ignore index.
568
#define AVFMT_FLAG_NONBLOCK     0x0004 ///< Do not block when reading packets from input.
569 5894e1bb Víctor Paesa
570
    int loop_input;
571 22e77e44 Diego Biurrun
    /** decoding: size of data to probe; encoding: unused. */
572 9e6c9470 Nico Sabbi
    unsigned int probesize;
573 a44b3c4d Michael Niedermayer
574
    /**
575 4f57fa8c Diego Biurrun
     * Maximum time (in AV_TIME_BASE units) during which the input should
576
     * be analyzed in av_find_stream_info().
577 a44b3c4d Michael Niedermayer
     */
578
    int max_analyze_duration;
579 c964c2c7 Reimar Döffinger
580
    const uint8_t *key;
581
    int keylen;
582 15afa396 Nico Sabbi
583
    unsigned int nb_programs;
584
    AVProgram **programs;
585 62600469 Michael Niedermayer
586
    /**
587
     * Forced video codec_id.
588 4f57fa8c Diego Biurrun
     * Demuxing: Set by user.
589 62600469 Michael Niedermayer
     */
590
    enum CodecID video_codec_id;
591
    /**
592
     * Forced audio codec_id.
593 4f57fa8c Diego Biurrun
     * Demuxing: Set by user.
594 62600469 Michael Niedermayer
     */
595
    enum CodecID audio_codec_id;
596
    /**
597
     * Forced subtitle codec_id.
598 4f57fa8c Diego Biurrun
     * Demuxing: Set by user.
599 62600469 Michael Niedermayer
     */
600
    enum CodecID subtitle_codec_id;
601 3dea63bd Paul Kelly
602
    /**
603 22e77e44 Diego Biurrun
     * Maximum amount of memory in bytes to use for the index of each stream.
604
     * If the index exceeds this size, entries will be discarded as
605 3dea63bd Paul Kelly
     * needed to maintain a smaller size. This can lead to slower or less
606
     * accurate seeking (depends on demuxer).
607 4f57fa8c Diego Biurrun
     * Demuxers for which a full in-memory index is mandatory will ignore
608 3dea63bd Paul Kelly
     * this.
609
     * muxing  : unused
610
     * demuxing: set by user
611
     */
612
    unsigned int max_index_size;
613 ab8ab30c Ramiro Polla
614
    /**
615 ffa71b2b Ramiro Polla
     * Maximum amount of memory in bytes to use for buffering frames
616 4f57fa8c Diego Biurrun
     * obtained from realtime capture devices.
617 ab8ab30c Ramiro Polla
     */
618
    unsigned int max_picture_buffer;
619 79d7836a Anton Khirnov
620 fbabf1e9 Michael Niedermayer
    unsigned int nb_chapters;
621 79d7836a Anton Khirnov
    AVChapter **chapters;
622 45b2b05f Michael Niedermayer
623
    /**
624 4f57fa8c Diego Biurrun
     * Flags to enable debugging.
625 45b2b05f Michael Niedermayer
     */
626
    int debug;
627
#define FF_FDEBUG_TS        0x0001
628 0bef08e5 Michael Niedermayer
629
    /**
630 4f57fa8c Diego Biurrun
     * Raw packets from the demuxer, prior to parsing and decoding.
631 0bef08e5 Michael Niedermayer
     * This buffer is used for buffering packets until the codec can
632
     * be identified, as parsing cannot be done without knowing the
633
     * codec.
634
     */
635
    struct AVPacketList *raw_packet_buffer;
636 5c5b1731 Måns Rullgård
    struct AVPacketList *raw_packet_buffer_end;
637
638
    struct AVPacketList *packet_buffer_end;
639 47146dfb Michael Niedermayer
640 e232c252 Aurelien Jacobs
    AVMetadata *metadata;
641 af122d6a Baptiste Coudurier
642
    /**
643
     * Remaining size available for raw_packet_buffer, in bytes.
644
     * NOT PART OF PUBLIC API
645
     */
646
#define RAW_PACKET_BUFFER_SIZE 32000
647
    int raw_packet_buffer_remaining_size;
648 de6d9b64 Fabrice Bellard
} AVFormatContext;
649
650
typedef struct AVPacketList {
651
    AVPacket pkt;
652
    struct AVPacketList *next;
653
} AVPacketList;
654
655 84be6e72 Michael Niedermayer
#if LIBAVFORMAT_VERSION_INT < (53<<16)
656 b9a281db Fabrice Bellard
extern AVInputFormat *first_iformat;
657
extern AVOutputFormat *first_oformat;
658 84be6e72 Michael Niedermayer
#endif
659
660 aeedac95 Stefano Sabatini
/**
661
 * If f is NULL, returns the first registered input format,
662 22e77e44 Diego Biurrun
 * if f is non-NULL, returns the next registered input format after f
663 aeedac95 Stefano Sabatini
 * or NULL if f is the last one.
664
 */
665 84be6e72 Michael Niedermayer
AVInputFormat  *av_iformat_next(AVInputFormat  *f);
666 aeedac95 Stefano Sabatini
667
/**
668
 * If f is NULL, returns the first registered output format,
669 22e77e44 Diego Biurrun
 * if f is non-NULL, returns the next registered output format after f
670 aeedac95 Stefano Sabatini
 * or NULL if f is the last one.
671
 */
672 84be6e72 Michael Niedermayer
AVOutputFormat *av_oformat_next(AVOutputFormat *f);
673 de6d9b64 Fabrice Bellard
674 5b6d5596 Michael Niedermayer
enum CodecID av_guess_image2_codec(const char *filename);
675 290c5fa6 Fabrice Bellard
676 22e77e44 Diego Biurrun
/* XXX: Use automatic init with either ELF sections or C file parser */
677
/* modules. */
678 de6d9b64 Fabrice Bellard
679 b9a281db Fabrice Bellard
/* utils.c */
680
void av_register_input_format(AVInputFormat *format);
681
void av_register_output_format(AVOutputFormat *format);
682 115329f1 Diego Biurrun
AVOutputFormat *guess_stream_format(const char *short_name,
683 78cb7273 Diego Biurrun
                                    const char *filename,
684
                                    const char *mime_type);
685 115329f1 Diego Biurrun
AVOutputFormat *guess_format(const char *short_name,
686 78cb7273 Diego Biurrun
                             const char *filename,
687
                             const char *mime_type);
688 3217cb42 Panagiotis Issaris
689
/**
690 4f57fa8c Diego Biurrun
 * Guesses the codec ID based upon muxer and filename.
691 3217cb42 Panagiotis Issaris
 */
692 115329f1 Diego Biurrun
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
693 78cb7273 Diego Biurrun
                            const char *filename, const char *mime_type,
694
                            enum CodecType type);
695 de6d9b64 Fabrice Bellard
696 3217cb42 Panagiotis Issaris
/**
697 750f0e1f Panagiotis Issaris
 * Send a nice hexadecimal dump of a buffer to the specified file stream.
698
 *
699
 * @param f The file stream pointer where the dump should be sent to.
700 3217cb42 Panagiotis Issaris
 * @param buf buffer
701
 * @param size buffer size
702 750f0e1f Panagiotis Issaris
 *
703
 * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
704 3217cb42 Panagiotis Issaris
 */
705 fb2758c8 Fabrice Bellard
void av_hex_dump(FILE *f, uint8_t *buf, int size);
706 3217cb42 Panagiotis Issaris
707
/**
708 750f0e1f Panagiotis Issaris
 * Send a nice hexadecimal dump of a buffer to the log.
709
 *
710
 * @param avcl A pointer to an arbitrary struct of which the first field is a
711
 * pointer to an AVClass struct.
712
 * @param level The importance level of the message, lower values signifying
713
 * higher importance.
714
 * @param buf buffer
715
 * @param size buffer size
716
 *
717
 * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
718
 */
719
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
720
721
/**
722
 * Send a nice dump of a packet to the specified file stream.
723
 *
724
 * @param f The file stream pointer where the dump should be sent to.
725 3217cb42 Panagiotis Issaris
 * @param pkt packet to dump
726 4f57fa8c Diego Biurrun
 * @param dump_payload True if the payload must be displayed, too.
727 3217cb42 Panagiotis Issaris
 */
728 fb2758c8 Fabrice Bellard
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
729 de6d9b64 Fabrice Bellard
730 750f0e1f Panagiotis Issaris
/**
731
 * Send a nice dump of a packet to the log.
732
 *
733
 * @param avcl A pointer to an arbitrary struct of which the first field is a
734
 * pointer to an AVClass struct.
735
 * @param level The importance level of the message, lower values signifying
736
 * higher importance.
737
 * @param pkt packet to dump
738 4f57fa8c Diego Biurrun
 * @param dump_payload True if the payload must be displayed, too.
739 750f0e1f Panagiotis Issaris
 */
740
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
741
742 4815e246 Stefano Sabatini
/**
743
 * Initialize libavformat and register all the muxers, demuxers and
744
 * protocols. If you do not call this function, then you can select
745
 * exactly which formats you want to support.
746
 *
747
 * @see av_register_input_format()
748
 * @see av_register_output_format()
749 5d377501 Stefano Sabatini
 * @see av_register_protocol()
750 4815e246 Stefano Sabatini
 */
751 94988531 Fabrice Bellard
void av_register_all(void);
752 de6d9b64 Fabrice Bellard
753 43d414ba Panagiotis Issaris
/** codec tag <-> codec id */
754 15545a09 Stefano Sabatini
enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
755
unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
756 7caf0cc6 Michael Niedermayer
757 b9a281db Fabrice Bellard
/* media file input */
758 3217cb42 Panagiotis Issaris
759
/**
760 4f57fa8c Diego Biurrun
 * Finds AVInputFormat based on the short name of the input format.
761 3217cb42 Panagiotis Issaris
 */
762 b9a281db Fabrice Bellard
AVInputFormat *av_find_input_format(const char *short_name);
763 3217cb42 Panagiotis Issaris
764
/**
765
 * Guess file format.
766
 *
767 4f57fa8c Diego Biurrun
 * @param is_opened Whether the file is already opened; determines whether
768
 *                  demuxers with or without AVFMT_NOFILE are probed.
769 3217cb42 Panagiotis Issaris
 */
770 94988531 Fabrice Bellard
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
771 3217cb42 Panagiotis Issaris
772
/**
773
 * Allocates all the structures needed to read an input stream.
774
 *        This does not open the needed codecs for decoding the stream[s].
775
 */
776 115329f1 Diego Biurrun
int av_open_input_stream(AVFormatContext **ic_ptr,
777
                         ByteIOContext *pb, const char *filename,
778 da24c5e3 Fabrice Bellard
                         AVInputFormat *fmt, AVFormatParameters *ap);
779 3217cb42 Panagiotis Issaris
780
/**
781 864ff8c1 Ramiro Polla
 * Open a media file as input. The codecs are not opened. Only the file
782 3217cb42 Panagiotis Issaris
 * header (if present) is read.
783
 *
784 4f57fa8c Diego Biurrun
 * @param ic_ptr The opened media file handle is put here.
785
 * @param filename filename to open
786
 * @param fmt If non-NULL, force the file format to use.
787 3217cb42 Panagiotis Issaris
 * @param buf_size optional buffer size (zero if default is OK)
788 78cb7273 Diego Biurrun
 * @param ap Additional parameters needed when opening the file
789
 *           (NULL if default).
790 4f57fa8c Diego Biurrun
 * @return 0 if OK, AVERROR_xxx otherwise
791 3217cb42 Panagiotis Issaris
 */
792 115329f1 Diego Biurrun
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
793 b9a281db Fabrice Bellard
                       AVInputFormat *fmt,
794
                       int buf_size,
795
                       AVFormatParameters *ap);
796 88a28965 Stefano Sabatini
797
#if LIBAVFORMAT_VERSION_MAJOR < 53
798
/**
799
 * @deprecated Use avformat_alloc_context() instead.
800
 */
801
attribute_deprecated AVFormatContext *av_alloc_format_context(void);
802
#endif
803
804 88808c60 Michael Niedermayer
/**
805
 * Allocate an AVFormatContext.
806 5d81d641 Diego Biurrun
 * Can be freed with av_free() but do not forget to free everything you
807 88808c60 Michael Niedermayer
 * explicitly allocated as well!
808
 */
809 88a28965 Stefano Sabatini
AVFormatContext *avformat_alloc_context(void);
810 b9a281db Fabrice Bellard
811 3217cb42 Panagiotis Issaris
/**
812
 * Read packets of a media file to get stream information. This
813
 * is useful for file formats with no headers such as MPEG. This
814 22e77e44 Diego Biurrun
 * function also computes the real framerate in case of MPEG-2 repeat
815 3217cb42 Panagiotis Issaris
 * frame mode.
816
 * The logical file position is not changed by this function;
817
 * examined packets may be buffered for later processing.
818
 *
819
 * @param ic media file handle
820 4f57fa8c Diego Biurrun
 * @return >=0 if OK, AVERROR_xxx on error
821
 * @todo Let the user decide somehow what information is needed so that
822
 *       we do not waste time getting stuff the user does not need.
823 3217cb42 Panagiotis Issaris
 */
824 b9a281db Fabrice Bellard
int av_find_stream_info(AVFormatContext *ic);
825 3217cb42 Panagiotis Issaris
826
/**
827
 * Read a transport packet from a media file.
828
 *
829 864ff8c1 Ramiro Polla
 * This function is obsolete and should never be used.
830 3217cb42 Panagiotis Issaris
 * Use av_read_frame() instead.
831
 *
832
 * @param s media file handle
833
 * @param pkt is filled
834 4f57fa8c Diego Biurrun
 * @return 0 if OK, AVERROR_xxx on error
835 3217cb42 Panagiotis Issaris
 */
836 de6d9b64 Fabrice Bellard
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
837 3217cb42 Panagiotis Issaris
838
/**
839
 * Return the next frame of a stream.
840
 *
841
 * The returned packet is valid
842
 * until the next av_read_frame() or until av_close_input_file() and
843
 * must be freed with av_free_packet. For video, the packet contains
844
 * exactly one frame. For audio, it contains an integer number of
845
 * frames if each frame has a known fixed size (e.g. PCM or ADPCM
846
 * data). If the audio frames have a variable size (e.g. MPEG audio),
847
 * then it contains one frame.
848
 *
849
 * pkt->pts, pkt->dts and pkt->duration are always set to correct
850 22e77e44 Diego Biurrun
 * values in AVStream.time_base units (and guessed if the format cannot
851 4f57fa8c Diego Biurrun
 * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
852
 * has B-frames, so it is better to rely on pkt->dts if you do not
853 3217cb42 Panagiotis Issaris
 * decompress the payload.
854
 *
855 4f57fa8c Diego Biurrun
 * @return 0 if OK, < 0 on error or end of file
856 3217cb42 Panagiotis Issaris
 */
857 fb2758c8 Fabrice Bellard
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
858 3217cb42 Panagiotis Issaris
859
/**
860 22e77e44 Diego Biurrun
 * Seek to the keyframe at timestamp.
861 3217cb42 Panagiotis Issaris
 * 'timestamp' in 'stream_index'.
862
 * @param stream_index If stream_index is (-1), a default
863
 * stream is selected, and timestamp is automatically converted
864
 * from AV_TIME_BASE units to the stream specific time_base.
865 4f57fa8c Diego Biurrun
 * @param timestamp Timestamp in AVStream.time_base units
866
 *        or, if no stream is specified, in AV_TIME_BASE units.
867 3217cb42 Panagiotis Issaris
 * @param flags flags which select direction and seeking mode
868
 * @return >= 0 on success
869
 */
870 78cb7273 Diego Biurrun
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
871
                  int flags);
872 3217cb42 Panagiotis Issaris
873
/**
874 d04768fa Michael Niedermayer
 * Seek to timestamp ts.
875
 * Seeking will be done so that the point from which all active streams
876
 * can be presented successfully will be closest to ts and within min/max_ts.
877
 * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
878
 *
879 22e77e44 Diego Biurrun
 * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
880 d04768fa Michael Niedermayer
 * are the file position (this may not be supported by all demuxers).
881 22e77e44 Diego Biurrun
 * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
882 d04768fa Michael Niedermayer
 * in the stream with stream_index (this may not be supported by all demuxers).
883 22e77e44 Diego Biurrun
 * Otherwise all timestamps are in units of the stream selected by stream_index
884
 * or if stream_index is -1, in AV_TIME_BASE units.
885
 * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
886 d04768fa Michael Niedermayer
 * keyframes (this may not be supported by all demuxers).
887
 *
888 22e77e44 Diego Biurrun
 * @param stream_index index of the stream which is used as time base reference
889 d04768fa Michael Niedermayer
 * @param min_ts smallest acceptable timestamp
890
 * @param ts target timestamp
891
 * @param max_ts largest acceptable timestamp
892
 * @param flags flags
893
 * @returns >=0 on success, error code otherwise
894 998b6f7c Michael Niedermayer
 *
895 22e77e44 Diego Biurrun
 * @NOTE This is part of the new seek API which is still under construction.
896
 *       Thus do not use this yet. It may change at any time, do not expect
897
 *       ABI compatibility yet!
898 d04768fa Michael Niedermayer
 */
899
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
900
901
/**
902 22e77e44 Diego Biurrun
 * Start playing a network-based stream (e.g. RTSP stream) at the
903 4f57fa8c Diego Biurrun
 * current position.
904 3217cb42 Panagiotis Issaris
 */
905 fb2758c8 Fabrice Bellard
int av_read_play(AVFormatContext *s);
906 3217cb42 Panagiotis Issaris
907
/**
908 22e77e44 Diego Biurrun
 * Pause a network-based stream (e.g. RTSP stream).
909 3217cb42 Panagiotis Issaris
 *
910
 * Use av_read_play() to resume it.
911
 */
912 fb2758c8 Fabrice Bellard
int av_read_pause(AVFormatContext *s);
913 3217cb42 Panagiotis Issaris
914
/**
915 2506fd54 Reimar Döffinger
 * Free a AVFormatContext allocated by av_open_input_stream.
916
 * @param s context to free
917
 */
918
void av_close_input_stream(AVFormatContext *s);
919
920
/**
921 3217cb42 Panagiotis Issaris
 * Close a media file (but not its codecs).
922
 *
923
 * @param s media file handle
924
 */
925 de6d9b64 Fabrice Bellard
void av_close_input_file(AVFormatContext *s);
926 3217cb42 Panagiotis Issaris
927
/**
928
 * Add a new stream to a media file.
929
 *
930
 * Can only be called in the read_header() function. If the flag
931
 * AVFMTCTX_NOHEADER is in the format context, then new streams
932
 * can be added in read_packet too.
933
 *
934
 * @param s media file handle
935 4f57fa8c Diego Biurrun
 * @param id file-format-dependent stream ID
936 3217cb42 Panagiotis Issaris
 */
937 b9a281db Fabrice Bellard
AVStream *av_new_stream(AVFormatContext *s, int id);
938 15afa396 Nico Sabbi
AVProgram *av_new_program(AVFormatContext *s, int id);
939 3217cb42 Panagiotis Issaris
940
/**
941 79d7836a Anton Khirnov
 * Add a new chapter.
942
 * This function is NOT part of the public API
943 4f57fa8c Diego Biurrun
 * and should ONLY be used by demuxers.
944 79d7836a Anton Khirnov
 *
945
 * @param s media file handle
946 4f57fa8c Diego Biurrun
 * @param id unique ID for this chapter
947 abd2256d Michael Niedermayer
 * @param start chapter start time in time_base units
948
 * @param end chapter end time in time_base units
949 79d7836a Anton Khirnov
 * @param title chapter title
950 5c37f43a Michael Niedermayer
 *
951 4f57fa8c Diego Biurrun
 * @return AVChapter or NULL on error
952 79d7836a Anton Khirnov
 */
953 78cb7273 Diego Biurrun
AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
954
                          int64_t start, int64_t end, const char *title);
955 79d7836a Anton Khirnov
956
/**
957 3217cb42 Panagiotis Issaris
 * Set the pts for a given stream.
958
 *
959
 * @param s stream
960
 * @param pts_wrap_bits number of bits effectively used by the pts
961
 *        (used for wrap control, 33 is the value for MPEG)
962
 * @param pts_num numerator to convert to seconds (MPEG: 1)
963
 * @param pts_den denominator to convert to seconds (MPEG: 90000)
964
 */
965 9ee91c2f Michael Niedermayer
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
966 916c80e9 Fabrice Bellard
                     int pts_num, int pts_den);
967 de6d9b64 Fabrice Bellard
968 3ba1438d Michael Niedermayer
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
969
#define AVSEEK_FLAG_BYTE     2 ///< seeking based on position in bytes
970 4f57fa8c Diego Biurrun
#define AVSEEK_FLAG_ANY      4 ///< seek to any frame, even non-keyframes
971 3ba1438d Michael Niedermayer
972 b754978a Michael Niedermayer
int av_find_default_stream_index(AVFormatContext *s);
973 3217cb42 Panagiotis Issaris
974
/**
975
 * Gets the index for a specific timestamp.
976 4f57fa8c Diego Biurrun
 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
977
 *                 to the timestamp which is <= the requested one, if backward
978
 *                 is 0, then it will be >=
979 3217cb42 Panagiotis Issaris
 *              if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
980
 * @return < 0 if no such timestamp could be found
981
 */
982 dc56fc38 Michael Niedermayer
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
983 3217cb42 Panagiotis Issaris
984
/**
985 3dea63bd Paul Kelly
 * Ensures the index uses less memory than the maximum specified in
986 22e77e44 Diego Biurrun
 * AVFormatContext.max_index_size by discarding entries if it grows
987 3dea63bd Paul Kelly
 * too large.
988
 * This function is not part of the public API and should only be called
989
 * by demuxers.
990
 */
991
void ff_reduce_index(AVFormatContext *s, int stream_index);
992
993
/**
994 4f57fa8c Diego Biurrun
 * Add an index entry into a sorted list. Update the entry if the list
995
 * already contains it.
996 3217cb42 Panagiotis Issaris
 *
997 4f57fa8c Diego Biurrun
 * @param timestamp timestamp in the time base of the given stream
998 3217cb42 Panagiotis Issaris
 */
999 78cb7273 Diego Biurrun
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1000
                       int size, int distance, int flags);
1001 3217cb42 Panagiotis Issaris
1002
/**
1003 78cb7273 Diego Biurrun
 * Does a binary search using av_index_search_timestamp() and
1004
 * AVCodec.read_timestamp().
1005
 * This is not supposed to be called directly by a user application,
1006
 * but by demuxers.
1007 3217cb42 Panagiotis Issaris
 * @param target_ts target timestamp in the time base of the given stream
1008
 * @param stream_index stream number
1009
 */
1010 78cb7273 Diego Biurrun
int av_seek_frame_binary(AVFormatContext *s, int stream_index,
1011
                         int64_t target_ts, int flags);
1012 3217cb42 Panagiotis Issaris
1013
/**
1014 4f57fa8c Diego Biurrun
 * Updates cur_dts of all streams based on the given timestamp and AVStream.
1015 3217cb42 Panagiotis Issaris
 *
1016 4f57fa8c Diego Biurrun
 * Stream ref_st unchanged, others set cur_dts in their native time base.
1017
 * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
1018 3217cb42 Panagiotis Issaris
 * @param timestamp new dts expressed in time_base of param ref_st
1019
 * @param ref_st reference stream giving time_base of param timestamp
1020
 */
1021 22ffac70 Reimar Döffinger
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
1022 3217cb42 Panagiotis Issaris
1023
/**
1024
 * Does a binary search using read_timestamp().
1025 78cb7273 Diego Biurrun
 * This is not supposed to be called directly by a user application,
1026
 * but by demuxers.
1027 3217cb42 Panagiotis Issaris
 * @param target_ts target timestamp in the time base of the given stream
1028
 * @param stream_index stream number
1029
 */
1030 78cb7273 Diego Biurrun
int64_t av_gen_search(AVFormatContext *s, int stream_index,
1031
                      int64_t target_ts, int64_t pos_min,
1032
                      int64_t pos_max, int64_t pos_limit,
1033
                      int64_t ts_min, int64_t ts_max,
1034
                      int flags, int64_t *ts_ret,
1035
                      int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
1036 b754978a Michael Niedermayer
1037 43d414ba Panagiotis Issaris
/** media file output */
1038 290c5fa6 Fabrice Bellard
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1039 3217cb42 Panagiotis Issaris
1040
/**
1041 755bfeab Diego Biurrun
 * Allocate the stream private data and write the stream header to an
1042
 * output media file.
1043 3217cb42 Panagiotis Issaris
 *
1044
 * @param s media file handle
1045 4f57fa8c Diego Biurrun
 * @return 0 if OK, AVERROR_xxx on error
1046 3217cb42 Panagiotis Issaris
 */
1047 b9a281db Fabrice Bellard
int av_write_header(AVFormatContext *s);
1048 3217cb42 Panagiotis Issaris
1049
/**
1050
 * Write a packet to an output media file.
1051
 *
1052
 * The packet shall contain one audio or video frame.
1053 78cb7273 Diego Biurrun
 * The packet must be correctly interleaved according to the container
1054
 * specification, if not then av_interleaved_write_frame must be used.
1055 3217cb42 Panagiotis Issaris
 *
1056
 * @param s media file handle
1057 78cb7273 Diego Biurrun
 * @param pkt The packet, which contains the stream_index, buf/buf_size,
1058
              dts/pts, ...
1059 4f57fa8c Diego Biurrun
 * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
1060 3217cb42 Panagiotis Issaris
 */
1061 e928649b Michael Niedermayer
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
1062 3217cb42 Panagiotis Issaris
1063
/**
1064
 * Writes a packet to an output media file ensuring correct interleaving.
1065
 *
1066
 * The packet must contain one audio or video frame.
1067 22e77e44 Diego Biurrun
 * If the packets are already correctly interleaved, the application should
1068 90b5b51e Diego Biurrun
 * call av_write_frame() instead as it is slightly faster. It is also important
1069
 * to keep in mind that completely non-interleaved input will need huge amounts
1070
 * of memory to interleave with this, so it is preferable to interleave at the
1071
 * demuxer level.
1072 3217cb42 Panagiotis Issaris
 *
1073
 * @param s media file handle
1074 78cb7273 Diego Biurrun
 * @param pkt The packet, which contains the stream_index, buf/buf_size,
1075
              dts/pts, ...
1076 4f57fa8c Diego Biurrun
 * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
1077 3217cb42 Panagiotis Issaris
 */
1078 3c895fc0 Michael Niedermayer
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
1079 3217cb42 Panagiotis Issaris
1080
/**
1081 4f57fa8c Diego Biurrun
 * Interleave a packet per dts in an output media file.
1082 3217cb42 Panagiotis Issaris
 *
1083 78cb7273 Diego Biurrun
 * Packets with pkt->destruct == av_destruct_packet will be freed inside this
1084 22e77e44 Diego Biurrun
 * function, so they cannot be used after it. Note that calling av_free_packet()
1085 78cb7273 Diego Biurrun
 * on them is still safe.
1086 3217cb42 Panagiotis Issaris
 *
1087
 * @param s media file handle
1088
 * @param out the interleaved packet will be output here
1089
 * @param in the input packet
1090
 * @param flush 1 if no further packets are available as input and all
1091
 *              remaining packets should be output
1092
 * @return 1 if a packet was output, 0 if no packet could be output,
1093 d9526386 Diego Biurrun
 *         < 0 if an error occurred
1094 3217cb42 Panagiotis Issaris
 */
1095 78cb7273 Diego Biurrun
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
1096
                                 AVPacket *pkt, int flush);
1097 e928649b Michael Niedermayer
1098 3217cb42 Panagiotis Issaris
/**
1099
 * @brief Write the stream trailer to an output media file and
1100
 *        free the file private data.
1101
 *
1102 dc76fe13 Reimar Döffinger
 * May only be called after a successful call to av_write_header.
1103
 *
1104 3217cb42 Panagiotis Issaris
 * @param s media file handle
1105 4f57fa8c Diego Biurrun
 * @return 0 if OK, AVERROR_xxx on error
1106 3217cb42 Panagiotis Issaris
 */
1107 b9a281db Fabrice Bellard
int av_write_trailer(AVFormatContext *s);
1108 de6d9b64 Fabrice Bellard
1109
void dump_format(AVFormatContext *ic,
1110 115329f1 Diego Biurrun
                 int index,
1111 de6d9b64 Fabrice Bellard
                 const char *url,
1112
                 int is_output);
1113 3217cb42 Panagiotis Issaris
1114 1ca9133f Stefano Sabatini
#if LIBAVFORMAT_VERSION_MAJOR < 53
1115 3217cb42 Panagiotis Issaris
/**
1116 4f57fa8c Diego Biurrun
 * Parses width and height out of string str.
1117 26ef3220 Stefano Sabatini
 * @deprecated Use av_parse_video_frame_size instead.
1118 3217cb42 Panagiotis Issaris
 */
1119 78cb7273 Diego Biurrun
attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
1120
                                          const char *str);
1121 3217cb42 Panagiotis Issaris
1122
/**
1123 22e77e44 Diego Biurrun
 * Converts framerate from a string to a fraction.
1124 26ef3220 Stefano Sabatini
 * @deprecated Use av_parse_video_frame_rate instead.
1125 3217cb42 Panagiotis Issaris
 */
1126 78cb7273 Diego Biurrun
attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
1127
                                          const char *arg);
1128 1ca9133f Stefano Sabatini
#endif
1129 3217cb42 Panagiotis Issaris
1130
/**
1131 819174fa Stefano Sabatini
 * Parses datestr and returns a corresponding number of microseconds.
1132 f9436161 Stefano Sabatini
 * @param datestr String representing a date or a duration.
1133
 * - If a date the syntax is:
1134 3217cb42 Panagiotis Issaris
 * @code
1135
 *  [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
1136
 * @endcode
1137 4f57fa8c Diego Biurrun
 * Time is local time unless Z is appended, in which case it is
1138 f9436161 Stefano Sabatini
 * interpreted as UTC.
1139 4f57fa8c Diego Biurrun
 * If the year-month-day part is not specified it takes the current
1140 f9436161 Stefano Sabatini
 * year-month-day.
1141
 * Returns the number of microseconds since 1st of January, 1970 up to
1142 819174fa Stefano Sabatini
 * the time of the parsed date or INT64_MIN if datestr cannot be
1143 f9436161 Stefano Sabatini
 * successfully parsed.
1144
 * - If a duration the syntax is:
1145
 * @code
1146
 *  [-]HH[:MM[:SS[.m...]]]
1147
 *  [-]S+[.m...]
1148
 * @endcode
1149
 * Returns the number of microseconds contained in a time interval
1150 819174fa Stefano Sabatini
 * with the specified duration or INT64_MIN if datestr cannot be
1151 7338d368 Diego Biurrun
 * successfully parsed.
1152 819174fa Stefano Sabatini
 * @param duration Flag which tells how to interpret datestr, if
1153
 * not zero datestr is interpreted as a duration, otherwise as a
1154 f9436161 Stefano Sabatini
 * date.
1155 3217cb42 Panagiotis Issaris
 */
1156 0c1a9eda Zdenek Kabelac
int64_t parse_date(const char *datestr, int duration);
1157 de6d9b64 Fabrice Bellard
1158 fff5e687 Diego Biurrun
/** Gets the current time in microseconds. */
1159 0c1a9eda Zdenek Kabelac
int64_t av_gettime(void);
1160 94988531 Fabrice Bellard
1161 4f57fa8c Diego Biurrun
/* ffm-specific for ffserver */
1162 de6d9b64 Fabrice Bellard
#define FFM_PACKET_SIZE 4096
1163 bc5c918e Diego Biurrun
int64_t ffm_read_write_index(int fd);
1164 6fcce4f9 Patrik Kullman
int ffm_write_write_index(int fd, int64_t pos);
1165 bc5c918e Diego Biurrun
void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
1166 de6d9b64 Fabrice Bellard
1167 3217cb42 Panagiotis Issaris
/**
1168
 * Attempts to find a specific tag in a URL.
1169
 *
1170
 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
1171
 * Return 1 if found.
1172
 */
1173 de6d9b64 Fabrice Bellard
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1174
1175 3217cb42 Panagiotis Issaris
/**
1176 22e77e44 Diego Biurrun
 * Returns in 'buf' the path with '%d' replaced by a number.
1177 4f57fa8c Diego Biurrun
 *
1178 3217cb42 Panagiotis Issaris
 * Also handles the '%0nd' format where 'n' is the total number
1179
 * of digits and '%%'.
1180
 *
1181
 * @param buf destination buffer
1182
 * @param buf_size destination buffer size
1183
 * @param path numbered sequence string
1184 8ea0e802 Panagiotis Issaris
 * @param number frame number
1185 4f57fa8c Diego Biurrun
 * @return 0 if OK, -1 on format error
1186 3217cb42 Panagiotis Issaris
 */
1187 5c07cf53 Michel Bardiaux
int av_get_frame_filename(char *buf, int buf_size,
1188
                          const char *path, int number);
1189 3217cb42 Panagiotis Issaris
1190
/**
1191
 * Check whether filename actually is a numbered sequence generator.
1192
 *
1193
 * @param filename possible numbered sequence string
1194 4f57fa8c Diego Biurrun
 * @return 1 if a valid numbered sequence string, 0 otherwise
1195 3217cb42 Panagiotis Issaris
 */
1196 5c07cf53 Michel Bardiaux
int av_filename_number_test(const char *filename);
1197 96baaa6a Fabrice Bellard
1198 c5388c07 Luca Abeni
/**
1199
 * Generate an SDP for an RTP session.
1200
 *
1201
 * @param ac array of AVFormatContexts describing the RTP streams. If the
1202
 *           array is composed by only one context, such context can contain
1203
 *           multiple AVStreams (one AVStream per RTP stream). Otherwise,
1204
 *           all the contexts in the array (an AVCodecContext per RTP stream)
1205 4f57fa8c Diego Biurrun
 *           must contain only one AVStream.
1206 8767b80f Luca Abeni
 * @param n_files number of AVCodecContexts contained in ac
1207
 * @param buff buffer where the SDP will be stored (must be allocated by
1208 4f57fa8c Diego Biurrun
 *             the caller)
1209 8767b80f Luca Abeni
 * @param size the size of the buffer
1210 4f57fa8c Diego Biurrun
 * @return 0 if OK, AVERROR_xxx on error
1211 c5388c07 Luca Abeni
 */
1212 8767b80f Luca Abeni
int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1213 c5388c07 Luca Abeni
1214 fb025625 Fabrice Bellard
#ifdef HAVE_AV_CONFIG_H
1215 f71869a4 Fabrice Bellard
1216 2db5da97 Ramiro Polla
void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
1217 39f472c3 Fabrice Bellard
1218 e4e70d2e Falk Hüffner
#ifdef __GNUC__
1219 39f472c3 Fabrice Bellard
#define dynarray_add(tab, nb_ptr, elem)\
1220
do {\
1221 72ab9d7f Diego Pettenò
    __typeof__(tab) _tab = (tab);\
1222
    __typeof__(elem) _elem = (elem);\
1223 39f472c3 Fabrice Bellard
    (void)sizeof(**_tab == _elem); /* check that types are compatible */\
1224 2db5da97 Ramiro Polla
    ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
1225 39f472c3 Fabrice Bellard
} while(0)
1226 e4e70d2e Falk Hüffner
#else
1227
#define dynarray_add(tab, nb_ptr, elem)\
1228
do {\
1229 2db5da97 Ramiro Polla
    ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
1230 e4e70d2e Falk Hüffner
} while(0)
1231
#endif
1232 39f472c3 Fabrice Bellard
1233 f71869a4 Fabrice Bellard
time_t mktimegm(struct tm *tm);
1234 0c9fc6e1 Roman Shaposhnik
struct tm *brktimegm(time_t secs, struct tm *tm);
1235 115329f1 Diego Biurrun
const char *small_strptime(const char *p, const char *fmt,
1236 f71869a4 Fabrice Bellard
                           struct tm *dt);
1237
1238 fb025625 Fabrice Bellard
struct in_addr;
1239
int resolve_host(struct in_addr *sin_addr, const char *hostname);
1240
1241
void url_split(char *proto, int proto_size,
1242 6ba5cbc6 Petr Doubek
               char *authorization, int authorization_size,
1243 fb025625 Fabrice Bellard
               char *hostname, int hostname_size,
1244
               int *port_ptr,
1245
               char *path, int path_size,
1246
               const char *url);
1247
1248 a3303178 Stefano Sabatini
/**
1249
 * Returns a positive value if the given filename has one of the given
1250
 * extensions, 0 otherwise.
1251
 *
1252
 * @param extensions a comma-separated list of filename extensions
1253
 */
1254 a941f391 Fabrice Bellard
int match_ext(const char *filename, const char *extensions);
1255
1256 fb025625 Fabrice Bellard
#endif /* HAVE_AV_CONFIG_H */
1257
1258 98790382 Stefano Sabatini
#endif /* AVFORMAT_AVFORMAT_H */