Statistics
| Branch: | Revision:

ffmpeg / libavformat / avformat.h @ a181981e

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