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