Commit | Line | Data |
---|---|---|
04d7f601 DB |
1 | /* |
2 | * copyright (c) 2001 Fabrice Bellard | |
3 | * | |
2912e87a | 4 | * This file is part of Libav. |
b78e7197 | 5 | * |
2912e87a | 6 | * Libav is free software; you can redistribute it and/or |
04d7f601 DB |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either | |
b78e7197 | 9 | * version 2.1 of the License, or (at your option) any later version. |
04d7f601 | 10 | * |
2912e87a | 11 | * Libav is distributed in the hope that it will be useful, |
04d7f601 DB |
12 | * 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 | |
2912e87a | 17 | * License along with Libav; if not, write to the Free Software |
04d7f601 DB |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ | |
20 | ||
98790382 SS |
21 | #ifndef AVFORMAT_AVFORMAT_H |
22 | #define AVFORMAT_AVFORMAT_H | |
de6d9b64 | 23 | |
e361b508 | 24 | /** |
eca06cbe AK |
25 | * @file |
26 | * @ingroup libavf | |
27 | * Main libavformat public API header | |
28 | */ | |
29 | ||
30 | /** | |
e361b508 LB |
31 | * @defgroup libavf I/O and Muxing/Demuxing Library |
32 | * @{ | |
33 | * | |
34 | * @defgroup lavf_decoding Demuxing | |
35 | * @{ | |
36 | * @} | |
37 | * | |
38 | * @defgroup lavf_encoding Muxing | |
39 | * @{ | |
40 | * @} | |
41 | * | |
e4f4a1f9 | 42 | * @defgroup lavf_io I/O Read/Write |
e361b508 LB |
43 | * @{ |
44 | * @} | |
45 | * | |
46 | * @defgroup lavf_codec Demuxers | |
47 | * @{ | |
48 | * @defgroup lavf_codec_native Native Demuxers | |
49 | * @{ | |
50 | * @} | |
51 | * @defgroup lavf_codec_wrappers External library wrappers | |
52 | * @{ | |
53 | * @} | |
54 | * @} | |
55 | * @defgroup lavf_protos I/O Protocols | |
56 | * @{ | |
57 | * @} | |
58 | * @defgroup lavf_internal Internal | |
59 | * @{ | |
60 | * @} | |
61 | * @} | |
62 | * | |
63 | */ | |
072e3efd | 64 | |
f71869a4 | 65 | #include <time.h> |
67070e4f | 66 | #include <stdio.h> /* FILE */ |
76a448ed | 67 | #include "libavcodec/avcodec.h" |
d9f80ea2 | 68 | #include "libavutil/dict.h" |
abc78a5a | 69 | #include "libavutil/log.h" |
de6d9b64 | 70 | |
de6d9b64 | 71 | #include "avio.h" |
50196a98 | 72 | #include "libavformat/version.h" |
de6d9b64 | 73 | |
f610a9f2 AJ |
74 | struct AVFormatContext; |
75 | ||
a6d18a0e | 76 | |
1a53a438 RT |
77 | /** |
78 | * @defgroup metadata_api Public Metadata API | |
79 | * @{ | |
b262a059 | 80 | * @ingroup libavf |
ea29242c | 81 | * The metadata API allows libavformat to export metadata tags to a client |
28b4c06b AK |
82 | * application when demuxing. Conversely it allows a client application to |
83 | * set metadata when muxing. | |
84 | * | |
85 | * Metadata is exported or set as pairs of key/value strings in the 'metadata' | |
86 | * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs | |
87 | * using the @ref lavu_dict "AVDictionary" API. Like all strings in Libav, | |
88 | * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata | |
61648423 | 89 | * exported by demuxers isn't checked to be valid UTF-8 in most cases. |
28b4c06b | 90 | * |
ea29242c | 91 | * Important concepts to keep in mind: |
1a53a438 | 92 | * - Keys are unique; there can never be 2 tags with the same key. This is |
ea29242c MM |
93 | * also meant semantically, i.e., a demuxer should not knowingly produce |
94 | * several keys that are literally different but semantically identical. | |
95 | * E.g., key=Author5, key=Author6. In this example, all authors must be | |
96 | * placed in the same tag. | |
1a53a438 | 97 | * - Metadata is flat, not hierarchical; there are no subtags. If you |
ea29242c MM |
98 | * want to store, e.g., the email address of the child of producer Alice |
99 | * and actor Bob, that could have key=alice_and_bobs_childs_email_address. | |
1a53a438 | 100 | * - Several modifiers can be applied to the tag name. This is done by |
ca76a119 AK |
101 | * appending a dash character ('-') and the modifier name in the order |
102 | * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. | |
1a53a438 | 103 | * - language -- a tag whose value is localized for a particular language |
ca76a119 AK |
104 | * is appended with the ISO 639-2/B 3-letter language code. |
105 | * For example: Author-ger=Michael, Author-eng=Mike | |
106 | * The original/default language is in the unqualified "Author" tag. | |
107 | * A demuxer should set a default if it sets any translated tag. | |
1a53a438 | 108 | * - sorting -- a modified version of a tag that should be used for |
ca76a119 AK |
109 | * sorting will have '-sort' appended. E.g. artist="The Beatles", |
110 | * artist-sort="Beatles, The". | |
111 | * | |
1a53a438 | 112 | * - Demuxers attempt to export metadata in a generic format, however tags |
03700d39 AK |
113 | * with no generic equivalents are left as they are stored in the container. |
114 | * Follows a list of generic tag names: | |
ca76a119 | 115 | * |
1a53a438 RT |
116 | @verbatim |
117 | album -- name of the set this work belongs to | |
118 | album_artist -- main creator of the set/album, if different from artist. | |
119 | e.g. "Various Artists" for compilation albums. | |
120 | artist -- main creator of the work | |
121 | comment -- any additional description of the file. | |
122 | composer -- who composed the work, if different from artist. | |
123 | copyright -- name of copyright holder. | |
124 | creation_time-- date when the file was created, preferably in ISO 8601. | |
125 | date -- date when the work was created, preferably in ISO 8601. | |
126 | disc -- number of a subset, e.g. disc in a multi-disc collection. | |
127 | encoder -- name/settings of the software/hardware that produced the file. | |
128 | encoded_by -- person/group who created the file. | |
129 | filename -- original name of the file. | |
130 | genre -- <self-evident>. | |
131 | language -- main language in which the work is performed, preferably | |
132 | in ISO 639-2 format. Multiple languages can be specified by | |
133 | separating them with commas. | |
134 | performer -- artist who performed the work, if different from artist. | |
135 | E.g for "Also sprach Zarathustra", artist would be "Richard | |
136 | Strauss" and performer "London Philharmonic Orchestra". | |
137 | publisher -- name of the label/publisher. | |
138 | service_name -- name of the service in broadcasting (channel name). | |
139 | service_provider -- name of the service provider in broadcasting. | |
140 | title -- name of the work. | |
141 | track -- number of this work in the set, can be in form current/total. | |
142 | variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of | |
143 | @endverbatim | |
144 | * | |
12489443 RT |
145 | * Look in the examples section for an application example how to use the Metadata API. |
146 | * | |
1a53a438 | 147 | * @} |
a6d18a0e MN |
148 | */ |
149 | ||
d9f80ea2 AK |
150 | #if FF_API_OLD_METADATA2 |
151 | /** | |
152 | * @defgroup old_metadata Old metadata API | |
153 | * The following functions are deprecated, use | |
154 | * their equivalents from libavutil/dict.h instead. | |
155 | * @{ | |
156 | */ | |
a6d18a0e | 157 | |
d9f80ea2 AK |
158 | #define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE |
159 | #define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX | |
160 | #define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY | |
161 | #define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL | |
162 | #define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE | |
163 | ||
164 | typedef attribute_deprecated AVDictionary AVMetadata; | |
165 | typedef attribute_deprecated AVDictionaryEntry AVMetadataTag; | |
a6d18a0e | 166 | |
f610a9f2 | 167 | typedef struct AVMetadataConv AVMetadataConv; |
a6d18a0e MN |
168 | |
169 | /** | |
49bd8e4b | 170 | * Get a metadata element with matching key. |
26cc5310 | 171 | * |
22e77e44 | 172 | * @param prev Set to the previous matching element to find the next. |
66b6c745 | 173 | * If set to NULL the first matching element is returned. |
22e77e44 DB |
174 | * @param flags Allows case as well as suffix-insensitive comparisons. |
175 | * @return Found tag or NULL, changing key or value leads to undefined behavior. | |
a6d18a0e | 176 | */ |
d9f80ea2 AK |
177 | attribute_deprecated AVDictionaryEntry * |
178 | av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); | |
a6d18a0e | 179 | |
a181981e | 180 | /** |
32e6f246 | 181 | * Set the given tag in *pm, overwriting an existing tag. |
26cc5310 | 182 | * |
983ec304 SS |
183 | * @param pm pointer to a pointer to a metadata struct. If *pm is NULL |
184 | * a metadata struct is allocated and put in *pm. | |
32e6f246 SS |
185 | * @param key tag key to add to *pm (will be av_strduped depending on flags) |
186 | * @param value tag value to add to *pm (will be av_strduped depending on flags). | |
160c896c | 187 | * Passing a NULL value will cause an existing tag to be deleted. |
a181981e MN |
188 | * @return >= 0 on success otherwise an error code <0 |
189 | */ | |
d9f80ea2 | 190 | attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags); |
a6d18a0e | 191 | |
094d9df7 | 192 | /** |
03700d39 | 193 | * This function is provided for compatibility reason and currently does nothing. |
f610a9f2 | 194 | */ |
03700d39 AK |
195 | attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv, |
196 | const AVMetadataConv *s_conv); | |
f610a9f2 AJ |
197 | |
198 | /** | |
d9f80ea2 AK |
199 | * Copy metadata from one AVDictionary struct into another. |
200 | * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, | |
7f88a5bf | 201 | * this function will allocate a struct for you and put it in *dst |
d9f80ea2 | 202 | * @param src pointer to source AVDictionary struct |
7f88a5bf | 203 | * @param flags flags to use when setting metadata in *dst |
d2d67e42 | 204 | * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag |
7f88a5bf | 205 | */ |
d9f80ea2 | 206 | attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags); |
7f88a5bf RB |
207 | |
208 | /** | |
d9f80ea2 | 209 | * Free all the memory allocated for an AVDictionary struct. |
094d9df7 | 210 | */ |
d9f80ea2 AK |
211 | attribute_deprecated void av_metadata_free(AVDictionary **m); |
212 | /** | |
213 | * @} | |
214 | */ | |
215 | #endif | |
094d9df7 | 216 | |
a6d18a0e | 217 | |
de6d9b64 FB |
218 | /* packet functions */ |
219 | ||
3217cb42 PI |
220 | |
221 | /** | |
49bd8e4b | 222 | * Allocate and read the payload of a packet and initialize its |
d1b9adf2 | 223 | * fields with default values. |
3217cb42 PI |
224 | * |
225 | * @param pkt packet | |
4f57fa8c DB |
226 | * @param size desired payload size |
227 | * @return >0 (read size) if OK, AVERROR_xxx otherwise | |
3217cb42 | 228 | */ |
ae628ec1 | 229 | int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); |
3217cb42 | 230 | |
de6d9b64 | 231 | |
6bfc2683 | 232 | /** |
fa8cc126 RD |
233 | * Read data and append it to the current content of the AVPacket. |
234 | * If pkt->size is 0 this is identical to av_get_packet. | |
6bfc2683 RD |
235 | * Note that this uses av_grow_packet and thus involves a realloc |
236 | * which is inefficient. Thus this function should only be used | |
237 | * when there is no reasonable way to know (an upper bound of) | |
238 | * the final size. | |
239 | * | |
240 | * @param pkt packet | |
241 | * @param size amount of data to read | |
242 | * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data | |
243 | * will not be lost even if an error occurs. | |
244 | */ | |
ae628ec1 | 245 | int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); |
6bfc2683 | 246 | |
de6d9b64 | 247 | /*************************************************/ |
916c80e9 FB |
248 | /* fractional numbers for exact pts handling */ |
249 | ||
671adb17 | 250 | /** |
4f57fa8c DB |
251 | * The exact value of the fractional number is: 'val + num / den'. |
252 | * num is assumed to be 0 <= num < den. | |
4c08b2bd | 253 | */ |
916c80e9 | 254 | typedef struct AVFrac { |
115329f1 | 255 | int64_t val, num, den; |
52e57500 | 256 | } AVFrac; |
916c80e9 | 257 | |
916c80e9 | 258 | /*************************************************/ |
b9a281db | 259 | /* input/output formats */ |
de6d9b64 | 260 | |
7caf0cc6 MN |
261 | struct AVCodecTag; |
262 | ||
76c56376 MN |
263 | /** |
264 | * This structure contains the data a format has to probe a file. | |
265 | */ | |
b9a281db | 266 | typedef struct AVProbeData { |
5c91a675 | 267 | const char *filename; |
e5f58f81 | 268 | unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */ |
269 | int buf_size; /**< Size of buf except extra allocated bytes */ | |
b9a281db FB |
270 | } AVProbeData; |
271 | ||
22e77e44 | 272 | #define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection |
87e87886 | 273 | #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer |
de6d9b64 FB |
274 | |
275 | typedef struct AVFormatParameters { | |
bffd4dd1 | 276 | #if FF_API_FORMAT_PARAMETERS |
b2592ea4 | 277 | attribute_deprecated AVRational time_base; |
bffd4dd1 AK |
278 | attribute_deprecated int sample_rate; |
279 | attribute_deprecated int channels; | |
89d1b7f4 AK |
280 | attribute_deprecated int width; |
281 | attribute_deprecated int height; | |
f91ccb1d | 282 | attribute_deprecated enum PixelFormat pix_fmt; |
d20576d0 | 283 | attribute_deprecated int channel; /**< Used to select DV channel. */ |
fc68a8f7 | 284 | attribute_deprecated const char *standard; /**< deprecated, use demuxer-specific options instead. */ |
fb37d573 | 285 | attribute_deprecated unsigned int mpeg2ts_raw:1; /**< deprecated, use mpegtsraw demuxer */ |
17a5556d AK |
286 | /**< deprecated, use mpegtsraw demuxer-specific options instead */ |
287 | attribute_deprecated unsigned int mpeg2ts_compute_pcr:1; | |
4779f593 AK |
288 | attribute_deprecated unsigned int initial_pause:1; /**< Do not begin to play the stream |
289 | immediately (RTSP only). */ | |
603b8bc2 | 290 | attribute_deprecated unsigned int prealloced_context:1; |
17a5556d | 291 | #endif |
de6d9b64 FB |
292 | } AVFormatParameters; |
293 | ||
c68fafe0 | 294 | /// Demuxer will use avio_open, no opened file should be provided by the caller. |
40d9c544 | 295 | #define AVFMT_NOFILE 0x0001 |
4f57fa8c DB |
296 | #define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ |
297 | #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ | |
298 | #define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for | |
299 | raw picture data. */ | |
300 | #define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ | |
301 | #define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ | |
302 | #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ | |
58ec7e00 | 303 | #define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */ |
25918212 | 304 | #define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ |
ab5a0175 | 305 | #define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ |
bb62d5c1 | 306 | #define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ |
69fa2396 VP |
307 | #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ |
308 | #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ | |
b631fba9 | 309 | #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ |
b9a281db | 310 | |
489a7b07 AK |
311 | /** |
312 | * @addtogroup lavf_encoding | |
313 | * @{ | |
314 | */ | |
b9a281db | 315 | typedef struct AVOutputFormat { |
de6d9b64 | 316 | const char *name; |
bde15e74 SS |
317 | /** |
318 | * Descriptive name for the format, meant to be more human-readable | |
819174fa | 319 | * than name. You should use the NULL_IF_CONFIG_SMALL() macro |
bde15e74 SS |
320 | * to define it. |
321 | */ | |
de6d9b64 FB |
322 | const char *long_name; |
323 | const char *mime_type; | |
4f57fa8c | 324 | const char *extensions; /**< comma-separated filename extensions */ |
76c56376 MN |
325 | /** |
326 | * size of private data so that it can be allocated in the wrapper | |
327 | */ | |
b9a281db | 328 | int priv_data_size; |
de6d9b64 | 329 | /* output support */ |
43d414ba PI |
330 | enum CodecID audio_codec; /**< default audio codec */ |
331 | enum CodecID video_codec; /**< default video codec */ | |
de6d9b64 | 332 | int (*write_header)(struct AVFormatContext *); |
e928649b | 333 | int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); |
de6d9b64 | 334 | int (*write_trailer)(struct AVFormatContext *); |
76c56376 | 335 | /** |
89e568fe AH |
336 | * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, |
337 | * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, | |
338 | * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS | |
76c56376 | 339 | */ |
b9a281db | 340 | int flags; |
76c56376 MN |
341 | /** |
342 | * Currently only used to set pixel format if not YUV420P. | |
343 | */ | |
290c5fa6 | 344 | int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); |
78cb7273 DB |
345 | int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, |
346 | AVPacket *in, int flush); | |
7caf0cc6 MN |
347 | |
348 | /** | |
78cb7273 | 349 | * List of supported codec_id-codec_tag pairs, ordered by "better |
22e77e44 | 350 | * choice first". The arrays are all terminated by CODEC_ID_NONE. |
7caf0cc6 | 351 | */ |
c1854592 | 352 | const struct AVCodecTag * const *codec_tag; |
7caf0cc6 | 353 | |
11bf3847 AJ |
354 | enum CodecID subtitle_codec; /**< default subtitle codec */ |
355 | ||
451d566f | 356 | #if FF_API_OLD_METADATA2 |
719e721a | 357 | const AVMetadataConv *metadata_conv; |
03700d39 | 358 | #endif |
f610a9f2 | 359 | |
cf99e4aa AH |
360 | const AVClass *priv_class; ///< AVClass for the private context |
361 | ||
48f9e457 AK |
362 | /** |
363 | * Test if the given codec can be stored in this container. | |
364 | * | |
365 | * @return 1 if the codec is supported, 0 if it is not. | |
366 | * A negative number if unknown. | |
367 | */ | |
368 | int (*query_codec)(enum CodecID id, int std_compliance); | |
369 | ||
b9a281db FB |
370 | /* private fields */ |
371 | struct AVOutputFormat *next; | |
372 | } AVOutputFormat; | |
489a7b07 AK |
373 | /** |
374 | * @} | |
375 | */ | |
de6d9b64 | 376 | |
370f27de AK |
377 | /** |
378 | * @addtogroup lavf_decoding | |
379 | * @{ | |
380 | */ | |
b9a281db | 381 | typedef struct AVInputFormat { |
76c56376 MN |
382 | /** |
383 | * A comma separated list of short names for the format. New names | |
ac3ccbc0 AC |
384 | * may be appended with a minor bump. |
385 | */ | |
b9a281db | 386 | const char *name; |
76c56376 | 387 | |
bde15e74 SS |
388 | /** |
389 | * Descriptive name for the format, meant to be more human-readable | |
819174fa | 390 | * than name. You should use the NULL_IF_CONFIG_SMALL() macro |
bde15e74 SS |
391 | * to define it. |
392 | */ | |
b9a281db | 393 | const char *long_name; |
76c56376 MN |
394 | |
395 | /** | |
396 | * Size of private data so that it can be allocated in the wrapper. | |
397 | */ | |
b9a281db | 398 | int priv_data_size; |
76c56376 | 399 | |
65d7d68b | 400 | /** |
22e77e44 | 401 | * Tell if a given file has a chance of being parsed as this format. |
5d81d641 DB |
402 | * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes |
403 | * big so you do not have to check for that unless you need more. | |
65d7d68b | 404 | */ |
b9a281db | 405 | int (*read_probe)(AVProbeData *); |
76c56376 MN |
406 | |
407 | /** | |
408 | * Read the format header and initialize the AVFormatContext | |
409 | * structure. Return 0 if OK. 'ap' if non-NULL contains | |
410 | * additional parameters. Only used in raw format right | |
411 | * now. 'av_new_stream' should be called to create new streams. | |
412 | */ | |
de6d9b64 FB |
413 | int (*read_header)(struct AVFormatContext *, |
414 | AVFormatParameters *ap); | |
76c56376 MN |
415 | |
416 | /** | |
417 | * Read one packet and put it in 'pkt'. pts and flags are also | |
418 | * set. 'av_new_stream' can be called only if the flag | |
2899a28c AJ |
419 | * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a |
420 | * background thread). | |
76c56376 MN |
421 | * @return 0 on success, < 0 on error. |
422 | * When returning an error, pkt must not have been allocated | |
423 | * or must be freed before returning | |
424 | */ | |
de6d9b64 | 425 | int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); |
76c56376 MN |
426 | |
427 | /** | |
428 | * Close the stream. The AVFormatContext and AVStreams are not | |
429 | * freed by this function | |
430 | */ | |
de6d9b64 | 431 | int (*read_close)(struct AVFormatContext *); |
1de2db8f | 432 | |
634e0304 | 433 | #if FF_API_READ_SEEK |
115329f1 | 434 | /** |
4f57fa8c DB |
435 | * Seek to a given timestamp relative to the frames in |
436 | * stream component stream_index. | |
22e77e44 DB |
437 | * @param stream_index Must not be -1. |
438 | * @param flags Selects which direction should be preferred if no exact | |
439 | * match is available. | |
05ce0f11 | 440 | * @return >= 0 on success (but not necessarily the new offset) |
3ba1438d | 441 | */ |
a15c7fd6 AK |
442 | attribute_deprecated int (*read_seek)(struct AVFormatContext *, |
443 | int stream_index, int64_t timestamp, int flags); | |
1de2db8f | 444 | #endif |
8d14a25c | 445 | /** |
4f57fa8c | 446 | * Gets the next timestamp in stream[stream_index].time_base units. |
d9526386 | 447 | * @return the timestamp or AV_NOPTS_VALUE if an error occurred |
8d14a25c MN |
448 | */ |
449 | int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, | |
450 | int64_t *pos, int64_t pos_limit); | |
76c56376 MN |
451 | |
452 | /** | |
050e20ae JR |
453 | * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, |
454 | * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, | |
b631fba9 | 455 | * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. |
76c56376 | 456 | */ |
de6d9b64 | 457 | int flags; |
76c56376 MN |
458 | |
459 | /** | |
460 | * If extensions are defined, then no probe is done. You should | |
461 | * usually not use extension format guessing because it is not | |
462 | * reliable enough | |
463 | */ | |
b9a281db | 464 | const char *extensions; |
76c56376 MN |
465 | |
466 | /** | |
467 | * General purpose read-only value that the format can use. | |
468 | */ | |
b9a281db | 469 | int value; |
fb2758c8 | 470 | |
76c56376 MN |
471 | /** |
472 | * Start/resume playing - only meaningful if using a network-based format | |
473 | * (RTSP). | |
474 | */ | |
fb2758c8 FB |
475 | int (*read_play)(struct AVFormatContext *); |
476 | ||
76c56376 MN |
477 | /** |
478 | * Pause playing - only meaningful if using a network-based format | |
479 | * (RTSP). | |
480 | */ | |
fb2758c8 FB |
481 | int (*read_pause)(struct AVFormatContext *); |
482 | ||
c1854592 | 483 | const struct AVCodecTag * const *codec_tag; |
7caf0cc6 | 484 | |
1de2db8f | 485 | /** |
49bd8e4b | 486 | * Seek to timestamp ts. |
1de2db8f MN |
487 | * Seeking will be done so that the point from which all active streams |
488 | * can be presented successfully will be closest to ts and within min/max_ts. | |
489 | * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. | |
490 | */ | |
882fb0a3 | 491 | int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); |
1de2db8f | 492 | |
451d566f | 493 | #if FF_API_OLD_METADATA2 |
719e721a | 494 | const AVMetadataConv *metadata_conv; |
03700d39 | 495 | #endif |
f610a9f2 | 496 | |
5dc82144 AK |
497 | const AVClass *priv_class; ///< AVClass for the private context |
498 | ||
b9a281db FB |
499 | /* private fields */ |
500 | struct AVInputFormat *next; | |
501 | } AVInputFormat; | |
370f27de AK |
502 | /** |
503 | * @} | |
504 | */ | |
de6d9b64 | 505 | |
57004ff1 AJ |
506 | enum AVStreamParseType { |
507 | AVSTREAM_PARSE_NONE, | |
508 | AVSTREAM_PARSE_FULL, /**< full parsing and repack */ | |
4f57fa8c | 509 | AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ |
78cb7273 | 510 | AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */ |
74a6df59 | 511 | AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */ |
57004ff1 AJ |
512 | }; |
513 | ||
fb2758c8 FB |
514 | typedef struct AVIndexEntry { |
515 | int64_t pos; | |
516 | int64_t timestamp; | |
517 | #define AVINDEX_KEYFRAME 0x0001 | |
30a43f2d | 518 | int flags:2; |
4f57fa8c DB |
519 | 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). |
520 | int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ | |
fb2758c8 FB |
521 | } AVIndexEntry; |
522 | ||
90c2295b ES |
523 | #define AV_DISPOSITION_DEFAULT 0x0001 |
524 | #define AV_DISPOSITION_DUB 0x0002 | |
525 | #define AV_DISPOSITION_ORIGINAL 0x0004 | |
526 | #define AV_DISPOSITION_COMMENT 0x0008 | |
527 | #define AV_DISPOSITION_LYRICS 0x0010 | |
528 | #define AV_DISPOSITION_KARAOKE 0x0020 | |
76c56376 MN |
529 | |
530 | /** | |
531 | * Track should be used during playback by default. | |
532 | * Useful for subtitle track that should be displayed | |
533 | * even when user did not explicitly ask for subtitles. | |
534 | */ | |
7a617a86 | 535 | #define AV_DISPOSITION_FORCED 0x0040 |
12c14cd4 PR |
536 | #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */ |
537 | #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ | |
24a83bd1 | 538 | #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ |
90c2295b | 539 | |
ba66ae94 MN |
540 | /** |
541 | * Stream structure. | |
542 | * New fields can be added to the end with minor version bumps. | |
8bfb108b | 543 | * Removal, reordering and changes to existing fields require a major |
ba66ae94 | 544 | * version bump. |
8bfb108b | 545 | * sizeof(AVStream) must not be used outside libav*. |
ba66ae94 | 546 | */ |
de6d9b64 | 547 | typedef struct AVStream { |
43d414ba | 548 | int index; /**< stream index in AVFormatContext */ |
4f57fa8c | 549 | int id; /**< format-specific stream ID */ |
43d414ba | 550 | AVCodecContext *codec; /**< codec context */ |
b4b87d48 | 551 | /** |
22e77e44 DB |
552 | * Real base framerate of the stream. |
553 | * This is the lowest framerate with which all timestamps can be | |
864ff8c1 | 554 | * represented accurately (it is the least common multiple of all |
22e77e44 DB |
555 | * framerates in the stream). Note, this value is just a guess! |
556 | * For example, if the time base is 1/90000 and all frames have either | |
4f57fa8c | 557 | * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. |
b4b87d48 MN |
558 | */ |
559 | AVRational r_frame_rate; | |
de6d9b64 | 560 | void *priv_data; |
82583548 | 561 | |
9a174562 | 562 | #if FF_API_REORDER_PRIVATE |
b9a281db | 563 | /* internal data used in av_find_stream_info() */ |
82583548 | 564 | int64_t first_dts; |
9a174562 | 565 | #endif |
76c56376 MN |
566 | |
567 | /** | |
568 | * encoding: pts generation when outputting stream | |
569 | */ | |
a9fd2b19 | 570 | struct AVFrac pts; |
5b28c8c3 MN |
571 | |
572 | /** | |
8bfb108b DB |
573 | * This is the fundamental unit of time (in seconds) in terms |
574 | * of which frame timestamps are represented. For fixed-fps content, | |
22e77e44 | 575 | * time base should be 1/framerate and timestamp increments should be 1. |
5d820db2 RD |
576 | * decoding: set by libavformat |
577 | * encoding: set by libavformat in av_write_header | |
5b28c8c3 | 578 | */ |
9ee91c2f | 579 | AVRational time_base; |
9a174562 | 580 | #if FF_API_REORDER_PRIVATE |
43d414ba | 581 | int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ |
9a174562 | 582 | #endif |
3d813e4c | 583 | #if FF_API_STREAM_COPY |
a48b7a6b | 584 | /* ffmpeg.c private use */ |
3d813e4c AK |
585 | attribute_deprecated int stream_copy; /**< If set, just copy stream. */ |
586 | #endif | |
4f57fa8c | 587 | enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. |
76c56376 | 588 | |
5e8d2e33 | 589 | #if FF_API_AVSTREAM_QUALITY |
b4aea108 | 590 | //FIXME move stuff to a flags field? |
76c56376 MN |
591 | /** |
592 | * Quality, as it has been removed from AVCodecContext and put in AVVideoFrame. | |
593 | * MN: dunno if that is the right place for it | |
594 | */ | |
5e8d2e33 AK |
595 | attribute_deprecated float quality; |
596 | #endif | |
76c56376 | 597 | |
6d96a9b9 | 598 | /** |
8bfb108b DB |
599 | * Decoding: pts of the first frame of the stream, in stream time base. |
600 | * Only set this if you are absolutely 100% sure that the value you set | |
601 | * it to really is the pts of the first frame. | |
4854c253 | 602 | * This may be undefined (AV_NOPTS_VALUE). |
6d96a9b9 | 603 | */ |
115329f1 | 604 | int64_t start_time; |
76c56376 | 605 | |
e26381b6 | 606 | /** |
8bfb108b | 607 | * Decoding: duration of the stream, in stream time base. |
e26381b6 | 608 | * If a source file does not specify a duration, but does specify |
4f57fa8c | 609 | * a bitrate, this value will be estimated from bitrate and file size. |
e26381b6 | 610 | */ |
ee404803 | 611 | int64_t duration; |
fb2758c8 | 612 | |
9a174562 | 613 | #if FF_API_REORDER_PRIVATE |
fb2758c8 | 614 | /* av_read_frame() support */ |
57004ff1 | 615 | enum AVStreamParseType need_parsing; |
fb2758c8 | 616 | struct AVCodecParserContext *parser; |
6ec87caa | 617 | |
fb2758c8 | 618 | int64_t cur_dts; |
635fbcb1 MN |
619 | int last_IP_duration; |
620 | int64_t last_IP_pts; | |
fb2758c8 | 621 | /* av_seek_frame() support */ |
4f57fa8c DB |
622 | AVIndexEntry *index_entries; /**< Only used if the format does not |
623 | support seeking natively. */ | |
fb2758c8 | 624 | int nb_index_entries; |
191e8ca7 | 625 | unsigned int index_entries_allocated_size; |
9a174562 | 626 | #endif |
115329f1 | 627 | |
b4b87d48 | 628 | int64_t nb_frames; ///< number of frames in this stream if known or 0 |
504ee036 | 629 | |
4f57fa8c | 630 | int disposition; /**< AV_DISPOSITION_* bit field */ |
0bef08e5 | 631 | |
9a174562 | 632 | #if FF_API_REORDER_PRIVATE |
0bef08e5 | 633 | AVProbeData probe_data; |
0d84a8f6 BC |
634 | #define MAX_REORDER_DELAY 16 |
635 | int64_t pts_buffer[MAX_REORDER_DELAY+1]; | |
9a174562 | 636 | #endif |
c30a4489 AJ |
637 | |
638 | /** | |
639 | * sample aspect ratio (0 if unknown) | |
640 | * - encoding: Set by user. | |
641 | * - decoding: Set by libavformat. | |
642 | */ | |
643 | AVRational sample_aspect_ratio; | |
f526adaf | 644 | |
d2d67e42 | 645 | AVDictionary *metadata; |
3a41c2f7 | 646 | |
9a174562 | 647 | #if FF_API_REORDER_PRIVATE |
31769dad VP |
648 | /* Intended mostly for av_read_frame() support. Not supposed to be used by */ |
649 | /* external applications; try to use something else if at all possible. */ | |
3a41c2f7 MN |
650 | const uint8_t *cur_ptr; |
651 | int cur_len; | |
652 | AVPacket cur_pkt; | |
27ca0a79 IS |
653 | |
654 | // Timestamp generation support: | |
655 | /** | |
656 | * Timestamp corresponding to the last dts sync point. | |
657 | * | |
658 | * Initialized when AVCodecParserContext.dts_sync_point >= 0 and | |
659 | * a DTS is received from the underlying container. Otherwise set to | |
660 | * AV_NOPTS_VALUE by default. | |
661 | */ | |
662 | int64_t reference_dts; | |
86cb7e33 BC |
663 | |
664 | /** | |
665 | * Number of packets to buffer for codec probing | |
666 | * NOT PART OF PUBLIC API | |
667 | */ | |
48616887 | 668 | #define MAX_PROBE_PACKETS 2500 |
86cb7e33 | 669 | int probe_packets; |
ddce56ef MN |
670 | |
671 | /** | |
e07b882b | 672 | * last packet in packet_buffer for this stream when muxing. |
da9cea77 DB |
673 | * Used internally, NOT PART OF PUBLIC API, do not read or |
674 | * write from outside of libav* | |
ddce56ef | 675 | */ |
e07b882b | 676 | struct AVPacketList *last_in_packet_buffer; |
9a174562 | 677 | #endif |
02b398ef MN |
678 | |
679 | /** | |
680 | * Average framerate | |
681 | */ | |
682 | AVRational avg_frame_rate; | |
6c6e6ef5 | 683 | |
9a174562 AK |
684 | /***************************************************************** |
685 | * All fields below this line are not part of the public API. They | |
686 | * may not be used outside of libavformat and can be changed and | |
687 | * removed at will. | |
688 | * New public fields should be added right above. | |
689 | ***************************************************************** | |
690 | */ | |
691 | ||
6c6e6ef5 MN |
692 | /** |
693 | * Number of frames that have been demuxed during av_find_stream_info() | |
694 | */ | |
695 | int codec_info_nb_frames; | |
fd0368e7 AJ |
696 | |
697 | /** | |
da9cea77 | 698 | * Stream information used internally by av_find_stream_info() |
fd0368e7 AJ |
699 | */ |
700 | #define MAX_STD_TIMEBASES (60*12+5) | |
701 | struct { | |
702 | int64_t last_dts; | |
703 | int64_t duration_gcd; | |
704 | int duration_count; | |
705 | double duration_error[MAX_STD_TIMEBASES]; | |
706 | int64_t codec_info_duration; | |
38a4be3f | 707 | int nb_decoded_frames; |
fd0368e7 | 708 | } *info; |
9a174562 AK |
709 | #if !FF_API_REORDER_PRIVATE |
710 | const uint8_t *cur_ptr; | |
711 | int cur_len; | |
712 | AVPacket cur_pkt; | |
713 | ||
714 | // Timestamp generation support: | |
715 | /** | |
716 | * Timestamp corresponding to the last dts sync point. | |
717 | * | |
718 | * Initialized when AVCodecParserContext.dts_sync_point >= 0 and | |
719 | * a DTS is received from the underlying container. Otherwise set to | |
720 | * AV_NOPTS_VALUE by default. | |
721 | */ | |
722 | int64_t reference_dts; | |
723 | int64_t first_dts; | |
724 | int64_t cur_dts; | |
725 | int last_IP_duration; | |
726 | int64_t last_IP_pts; | |
727 | ||
728 | /** | |
729 | * Number of packets to buffer for codec probing | |
730 | */ | |
731 | #define MAX_PROBE_PACKETS 2500 | |
732 | int probe_packets; | |
733 | ||
734 | /** | |
735 | * last packet in packet_buffer for this stream when muxing. | |
736 | */ | |
737 | struct AVPacketList *last_in_packet_buffer; | |
738 | AVProbeData probe_data; | |
739 | #define MAX_REORDER_DELAY 16 | |
740 | int64_t pts_buffer[MAX_REORDER_DELAY+1]; | |
741 | /* av_read_frame() support */ | |
742 | enum AVStreamParseType need_parsing; | |
743 | struct AVCodecParserContext *parser; | |
744 | ||
745 | AVIndexEntry *index_entries; /**< Only used if the format does not | |
746 | support seeking natively. */ | |
747 | int nb_index_entries; | |
748 | unsigned int index_entries_allocated_size; | |
749 | ||
750 | int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ | |
751 | #endif | |
de6d9b64 FB |
752 | } AVStream; |
753 | ||
15afa396 NS |
754 | #define AV_PROGRAM_RUNNING 1 |
755 | ||
ba66ae94 | 756 | /** |
ba66ae94 | 757 | * New fields can be added to the end with minor version bumps. |
8bfb108b | 758 | * Removal, reordering and changes to existing fields require a major |
ba66ae94 | 759 | * version bump. |
8bfb108b | 760 | * sizeof(AVProgram) must not be used outside libav*. |
ba66ae94 | 761 | */ |
15afa396 NS |
762 | typedef struct AVProgram { |
763 | int id; | |
15afa396 NS |
764 | int flags; |
765 | enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller | |
526efa10 NS |
766 | unsigned int *stream_index; |
767 | unsigned int nb_stream_indexes; | |
d2d67e42 | 768 | AVDictionary *metadata; |
15afa396 NS |
769 | } AVProgram; |
770 | ||
43d414ba | 771 | #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present |
da24c5e3 FB |
772 | (streams are added dynamically) */ |
773 | ||
79d7836a | 774 | typedef struct AVChapter { |
4f57fa8c DB |
775 | int id; ///< unique ID to identify the chapter |
776 | AVRational time_base; ///< time base in which the start/end timestamps are specified | |
8931e7b4 | 777 | int64_t start, end; ///< chapter start/end time in time_base units |
d2d67e42 | 778 | AVDictionary *metadata; |
79d7836a AK |
779 | } AVChapter; |
780 | ||
252f17e2 | 781 | /** |
4f57fa8c | 782 | * Format I/O context. |
252f17e2 | 783 | * New fields can be added to the end with minor version bumps. |
8bfb108b | 784 | * Removal, reordering and changes to existing fields require a major |
252f17e2 | 785 | * version bump. |
83daced0 AK |
786 | * sizeof(AVFormatContext) must not be used outside libav*, use |
787 | * avformat_alloc_context() to create an AVFormatContext. | |
252f17e2 | 788 | */ |
de6d9b64 | 789 | typedef struct AVFormatContext { |
83daced0 AK |
790 | /** |
791 | * A class for logging and AVOptions. Set by avformat_alloc_context(). | |
792 | * Exports (de)muxer private options if they exist. | |
793 | */ | |
794 | const AVClass *av_class; | |
795 | ||
796 | /** | |
797 | * Can only be iformat or oformat, not both at the same time. | |
798 | * | |
799 | * decoding: set by avformat_open_input(). | |
800 | * encoding: set by the user. | |
801 | */ | |
b9a281db FB |
802 | struct AVInputFormat *iformat; |
803 | struct AVOutputFormat *oformat; | |
83daced0 AK |
804 | |
805 | /** | |
806 | * Format private data. This is an AVOptions-enabled struct | |
807 | * if and only if iformat/oformat.priv_class is not NULL. | |
808 | */ | |
de6d9b64 | 809 | void *priv_data; |
83daced0 AK |
810 | |
811 | /* | |
812 | * I/O context. | |
813 | * | |
814 | * decoding: either set by the user before avformat_open_input() (then | |
815 | * the user must close it manually) or set by avformat_open_input(). | |
816 | * encoding: set by the user. | |
817 | * | |
818 | * Do NOT set this field if AVFMT_NOFILE flag is set in | |
819 | * iformat/oformat.flags. In such a case, the (de)muxer will handle | |
820 | * I/O in some other way and this field will be NULL. | |
821 | */ | |
ae628ec1 | 822 | AVIOContext *pb; |
83daced0 AK |
823 | |
824 | /** | |
825 | * A list of all streams in the file. New streams are created with | |
826 | * avformat_new_stream(). | |
827 | * | |
828 | * decoding: streams are created by libavformat in avformat_open_input(). | |
829 | * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also | |
830 | * appear in av_read_frame(). | |
831 | * encoding: streams are created by the user before avformat_write_header(). | |
832 | */ | |
db69c2e5 | 833 | unsigned int nb_streams; |
38aab35f | 834 | AVStream **streams; |
83daced0 | 835 | |
43d414ba | 836 | char filename[1024]; /**< input or output filename */ |
de6d9b64 | 837 | /* stream info */ |
5f847bf6 AK |
838 | #if FF_API_TIMESTAMP |
839 | /** | |
840 | * @deprecated use 'creation_time' metadata tag instead | |
841 | */ | |
842 | attribute_deprecated int64_t timestamp; | |
843 | #endif | |
6a58e151 | 844 | |
4f57fa8c | 845 | int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ |
df968050 | 846 | #if FF_API_REORDER_PRIVATE |
4f57fa8c | 847 | /* private data for pts handling (do not modify directly). */ |
76c56376 MN |
848 | /** |
849 | * This buffer is only needed when packets were already buffered but | |
850 | * not decoded, for example to get the codec parameters in MPEG | |
851 | * streams. | |
852 | */ | |
ee404803 | 853 | struct AVPacketList *packet_buffer; |
df968050 | 854 | #endif |
ee404803 | 855 | |
76c56376 MN |
856 | /** |
857 | * Decoding: position of the first frame of the component, in | |
858 | * AV_TIME_BASE fractional seconds. NEVER set this value directly: | |
859 | * It is deduced from the AVStream values. | |
860 | */ | |
115329f1 | 861 | int64_t start_time; |
76c56376 MN |
862 | |
863 | /** | |
864 | * Decoding: duration of the stream, in AV_TIME_BASE fractional | |
865 | * seconds. Only set this value if you know none of the individual stream | |
da9cea77 | 866 | * durations and also do not set any of them. This is deduced from the |
76c56376 MN |
867 | * AVStream values if not set. |
868 | */ | |
ee404803 | 869 | int64_t duration; |
76c56376 | 870 | |
c10731e7 | 871 | #if FF_API_FILESIZE |
76c56376 MN |
872 | /** |
873 | * decoding: total file size, 0 if unknown | |
874 | */ | |
c10731e7 AK |
875 | attribute_deprecated int64_t file_size; |
876 | #endif | |
76c56376 MN |
877 | |
878 | /** | |
879 | * Decoding: total stream bitrate in bit/s, 0 if not | |
880 | * available. Never set it directly if the file_size and the | |
6001dad6 | 881 | * duration are known as Libav can compute it automatically. |
76c56376 | 882 | */ |
ee404803 | 883 | int bit_rate; |
fb2758c8 | 884 | |
df968050 | 885 | #if FF_API_REORDER_PRIVATE |
fb2758c8 FB |
886 | /* av_read_frame() support */ |
887 | AVStream *cur_st; | |
fb2758c8 | 888 | |
fb2758c8 | 889 | /* av_seek_frame() support */ |
ec906fcd | 890 | int64_t data_offset; /**< offset of the first packet */ |
df968050 | 891 | #endif |
115329f1 | 892 | |
5a9ee315 AK |
893 | #if FF_API_MUXRATE |
894 | /** | |
895 | * use mpeg muxer private options instead | |
896 | */ | |
897 | attribute_deprecated int mux_rate; | |
898 | #endif | |
92400be2 | 899 | unsigned int packet_size; |
f172132f AK |
900 | #if FF_API_PRELOAD |
901 | attribute_deprecated int preload; | |
902 | #endif | |
17c88cb0 | 903 | int max_delay; |
8108551a | 904 | |
d31e3f7c | 905 | #if FF_API_LOOP_OUTPUT |
115329f1 DB |
906 | #define AVFMT_NOOUTPUTLOOP -1 |
907 | #define AVFMT_INFINITEOUTPUTLOOP 0 | |
76c56376 MN |
908 | /** |
909 | * number of times to loop output in formats that support it | |
d31e3f7c AK |
910 | * |
911 | * @deprecated use the 'loop' private option in the gif muxer. | |
76c56376 | 912 | */ |
d31e3f7c AK |
913 | attribute_deprecated int loop_output; |
914 | #endif | |
115329f1 | 915 | |
30bc6613 | 916 | int flags; |
22e77e44 | 917 | #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. |
4f57fa8c DB |
918 | #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. |
919 | #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. | |
c55806e3 | 920 | #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS |
fe8344a2 MN |
921 | #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container |
922 | #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled | |
28734ac9 MS |
923 | #if FF_API_FLAG_RTP_HINT |
924 | #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead | |
925 | #endif | |
05e84c95 | 926 | #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. |
73e8e8db | 927 | #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted |
5894e1bb | 928 | |
6002fdef AK |
929 | #if FF_API_LOOP_INPUT |
930 | /** | |
931 | * @deprecated, use the 'loop' img2 demuxer private option. | |
932 | */ | |
933 | attribute_deprecated int loop_input; | |
934 | #endif | |
76c56376 MN |
935 | |
936 | /** | |
937 | * decoding: size of data to probe; encoding: unused. | |
938 | */ | |
9e6c9470 | 939 | unsigned int probesize; |
a44b3c4d MN |
940 | |
941 | /** | |
83daced0 AK |
942 | * decoding: maximum time (in AV_TIME_BASE units) during which the input should |
943 | * be analyzed in avformat_find_stream_info(). | |
a44b3c4d MN |
944 | */ |
945 | int max_analyze_duration; | |
c964c2c7 RD |
946 | |
947 | const uint8_t *key; | |
948 | int keylen; | |
15afa396 NS |
949 | |
950 | unsigned int nb_programs; | |
951 | AVProgram **programs; | |
62600469 MN |
952 | |
953 | /** | |
954 | * Forced video codec_id. | |
4f57fa8c | 955 | * Demuxing: Set by user. |
62600469 MN |
956 | */ |
957 | enum CodecID video_codec_id; | |
76c56376 | 958 | |
62600469 MN |
959 | /** |
960 | * Forced audio codec_id. | |
4f57fa8c | 961 | * Demuxing: Set by user. |
62600469 MN |
962 | */ |
963 | enum CodecID audio_codec_id; | |
76c56376 | 964 | |
62600469 MN |
965 | /** |
966 | * Forced subtitle codec_id. | |
4f57fa8c | 967 | * Demuxing: Set by user. |
62600469 MN |
968 | */ |
969 | enum CodecID subtitle_codec_id; | |
3dea63bd PK |
970 | |
971 | /** | |
22e77e44 DB |
972 | * Maximum amount of memory in bytes to use for the index of each stream. |
973 | * If the index exceeds this size, entries will be discarded as | |
3dea63bd PK |
974 | * needed to maintain a smaller size. This can lead to slower or less |
975 | * accurate seeking (depends on demuxer). | |
4f57fa8c | 976 | * Demuxers for which a full in-memory index is mandatory will ignore |
3dea63bd PK |
977 | * this. |
978 | * muxing : unused | |
979 | * demuxing: set by user | |
980 | */ | |
981 | unsigned int max_index_size; | |
ab8ab30c RP |
982 | |
983 | /** | |
ffa71b2b | 984 | * Maximum amount of memory in bytes to use for buffering frames |
4f57fa8c | 985 | * obtained from realtime capture devices. |
ab8ab30c RP |
986 | */ |
987 | unsigned int max_picture_buffer; | |
79d7836a | 988 | |
fbabf1e9 | 989 | unsigned int nb_chapters; |
79d7836a | 990 | AVChapter **chapters; |
45b2b05f MN |
991 | |
992 | /** | |
4f57fa8c | 993 | * Flags to enable debugging. |
45b2b05f MN |
994 | */ |
995 | int debug; | |
996 | #define FF_FDEBUG_TS 0x0001 | |
0bef08e5 | 997 | |
df968050 | 998 | #if FF_API_REORDER_PRIVATE |
0bef08e5 | 999 | /** |
4f57fa8c | 1000 | * Raw packets from the demuxer, prior to parsing and decoding. |
0bef08e5 MN |
1001 | * This buffer is used for buffering packets until the codec can |
1002 | * be identified, as parsing cannot be done without knowing the | |
1003 | * codec. | |
1004 | */ | |
1005 | struct AVPacketList *raw_packet_buffer; | |
5c5b1731 MR |
1006 | struct AVPacketList *raw_packet_buffer_end; |
1007 | ||
1008 | struct AVPacketList *packet_buffer_end; | |
df968050 | 1009 | #endif |
47146dfb | 1010 | |
d2d67e42 | 1011 | AVDictionary *metadata; |
af122d6a | 1012 | |
df968050 | 1013 | #if FF_API_REORDER_PRIVATE |
af122d6a BC |
1014 | /** |
1015 | * Remaining size available for raw_packet_buffer, in bytes. | |
1016 | * NOT PART OF PUBLIC API | |
1017 | */ | |
48616887 | 1018 | #define RAW_PACKET_BUFFER_SIZE 2500000 |
af122d6a | 1019 | int raw_packet_buffer_remaining_size; |
df968050 | 1020 | #endif |
b8819c85 MS |
1021 | |
1022 | /** | |
1023 | * Start time of the stream in real world time, in microseconds | |
1024 | * since the unix epoch (00:00 1st January 1970). That is, pts=0 | |
1025 | * in the stream was captured at this real world time. | |
1026 | * - encoding: Set by user. | |
1027 | * - decoding: Unused. | |
1028 | */ | |
1029 | int64_t start_time_realtime; | |
30315a8d AC |
1030 | |
1031 | /** | |
1032 | * decoding: number of frames used to probe fps | |
1033 | */ | |
1034 | int fps_probe_size; | |
2f63440c DB |
1035 | |
1036 | /** | |
1037 | * Error recognition; higher values will detect more errors but may | |
1038 | * misdetect some more or less valid parts as errors. | |
1039 | * - encoding: unused | |
1040 | * - decoding: Set by user. | |
1041 | */ | |
1042 | int error_recognition; | |
df968050 | 1043 | |
6aa0b98f MS |
1044 | /** |
1045 | * Custom interrupt callbacks for the I/O layer. | |
1046 | * | |
1047 | * decoding: set by the user before avformat_open_input(). | |
1048 | * encoding: set by the user before avformat_write_header() | |
1049 | * (mainly useful for AVFMT_NOFILE formats). The callback | |
1050 | * should also be passed to avio_open2() if it's used to | |
1051 | * open the file. | |
1052 | */ | |
1053 | AVIOInterruptCB interrupt_callback; | |
1054 | ||
df968050 AK |
1055 | /***************************************************************** |
1056 | * All fields below this line are not part of the public API. They | |
1057 | * may not be used outside of libavformat and can be changed and | |
1058 | * removed at will. | |
1059 | * New public fields should be added right above. | |
1060 | ***************************************************************** | |
1061 | */ | |
1062 | #if !FF_API_REORDER_PRIVATE | |
1063 | /** | |
1064 | * Raw packets from the demuxer, prior to parsing and decoding. | |
1065 | * This buffer is used for buffering packets until the codec can | |
1066 | * be identified, as parsing cannot be done without knowing the | |
1067 | * codec. | |
1068 | */ | |
1069 | struct AVPacketList *raw_packet_buffer; | |
1070 | struct AVPacketList *raw_packet_buffer_end; | |
1071 | /** | |
1072 | * Remaining size available for raw_packet_buffer, in bytes. | |
1073 | */ | |
1074 | #define RAW_PACKET_BUFFER_SIZE 2500000 | |
1075 | int raw_packet_buffer_remaining_size; | |
1076 | ||
1077 | /** | |
1078 | * This buffer is only needed when packets were already buffered but | |
1079 | * not decoded, for example to get the codec parameters in MPEG | |
1080 | * streams. | |
1081 | */ | |
1082 | struct AVPacketList *packet_buffer; | |
1083 | struct AVPacketList *packet_buffer_end; | |
1084 | ||
1085 | /* av_read_frame() support */ | |
1086 | AVStream *cur_st; | |
1087 | ||
1088 | /* av_seek_frame() support */ | |
1089 | int64_t data_offset; /**< offset of the first packet */ | |
1090 | #endif | |
de6d9b64 FB |
1091 | } AVFormatContext; |
1092 | ||
1093 | typedef struct AVPacketList { | |
1094 | AVPacket pkt; | |
1095 | struct AVPacketList *next; | |
1096 | } AVPacketList; | |
1097 | ||
469c62d0 AK |
1098 | |
1099 | /** | |
1100 | * @defgroup lavf_core Core functions | |
1101 | * @ingroup libavf | |
1102 | * | |
1103 | * Functions for querying libavformat capabilities, allocating core structures, | |
1104 | * etc. | |
1105 | * @{ | |
1106 | */ | |
1107 | ||
1108 | /** | |
1109 | * Return the LIBAVFORMAT_VERSION_INT constant. | |
1110 | */ | |
1111 | unsigned avformat_version(void); | |
1112 | ||
1113 | /** | |
1114 | * Return the libavformat build-time configuration. | |
1115 | */ | |
1116 | const char *avformat_configuration(void); | |
1117 | ||
1118 | /** | |
1119 | * Return the libavformat license. | |
1120 | */ | |
1121 | const char *avformat_license(void); | |
1122 | ||
1123 | /** | |
1124 | * Initialize libavformat and register all the muxers, demuxers and | |
1125 | * protocols. If you do not call this function, then you can select | |
1126 | * exactly which formats you want to support. | |
1127 | * | |
1128 | * @see av_register_input_format() | |
1129 | * @see av_register_output_format() | |
1130 | * @see av_register_protocol() | |
1131 | */ | |
1132 | void av_register_all(void); | |
1133 | ||
1134 | void av_register_input_format(AVInputFormat *format); | |
1135 | void av_register_output_format(AVOutputFormat *format); | |
1136 | ||
1137 | /** | |
1138 | * Do global initialization of network components. This is optional, | |
1139 | * but recommended, since it avoids the overhead of implicitly | |
1140 | * doing the setup for each session. | |
1141 | * | |
1142 | * Calling this function will become mandatory if using network | |
1143 | * protocols at some major version bump. | |
1144 | */ | |
1145 | int avformat_network_init(void); | |
1146 | ||
1147 | /** | |
1148 | * Undo the initialization done by avformat_network_init. | |
1149 | */ | |
1150 | int avformat_network_deinit(void); | |
1151 | ||
aeedac95 SS |
1152 | /** |
1153 | * If f is NULL, returns the first registered input format, | |
22e77e44 | 1154 | * if f is non-NULL, returns the next registered input format after f |
aeedac95 SS |
1155 | * or NULL if f is the last one. |
1156 | */ | |
84be6e72 | 1157 | AVInputFormat *av_iformat_next(AVInputFormat *f); |
aeedac95 SS |
1158 | |
1159 | /** | |
1160 | * If f is NULL, returns the first registered output format, | |
22e77e44 | 1161 | * if f is non-NULL, returns the next registered output format after f |
aeedac95 SS |
1162 | * or NULL if f is the last one. |
1163 | */ | |
84be6e72 | 1164 | AVOutputFormat *av_oformat_next(AVOutputFormat *f); |
de6d9b64 | 1165 | |
469c62d0 AK |
1166 | /** |
1167 | * Allocate an AVFormatContext. | |
1168 | * avformat_free_context() can be used to free the context and everything | |
1169 | * allocated by the framework within it. | |
1170 | */ | |
1171 | AVFormatContext *avformat_alloc_context(void); | |
1172 | ||
1173 | /** | |
1174 | * Free an AVFormatContext and all its streams. | |
1175 | * @param s context to free | |
1176 | */ | |
1177 | void avformat_free_context(AVFormatContext *s); | |
1178 | ||
1179 | /** | |
1180 | * Get the AVClass for AVFormatContext. It can be used in combination with | |
1181 | * AV_OPT_SEARCH_FAKE_OBJ for examining options. | |
1182 | * | |
1183 | * @see av_opt_find(). | |
1184 | */ | |
1185 | const AVClass *avformat_get_class(void); | |
1186 | ||
1187 | /** | |
1188 | * Add a new stream to a media file. | |
1189 | * | |
1190 | * When demuxing, it is called by the demuxer in read_header(). If the | |
1191 | * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also | |
1192 | * be called in read_packet(). | |
1193 | * | |
1194 | * When muxing, should be called by the user before avformat_write_header(). | |
1195 | * | |
1196 | * @param c If non-NULL, the AVCodecContext corresponding to the new stream | |
1197 | * will be initialized to use this codec. This is needed for e.g. codec-specific | |
1198 | * defaults to be set, so codec should be provided if it is known. | |
1199 | * | |
1200 | * @return newly created stream or NULL on error. | |
1201 | */ | |
1202 | AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c); | |
1203 | ||
1204 | AVProgram *av_new_program(AVFormatContext *s, int id); | |
1205 | ||
1206 | /** | |
1207 | * @} | |
1208 | */ | |
1209 | ||
1210 | ||
a9bf9d8e AK |
1211 | #if FF_API_GUESS_IMG2_CODEC |
1212 | attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename); | |
1213 | #endif | |
290c5fa6 | 1214 | |
f48b0fa2 | 1215 | /** |
49bd8e4b | 1216 | * Send a nice hexadecimal dump of a buffer to the specified file stream. |
750f0e1f PI |
1217 | * |
1218 | * @param f The file stream pointer where the dump should be sent to. | |
3217cb42 PI |
1219 | * @param buf buffer |
1220 | * @param size buffer size | |
750f0e1f | 1221 | * |
863c4716 | 1222 | * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 |
3217cb42 | 1223 | */ |
fb2758c8 | 1224 | void av_hex_dump(FILE *f, uint8_t *buf, int size); |
3217cb42 PI |
1225 | |
1226 | /** | |
49bd8e4b | 1227 | * Send a nice hexadecimal dump of a buffer to the log. |
750f0e1f PI |
1228 | * |
1229 | * @param avcl A pointer to an arbitrary struct of which the first field is a | |
1230 | * pointer to an AVClass struct. | |
1231 | * @param level The importance level of the message, lower values signifying | |
1232 | * higher importance. | |
1233 | * @param buf buffer | |
1234 | * @param size buffer size | |
1235 | * | |
863c4716 | 1236 | * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 |
750f0e1f PI |
1237 | */ |
1238 | void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); | |
1239 | ||
1240 | /** | |
49bd8e4b | 1241 | * Send a nice dump of a packet to the specified file stream. |
750f0e1f PI |
1242 | * |
1243 | * @param f The file stream pointer where the dump should be sent to. | |
3217cb42 | 1244 | * @param pkt packet to dump |
4f57fa8c | 1245 | * @param dump_payload True if the payload must be displayed, too. |
863c4716 | 1246 | * @param st AVStream that the packet belongs to |
3217cb42 | 1247 | */ |
863c4716 MS |
1248 | void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); |
1249 | ||
de6d9b64 | 1250 | |
750f0e1f | 1251 | /** |
49bd8e4b | 1252 | * Send a nice dump of a packet to the log. |
750f0e1f PI |
1253 | * |
1254 | * @param avcl A pointer to an arbitrary struct of which the first field is a | |
1255 | * pointer to an AVClass struct. | |
1256 | * @param level The importance level of the message, lower values signifying | |
1257 | * higher importance. | |
1258 | * @param pkt packet to dump | |
4f57fa8c | 1259 | * @param dump_payload True if the payload must be displayed, too. |
863c4716 | 1260 | * @param st AVStream that the packet belongs to |
750f0e1f | 1261 | */ |
863c4716 MS |
1262 | void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, |
1263 | AVStream *st); | |
1264 | ||
c5704b2b AK |
1265 | #if FF_API_PKT_DUMP |
1266 | attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); | |
863c4716 MS |
1267 | attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, |
1268 | int dump_payload); | |
17ca374c | 1269 | #endif |
750f0e1f | 1270 | |
4815e246 | 1271 | /** |
49bd8e4b | 1272 | * Get the CodecID for the given codec tag tag. |
7693b93e SS |
1273 | * If no codec id is found returns CODEC_ID_NONE. |
1274 | * | |
1275 | * @param tags list of supported codec_id-codec_tag pairs, as stored | |
1276 | * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag | |
1277 | */ | |
15545a09 | 1278 | enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); |
7693b93e SS |
1279 | |
1280 | /** | |
49bd8e4b | 1281 | * Get the codec tag for the given codec id id. |
7693b93e SS |
1282 | * If no codec tag is found returns 0. |
1283 | * | |
1284 | * @param tags list of supported codec_id-codec_tag pairs, as stored | |
1285 | * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag | |
1286 | */ | |
15545a09 | 1287 | unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id); |
7caf0cc6 | 1288 | |
370f27de | 1289 | /** |
370f27de AK |
1290 | * @addtogroup lavf_decoding |
1291 | * @{ | |
1292 | */ | |
3217cb42 PI |
1293 | |
1294 | /** | |
49bd8e4b | 1295 | * Find AVInputFormat based on the short name of the input format. |
3217cb42 | 1296 | */ |
b9a281db | 1297 | AVInputFormat *av_find_input_format(const char *short_name); |
3217cb42 PI |
1298 | |
1299 | /** | |
49bd8e4b | 1300 | * Guess the file format. |
3217cb42 | 1301 | * |
4f57fa8c DB |
1302 | * @param is_opened Whether the file is already opened; determines whether |
1303 | * demuxers with or without AVFMT_NOFILE are probed. | |
3217cb42 | 1304 | */ |
94988531 | 1305 | AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); |
3217cb42 PI |
1306 | |
1307 | /** | |
49bd8e4b | 1308 | * Guess the file format. |
8e2ee182 RD |
1309 | * |
1310 | * @param is_opened Whether the file is already opened; determines whether | |
1311 | * demuxers with or without AVFMT_NOFILE are probed. | |
c99d506b RD |
1312 | * @param score_max A probe score larger that this is required to accept a |
1313 | * detection, the variable is set to the actual detection | |
1314 | * score afterwards. | |
1315 | * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended | |
8e2ee182 RD |
1316 | * to retry with a larger probe buffer. |
1317 | */ | |
1318 | AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); | |
1319 | ||
1320 | /** | |
3940caad AH |
1321 | * Probe a bytestream to determine the input format. Each time a probe returns |
1322 | * with a score that is too low, the probe buffer size is increased and another | |
1323 | * attempt is made. When the maximum probe size is reached, the input format | |
1324 | * with the highest score is returned. | |
1325 | * | |
1326 | * @param pb the bytestream to probe | |
1327 | * @param fmt the input format is put here | |
1328 | * @param filename the filename of the stream | |
1329 | * @param logctx the log context | |
1330 | * @param offset the offset within the bytestream to probe from | |
1331 | * @param max_probe_size the maximum probe buffer size (zero for default) | |
1332 | * @return 0 in case of success, a negative value corresponding to an | |
1333 | * AVERROR code otherwise | |
1334 | */ | |
ae628ec1 | 1335 | int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, |
3940caad AH |
1336 | const char *filename, void *logctx, |
1337 | unsigned int offset, unsigned int max_probe_size); | |
1338 | ||
603b8bc2 | 1339 | #if FF_API_FORMAT_PARAMETERS |
3940caad | 1340 | /** |
49bd8e4b | 1341 | * Allocate all the structures needed to read an input stream. |
3217cb42 | 1342 | * This does not open the needed codecs for decoding the stream[s]. |
603b8bc2 | 1343 | * @deprecated use avformat_open_input instead. |
3217cb42 | 1344 | */ |
603b8bc2 | 1345 | attribute_deprecated int av_open_input_stream(AVFormatContext **ic_ptr, |
ae628ec1 | 1346 | AVIOContext *pb, const char *filename, |
da24c5e3 | 1347 | AVInputFormat *fmt, AVFormatParameters *ap); |
3217cb42 PI |
1348 | |
1349 | /** | |
49bd8e4b | 1350 | * Open a media file as input. The codecs are not opened. Only the file |
3217cb42 PI |
1351 | * header (if present) is read. |
1352 | * | |
4f57fa8c DB |
1353 | * @param ic_ptr The opened media file handle is put here. |
1354 | * @param filename filename to open | |
1355 | * @param fmt If non-NULL, force the file format to use. | |
3217cb42 | 1356 | * @param buf_size optional buffer size (zero if default is OK) |
78cb7273 DB |
1357 | * @param ap Additional parameters needed when opening the file |
1358 | * (NULL if default). | |
4f57fa8c | 1359 | * @return 0 if OK, AVERROR_xxx otherwise |
603b8bc2 AK |
1360 | * |
1361 | * @deprecated use avformat_open_input instead. | |
3217cb42 | 1362 | */ |
603b8bc2 | 1363 | attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, |
b9a281db FB |
1364 | AVInputFormat *fmt, |
1365 | int buf_size, | |
1366 | AVFormatParameters *ap); | |
603b8bc2 | 1367 | #endif |
88a28965 | 1368 | |
88808c60 | 1369 | /** |
05e84c95 AK |
1370 | * Open an input stream and read the header. The codecs are not opened. |
1371 | * The stream must be closed with av_close_input_file(). | |
1372 | * | |
1373 | * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). | |
1374 | * May be a pointer to NULL, in which case an AVFormatContext is allocated by this | |
1375 | * function and written into ps. | |
1376 | * Note that a user-supplied AVFormatContext will be freed on failure. | |
1377 | * @param filename Name of the stream to open. | |
1378 | * @param fmt If non-NULL, this parameter forces a specific input format. | |
1379 | * Otherwise the format is autodetected. | |
1380 | * @param options A dictionary filled with AVFormatContext and demuxer-private options. | |
1381 | * On return this parameter will be destroyed and replaced with a dict containing | |
1382 | * options that were not found. May be NULL. | |
1383 | * | |
1384 | * @return 0 on success, a negative AVERROR on failure. | |
1385 | * | |
1386 | * @note If you want to use custom IO, preallocate the format context and set its pb field. | |
1387 | */ | |
1388 | int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); | |
1389 | ||
a67c061e | 1390 | #if FF_API_FORMAT_PARAMETERS |
3217cb42 | 1391 | /** |
49bd8e4b | 1392 | * Read packets of a media file to get stream information. This |
3217cb42 | 1393 | * is useful for file formats with no headers such as MPEG. This |
22e77e44 | 1394 | * function also computes the real framerate in case of MPEG-2 repeat |
3217cb42 PI |
1395 | * frame mode. |
1396 | * The logical file position is not changed by this function; | |
1397 | * examined packets may be buffered for later processing. | |
1398 | * | |
1399 | * @param ic media file handle | |
4f57fa8c DB |
1400 | * @return >=0 if OK, AVERROR_xxx on error |
1401 | * @todo Let the user decide somehow what information is needed so that | |
1402 | * we do not waste time getting stuff the user does not need. | |
a67c061e AK |
1403 | * |
1404 | * @deprecated use avformat_find_stream_info. | |
3217cb42 | 1405 | */ |
3c7fa664 | 1406 | attribute_deprecated |
b9a281db | 1407 | int av_find_stream_info(AVFormatContext *ic); |
a67c061e AK |
1408 | #endif |
1409 | ||
1410 | /** | |
1411 | * Read packets of a media file to get stream information. This | |
1412 | * is useful for file formats with no headers such as MPEG. This | |
1413 | * function also computes the real framerate in case of MPEG-2 repeat | |
1414 | * frame mode. | |
1415 | * The logical file position is not changed by this function; | |
1416 | * examined packets may be buffered for later processing. | |
1417 | * | |
1418 | * @param ic media file handle | |
1419 | * @param options If non-NULL, an ic.nb_streams long array of pointers to | |
1420 | * dictionaries, where i-th member contains options for | |
1421 | * codec corresponding to i-th stream. | |
1422 | * On return each dictionary will be filled with options that were not found. | |
1423 | * @return >=0 if OK, AVERROR_xxx on error | |
1424 | * | |
1425 | * @note this function isn't guaranteed to open all the codecs, so | |
1426 | * options being non-empty at return is a perfectly normal behavior. | |
1427 | * | |
1428 | * @todo Let the user decide somehow what information is needed so that | |
1429 | * we do not waste time getting stuff the user does not need. | |
1430 | */ | |
1431 | int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); | |
3217cb42 PI |
1432 | |
1433 | /** | |
9128ae08 NG |
1434 | * Find the "best" stream in the file. |
1435 | * The best stream is determined according to various heuristics as the most | |
1436 | * likely to be what the user expects. | |
1437 | * If the decoder parameter is non-NULL, av_find_best_stream will find the | |
1438 | * default decoder for the stream's codec; streams for which no decoder can | |
1439 | * be found are ignored. | |
1440 | * | |
1441 | * @param ic media file handle | |
1442 | * @param type stream type: video, audio, subtitles, etc. | |
1443 | * @param wanted_stream_nb user-requested stream number, | |
1444 | * or -1 for automatic selection | |
1445 | * @param related_stream try to find a stream related (eg. in the same | |
1446 | * program) to this one, or -1 if none | |
1447 | * @param decoder_ret if non-NULL, returns the decoder for the | |
1448 | * selected stream | |
1449 | * @param flags flags; none are currently defined | |
1450 | * @return the non-negative stream number in case of success, | |
1451 | * AVERROR_STREAM_NOT_FOUND if no stream with the requested type | |
1452 | * could be found, | |
1453 | * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder | |
1454 | * @note If av_find_best_stream returns successfully and decoder_ret is not | |
1455 | * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. | |
1456 | */ | |
1457 | int av_find_best_stream(AVFormatContext *ic, | |
1458 | enum AVMediaType type, | |
1459 | int wanted_stream_nb, | |
1460 | int related_stream, | |
1461 | AVCodec **decoder_ret, | |
1462 | int flags); | |
1463 | ||
1464 | /** | |
49bd8e4b | 1465 | * Read a transport packet from a media file. |
3217cb42 | 1466 | * |
864ff8c1 | 1467 | * This function is obsolete and should never be used. |
3217cb42 PI |
1468 | * Use av_read_frame() instead. |
1469 | * | |
1470 | * @param s media file handle | |
1471 | * @param pkt is filled | |
4f57fa8c | 1472 | * @return 0 if OK, AVERROR_xxx on error |
3217cb42 | 1473 | */ |
de6d9b64 | 1474 | int av_read_packet(AVFormatContext *s, AVPacket *pkt); |
3217cb42 PI |
1475 | |
1476 | /** | |
49bd8e4b | 1477 | * Return the next frame of a stream. |
4faf628f MN |
1478 | * This function returns what is stored in the file, and does not validate |
1479 | * that what is there are valid frames for the decoder. It will split what is | |
1480 | * stored in the file into frames and return one for each call. It will not | |
1481 | * omit invalid data between valid frames so as to give the decoder the maximum | |
1482 | * information possible for decoding. | |
3217cb42 PI |
1483 | * |
1484 | * The returned packet is valid | |
1485 | * until the next av_read_frame() or until av_close_input_file() and | |
1486 | * must be freed with av_free_packet. For video, the packet contains | |
1487 | * exactly one frame. For audio, it contains an integer number of | |
1488 | * frames if each frame has a known fixed size (e.g. PCM or ADPCM | |
1489 | * data). If the audio frames have a variable size (e.g. MPEG audio), | |
1490 | * then it contains one frame. | |
1491 | * | |
1492 | * pkt->pts, pkt->dts and pkt->duration are always set to correct | |
22e77e44 | 1493 | * values in AVStream.time_base units (and guessed if the format cannot |
4f57fa8c DB |
1494 | * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format |
1495 | * has B-frames, so it is better to rely on pkt->dts if you do not | |
3217cb42 PI |
1496 | * decompress the payload. |
1497 | * | |
4f57fa8c | 1498 | * @return 0 if OK, < 0 on error or end of file |
3217cb42 | 1499 | */ |
fb2758c8 | 1500 | int av_read_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 PI |
1501 | |
1502 | /** | |
49bd8e4b | 1503 | * Seek to the keyframe at timestamp. |
3217cb42 PI |
1504 | * 'timestamp' in 'stream_index'. |
1505 | * @param stream_index If stream_index is (-1), a default | |
1506 | * stream is selected, and timestamp is automatically converted | |
1507 | * from AV_TIME_BASE units to the stream specific time_base. | |
4f57fa8c DB |
1508 | * @param timestamp Timestamp in AVStream.time_base units |
1509 | * or, if no stream is specified, in AV_TIME_BASE units. | |
3217cb42 PI |
1510 | * @param flags flags which select direction and seeking mode |
1511 | * @return >= 0 on success | |
1512 | */ | |
78cb7273 DB |
1513 | int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, |
1514 | int flags); | |
3217cb42 PI |
1515 | |
1516 | /** | |
49bd8e4b | 1517 | * Seek to timestamp ts. |
d04768fa MN |
1518 | * Seeking will be done so that the point from which all active streams |
1519 | * can be presented successfully will be closest to ts and within min/max_ts. | |
1520 | * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. | |
1521 | * | |
22e77e44 | 1522 | * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and |
d04768fa | 1523 | * are the file position (this may not be supported by all demuxers). |
22e77e44 | 1524 | * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames |
d04768fa | 1525 | * in the stream with stream_index (this may not be supported by all demuxers). |
22e77e44 DB |
1526 | * Otherwise all timestamps are in units of the stream selected by stream_index |
1527 | * or if stream_index is -1, in AV_TIME_BASE units. | |
1528 | * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as | |
d04768fa MN |
1529 | * keyframes (this may not be supported by all demuxers). |
1530 | * | |
22e77e44 | 1531 | * @param stream_index index of the stream which is used as time base reference |
d04768fa MN |
1532 | * @param min_ts smallest acceptable timestamp |
1533 | * @param ts target timestamp | |
1534 | * @param max_ts largest acceptable timestamp | |
1535 | * @param flags flags | |
32e543f8 | 1536 | * @return >=0 on success, error code otherwise |
998b6f7c | 1537 | * |
8a4d7a30 | 1538 | * @note This is part of the new seek API which is still under construction. |
22e77e44 DB |
1539 | * Thus do not use this yet. It may change at any time, do not expect |
1540 | * ABI compatibility yet! | |
d04768fa MN |
1541 | */ |
1542 | int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); | |
1543 | ||
1544 | /** | |
49bd8e4b | 1545 | * Start playing a network-based stream (e.g. RTSP stream) at the |
4f57fa8c | 1546 | * current position. |
3217cb42 | 1547 | */ |
fb2758c8 | 1548 | int av_read_play(AVFormatContext *s); |
3217cb42 PI |
1549 | |
1550 | /** | |
49bd8e4b | 1551 | * Pause a network-based stream (e.g. RTSP stream). |
3217cb42 PI |
1552 | * |
1553 | * Use av_read_play() to resume it. | |
1554 | */ | |
fb2758c8 | 1555 | int av_read_pause(AVFormatContext *s); |
3217cb42 PI |
1556 | |
1557 | /** | |
49bd8e4b | 1558 | * Free a AVFormatContext allocated by av_open_input_stream. |
2506fd54 RD |
1559 | * @param s context to free |
1560 | */ | |
1561 | void av_close_input_stream(AVFormatContext *s); | |
1562 | ||
1563 | /** | |
49bd8e4b | 1564 | * Close a media file (but not its codecs). |
3217cb42 PI |
1565 | * |
1566 | * @param s media file handle | |
1567 | */ | |
de6d9b64 | 1568 | void av_close_input_file(AVFormatContext *s); |
370f27de AK |
1569 | /** |
1570 | * @} | |
1571 | */ | |
3217cb42 | 1572 | |
569129a6 | 1573 | #if FF_API_NEW_STREAM |
f124b087 | 1574 | /** |
49bd8e4b | 1575 | * Add a new stream to a media file. |
3217cb42 PI |
1576 | * |
1577 | * Can only be called in the read_header() function. If the flag | |
1578 | * AVFMTCTX_NOHEADER is in the format context, then new streams | |
1579 | * can be added in read_packet too. | |
1580 | * | |
1581 | * @param s media file handle | |
4f57fa8c | 1582 | * @param id file-format-dependent stream ID |
3217cb42 | 1583 | */ |
569129a6 | 1584 | attribute_deprecated |
b9a281db | 1585 | AVStream *av_new_stream(AVFormatContext *s, int id); |
569129a6 AK |
1586 | #endif |
1587 | ||
c3f9ebf7 | 1588 | #if FF_API_SET_PTS_INFO |
3217cb42 | 1589 | /** |
c3f9ebf7 | 1590 | * @deprecated this function is not supposed to be called outside of lavf |
3217cb42 | 1591 | */ |
c3f9ebf7 | 1592 | attribute_deprecated |
9ee91c2f | 1593 | void av_set_pts_info(AVStream *s, int pts_wrap_bits, |
dec14949 | 1594 | unsigned int pts_num, unsigned int pts_den); |
c3f9ebf7 | 1595 | #endif |
de6d9b64 | 1596 | |
3ba1438d MN |
1597 | #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward |
1598 | #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes | |
4f57fa8c | 1599 | #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes |
2bf74f49 | 1600 | #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number |
3ba1438d | 1601 | |
b754978a | 1602 | int av_find_default_stream_index(AVFormatContext *s); |
3217cb42 PI |
1603 | |
1604 | /** | |
49bd8e4b | 1605 | * Get the index for a specific timestamp. |
4f57fa8c DB |
1606 | * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond |
1607 | * to the timestamp which is <= the requested one, if backward | |
1608 | * is 0, then it will be >= | |
3217cb42 PI |
1609 | * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise |
1610 | * @return < 0 if no such timestamp could be found | |
1611 | */ | |
dc56fc38 | 1612 | int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); |
3217cb42 PI |
1613 | |
1614 | /** | |
49bd8e4b | 1615 | * Add an index entry into a sorted list. Update the entry if the list |
4f57fa8c | 1616 | * already contains it. |
3217cb42 | 1617 | * |
4f57fa8c | 1618 | * @param timestamp timestamp in the time base of the given stream |
3217cb42 | 1619 | */ |
78cb7273 DB |
1620 | int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, |
1621 | int size, int distance, int flags); | |
3217cb42 | 1622 | |
a2faa951 AK |
1623 | #if FF_API_SEEK_PUBLIC |
1624 | attribute_deprecated | |
78cb7273 DB |
1625 | int av_seek_frame_binary(AVFormatContext *s, int stream_index, |
1626 | int64_t target_ts, int flags); | |
a2faa951 | 1627 | attribute_deprecated |
22ffac70 | 1628 | void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); |
a2faa951 | 1629 | attribute_deprecated |
78cb7273 DB |
1630 | int64_t av_gen_search(AVFormatContext *s, int stream_index, |
1631 | int64_t target_ts, int64_t pos_min, | |
1632 | int64_t pos_max, int64_t pos_limit, | |
1633 | int64_t ts_min, int64_t ts_max, | |
1634 | int flags, int64_t *ts_ret, | |
1635 | int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); | |
a2faa951 | 1636 | #endif |
b754978a | 1637 | |
25de5958 AK |
1638 | #if FF_API_FORMAT_PARAMETERS |
1639 | /** | |
1640 | * @deprecated pass the options to avformat_write_header directly. | |
1641 | */ | |
1642 | attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); | |
1643 | #endif | |
3217cb42 PI |
1644 | |
1645 | /** | |
f3bfe388 MR |
1646 | * Split a URL string into components. |
1647 | * | |
1648 | * The pointers to buffers for storing individual components may be null, | |
1649 | * in order to ignore that component. Buffers for components not found are | |
1650 | * set to empty strings. If the port is not found, it is set to a negative | |
1651 | * value. | |
1652 | * | |
1653 | * @param proto the buffer for the protocol | |
1654 | * @param proto_size the size of the proto buffer | |
1655 | * @param authorization the buffer for the authorization | |
1656 | * @param authorization_size the size of the authorization buffer | |
1657 | * @param hostname the buffer for the host name | |
1658 | * @param hostname_size the size of the hostname buffer | |
1659 | * @param port_ptr a pointer to store the port number in | |
1660 | * @param path the buffer for the path | |
1661 | * @param path_size the size of the path buffer | |
1662 | * @param url the URL to split | |
1663 | */ | |
1664 | void av_url_split(char *proto, int proto_size, | |
1665 | char *authorization, int authorization_size, | |
1666 | char *hostname, int hostname_size, | |
1667 | int *port_ptr, | |
1668 | char *path, int path_size, | |
1669 | const char *url); | |
489a7b07 AK |
1670 | /** |
1671 | * @addtogroup lavf_encoding | |
1672 | * @{ | |
1673 | */ | |
f3bfe388 | 1674 | /** |
25de5958 AK |
1675 | * Allocate the stream private data and write the stream header to |
1676 | * an output media file. | |
1677 | * | |
1678 | * @param s Media file handle, must be allocated with avformat_alloc_context(). | |
1679 | * Its oformat field must be set to the desired output format; | |
1680 | * Its pb field must be set to an already openened AVIOContext. | |
1681 | * @param options An AVDictionary filled with AVFormatContext and muxer-private options. | |
1682 | * On return this parameter will be destroyed and replaced with a dict containing | |
1683 | * options that were not found. May be NULL. | |
1684 | * | |
1685 | * @return 0 on success, negative AVERROR on failure. | |
1686 | * | |
1687 | * @see av_opt_find, av_dict_set, avio_open, av_oformat_next. | |
1688 | */ | |
1689 | int avformat_write_header(AVFormatContext *s, AVDictionary **options); | |
1690 | ||
1691 | #if FF_API_FORMAT_PARAMETERS | |
1692 | /** | |
49bd8e4b | 1693 | * Allocate the stream private data and write the stream header to an |
755bfeab | 1694 | * output media file. |
5d820db2 RD |
1695 | * @note: this sets stream time-bases, if possible to stream->codec->time_base |
1696 | * but for some formats it might also be some other time base | |
3217cb42 PI |
1697 | * |
1698 | * @param s media file handle | |
4f57fa8c | 1699 | * @return 0 if OK, AVERROR_xxx on error |
25de5958 AK |
1700 | * |
1701 | * @deprecated use avformat_write_header. | |
3217cb42 | 1702 | */ |
25de5958 AK |
1703 | attribute_deprecated int av_write_header(AVFormatContext *s); |
1704 | #endif | |
3217cb42 PI |
1705 | |
1706 | /** | |
49bd8e4b | 1707 | * Write a packet to an output media file. |
3217cb42 PI |
1708 | * |
1709 | * The packet shall contain one audio or video frame. | |
78cb7273 DB |
1710 | * The packet must be correctly interleaved according to the container |
1711 | * specification, if not then av_interleaved_write_frame must be used. | |
3217cb42 PI |
1712 | * |
1713 | * @param s media file handle | |
78cb7273 DB |
1714 | * @param pkt The packet, which contains the stream_index, buf/buf_size, |
1715 | dts/pts, ... | |
4f57fa8c | 1716 | * @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
3217cb42 | 1717 | */ |
e928649b | 1718 | int av_write_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 PI |
1719 | |
1720 | /** | |
49bd8e4b | 1721 | * Write a packet to an output media file ensuring correct interleaving. |
3217cb42 PI |
1722 | * |
1723 | * The packet must contain one audio or video frame. | |
22e77e44 | 1724 | * If the packets are already correctly interleaved, the application should |
90b5b51e DB |
1725 | * call av_write_frame() instead as it is slightly faster. It is also important |
1726 | * to keep in mind that completely non-interleaved input will need huge amounts | |
1727 | * of memory to interleave with this, so it is preferable to interleave at the | |
1728 | * demuxer level. | |
3217cb42 PI |
1729 | * |
1730 | * @param s media file handle | |
78cb7273 DB |
1731 | * @param pkt The packet, which contains the stream_index, buf/buf_size, |
1732 | dts/pts, ... | |
4f57fa8c | 1733 | * @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
3217cb42 | 1734 | */ |
3c895fc0 | 1735 | int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 PI |
1736 | |
1737 | /** | |
49bd8e4b | 1738 | * Interleave a packet per dts in an output media file. |
3217cb42 | 1739 | * |
78cb7273 | 1740 | * Packets with pkt->destruct == av_destruct_packet will be freed inside this |
22e77e44 | 1741 | * function, so they cannot be used after it. Note that calling av_free_packet() |
78cb7273 | 1742 | * on them is still safe. |
3217cb42 PI |
1743 | * |
1744 | * @param s media file handle | |
1745 | * @param out the interleaved packet will be output here | |
9a58234f | 1746 | * @param pkt the input packet |
3217cb42 PI |
1747 | * @param flush 1 if no further packets are available as input and all |
1748 | * remaining packets should be output | |
1749 | * @return 1 if a packet was output, 0 if no packet could be output, | |
d9526386 | 1750 | * < 0 if an error occurred |
3217cb42 | 1751 | */ |
78cb7273 DB |
1752 | int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, |
1753 | AVPacket *pkt, int flush); | |
e928649b | 1754 | |
3217cb42 | 1755 | /** |
49bd8e4b | 1756 | * Write the stream trailer to an output media file and free the |
2b75bde6 | 1757 | * file private data. |
3217cb42 | 1758 | * |
dc76fe13 RD |
1759 | * May only be called after a successful call to av_write_header. |
1760 | * | |
3217cb42 | 1761 | * @param s media file handle |
4f57fa8c | 1762 | * @return 0 if OK, AVERROR_xxx on error |
3217cb42 | 1763 | */ |
b9a281db | 1764 | int av_write_trailer(AVFormatContext *s); |
c8dffc02 AK |
1765 | |
1766 | /** | |
1767 | * Return the output format in the list of registered output formats | |
1768 | * which best matches the provided parameters, or return NULL if | |
1769 | * there is no match. | |
1770 | * | |
1771 | * @param short_name if non-NULL checks if short_name matches with the | |
1772 | * names of the registered formats | |
1773 | * @param filename if non-NULL checks if filename terminates with the | |
1774 | * extensions of the registered formats | |
1775 | * @param mime_type if non-NULL checks if mime_type matches with the | |
1776 | * MIME type of the registered formats | |
1777 | */ | |
1778 | AVOutputFormat *av_guess_format(const char *short_name, | |
1779 | const char *filename, | |
1780 | const char *mime_type); | |
1781 | ||
1782 | /** | |
1783 | * Guess the codec ID based upon muxer and filename. | |
1784 | */ | |
1785 | enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, | |
1786 | const char *filename, const char *mime_type, | |
1787 | enum AVMediaType type); | |
1788 | ||
489a7b07 AK |
1789 | /** |
1790 | * @} | |
1791 | */ | |
de6d9b64 | 1792 | |
610219a5 AK |
1793 | #if FF_API_DUMP_FORMAT |
1794 | attribute_deprecated void dump_format(AVFormatContext *ic, | |
1795 | int index, | |
1796 | const char *url, | |
1797 | int is_output); | |
1798 | #endif | |
1799 | ||
1800 | void av_dump_format(AVFormatContext *ic, | |
1801 | int index, | |
1802 | const char *url, | |
1803 | int is_output); | |
3217cb42 | 1804 | |
f6c7375a | 1805 | #if FF_API_PARSE_DATE |
3217cb42 | 1806 | /** |
49bd8e4b | 1807 | * Parse datestr and return a corresponding number of microseconds. |
f6c7375a | 1808 | * |
f9436161 | 1809 | * @param datestr String representing a date or a duration. |
f6c7375a SS |
1810 | * See av_parse_time() for the syntax of the provided string. |
1811 | * @deprecated in favor of av_parse_time() | |
3217cb42 | 1812 | */ |
f6c7375a | 1813 | attribute_deprecated |
0c1a9eda | 1814 | int64_t parse_date(const char *datestr, int duration); |
f6c7375a | 1815 | #endif |
de6d9b64 | 1816 | |
76c56376 MN |
1817 | /** |
1818 | * Get the current time in microseconds. | |
1819 | */ | |
0c1a9eda | 1820 | int64_t av_gettime(void); |
94988531 | 1821 | |
ab0287fc | 1822 | #if FF_API_FIND_INFO_TAG |
3217cb42 | 1823 | /** |
ab0287fc | 1824 | * @deprecated use av_find_info_tag in libavutil instead. |
3217cb42 | 1825 | */ |
ab0287fc AK |
1826 | attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); |
1827 | #endif | |
de6d9b64 | 1828 | |
3217cb42 | 1829 | /** |
49bd8e4b | 1830 | * Return in 'buf' the path with '%d' replaced by a number. |
4f57fa8c | 1831 | * |
3217cb42 PI |
1832 | * Also handles the '%0nd' format where 'n' is the total number |
1833 | * of digits and '%%'. | |
1834 | * | |
1835 | * @param buf destination buffer | |
1836 | * @param buf_size destination buffer size | |
1837 | * @param path numbered sequence string | |
8ea0e802 | 1838 | * @param number frame number |
4f57fa8c | 1839 | * @return 0 if OK, -1 on format error |
3217cb42 | 1840 | */ |
5c07cf53 MB |
1841 | int av_get_frame_filename(char *buf, int buf_size, |
1842 | const char *path, int number); | |
3217cb42 PI |
1843 | |
1844 | /** | |
49bd8e4b | 1845 | * Check whether filename actually is a numbered sequence generator. |
3217cb42 PI |
1846 | * |
1847 | * @param filename possible numbered sequence string | |
4f57fa8c | 1848 | * @return 1 if a valid numbered sequence string, 0 otherwise |
3217cb42 | 1849 | */ |
5c07cf53 | 1850 | int av_filename_number_test(const char *filename); |
96baaa6a | 1851 | |
c5388c07 | 1852 | /** |
49bd8e4b | 1853 | * Generate an SDP for an RTP session. |
c5388c07 LA |
1854 | * |
1855 | * @param ac array of AVFormatContexts describing the RTP streams. If the | |
1856 | * array is composed by only one context, such context can contain | |
1857 | * multiple AVStreams (one AVStream per RTP stream). Otherwise, | |
1858 | * all the contexts in the array (an AVCodecContext per RTP stream) | |
4f57fa8c | 1859 | * must contain only one AVStream. |
8767b80f | 1860 | * @param n_files number of AVCodecContexts contained in ac |
c234d40b AK |
1861 | * @param buf buffer where the SDP will be stored (must be allocated by |
1862 | * the caller) | |
8767b80f | 1863 | * @param size the size of the buffer |
4f57fa8c | 1864 | * @return 0 if OK, AVERROR_xxx on error |
c5388c07 | 1865 | */ |
c234d40b | 1866 | int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); |
c3675dfe AK |
1867 | |
1868 | #if FF_API_SDP_CREATE | |
1869 | attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); | |
1870 | #endif | |
c5388c07 | 1871 | |
1a70d127 | 1872 | /** |
49bd8e4b | 1873 | * Return a positive value if the given filename has one of the given |
1a70d127 SS |
1874 | * extensions, 0 otherwise. |
1875 | * | |
1876 | * @param extensions a comma-separated list of filename extensions | |
1877 | */ | |
1878 | int av_match_ext(const char *filename, const char *extensions); | |
1879 | ||
48f9e457 AK |
1880 | /** |
1881 | * Test if the given container can store a codec. | |
1882 | * | |
1883 | * @param std_compliance standards compliance level, one of FF_COMPLIANCE_* | |
1884 | * | |
1885 | * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. | |
1886 | * A negative number if this information is not available. | |
1887 | */ | |
1888 | int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance); | |
1889 | ||
98790382 | 1890 | #endif /* AVFORMAT_AVFORMAT_H */ |