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