Move doxygen comments for av_gettime from utils.c to avformat.h.
[libav.git] / libavformat / avformat.h
CommitLineData
04d7f601
DB
1/*
2 * copyright (c) 2001 Fabrice Bellard
3 *
b78e7197
DB
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
04d7f601
DB
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
b78e7197 9 * version 2.1 of the License, or (at your option) any later version.
04d7f601 10 *
b78e7197 11 * FFmpeg is distributed in the hope that it will be useful,
04d7f601
DB
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
b78e7197 17 * License along with FFmpeg; if not, write to the Free Software
04d7f601
DB
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
98790382
SS
21#ifndef AVFORMAT_AVFORMAT_H
22#define AVFORMAT_AVFORMAT_H
de6d9b64 23
800c289a 24#define LIBAVFORMAT_VERSION_MAJOR 52
a2636c0f 25#define LIBAVFORMAT_VERSION_MINOR 22
74cf4819 26#define LIBAVFORMAT_VERSION_MICRO 1
e97ac1e6 27
800c289a
MR
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)
5aa083ee 34#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
8026c3b5 35
5aa083ee 36#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
4b1f4f23 37
c97429e2
SS
38/**
39 * Returns the LIBAVFORMAT_VERSION_INT constant.
40 */
41unsigned avformat_version(void);
42
f71869a4 43#include <time.h>
67070e4f 44#include <stdio.h> /* FILE */
76a448ed 45#include "libavcodec/avcodec.h"
de6d9b64 46
de6d9b64
FB
47#include "avio.h"
48
49/* packet functions */
50
51typedef struct AVPacket {
f6e76ba4
MN
52 /**
53 * Presentation time stamp in time_base units.
54 * This is the time at which the decompressed packet will be presented
55 * to the user.
56 * Can be AV_NOPTS_VALUE if it is not stored in the file.
57 * pts MUST be larger or equal to dts as presentation can not happen before
58 * decompression, unless one wants to view hex dumps. Some formats misuse
59 * the terms dts and pts/cts to mean something different, these timestamps
60 * must be converted to true pts/dts before they are stored in AVPacket.
61 */
62 int64_t pts;
63 /**
64 * Decompression time stamp in time_base units.
65 * This is the time at which the packet is decompressed.
66 * Can be AV_NOPTS_VALUE if it is not stored in the file.
67 */
68 int64_t dts;
0c1a9eda 69 uint8_t *data;
6fa5a56c
FB
70 int size;
71 int stream_index;
72 int flags;
a82630de
MN
73 /**
74 * Duration of this packet in time_base units, 0 if unknown.
75 * Equals next_pts - this_pts in presentation order.
76 */
77 int duration;
6fa5a56c
FB
78 void (*destruct)(struct AVPacket *);
79 void *priv;
2692067a 80 int64_t pos; ///< byte position in stream, -1 if unknown
a2636c0f
MN
81
82 /**
e7f656d5
MN
83 * This is the time difference in stream timebase units from the pts of this
84 * packet to the point at which the output from the decoder has converged
85 * independent from the availability
a2636c0f
MN
86 * of previous frames (that is the frames are virtually identical no matter
87 * if decoding started from the very first frame or from this keyframe).
88 * is AV_NOPTS_VALUE if unknown.
e7f656d5 89 * This field is not the display duration of the current packet.
a2636c0f
MN
90 *
91 * The purpose of this field is to allow seeking in streams that have no
92 * keyframes in the conventional sense. It corresponds to the
93 * recovery point SEI in H.264 and match_time_delta in nut. It also is
94 * essential for some types of subtitle streams to ensure that all
95 * subtitles are correctly displayed after seeking.
96 */
97 int64_t convergence_duration;
115329f1 98} AVPacket;
6fa5a56c
FB
99#define PKT_FLAG_KEY 0x0001
100
63dd1377 101void av_destruct_packet_nofree(AVPacket *pkt);
3217cb42
PI
102
103/**
104 * Default packet destructor.
105 */
90ad92b3 106void av_destruct_packet(AVPacket *pkt);
63dd1377 107
05abfce9
RP
108/**
109 * Initialize optional fields of a packet to default values.
110 *
111 * @param pkt packet
112 */
659596f0 113void av_init_packet(AVPacket *pkt);
de6d9b64 114
3217cb42 115/**
ac3967c1 116 * Allocate the payload of a packet and initialize its fields to default values.
3217cb42
PI
117 *
118 * @param pkt packet
119 * @param size wanted payload size
120 * @return 0 if OK. AVERROR_xxx otherwise.
121 */
de6d9b64 122int av_new_packet(AVPacket *pkt, int size);
3217cb42
PI
123
124/**
ac3967c1 125 * Allocate and read the payload of a packet and initialize its fields to default values.
3217cb42
PI
126 *
127 * @param pkt packet
128 * @param size wanted payload size
129 * @return >0 (read size) if OK. AVERROR_xxx otherwise.
130 */
2692067a 131int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
3217cb42 132
43d414ba
PI
133/**
134 * @warning This is a hack - the packet memory allocation stuff is broken. The
135 * packet is allocated if it was not really allocated
136 */
fb2758c8 137int av_dup_packet(AVPacket *pkt);
6fa5a56c
FB
138
139/**
140 * Free a packet
141 *
142 * @param pkt packet to free
143 */
144static inline void av_free_packet(AVPacket *pkt)
145{
342474ab 146 if (pkt && pkt->destruct) {
bb270c08 147 pkt->destruct(pkt);
342474ab 148 }
6fa5a56c 149}
de6d9b64
FB
150
151/*************************************************/
916c80e9
FB
152/* fractional numbers for exact pts handling */
153
671adb17
MC
154/**
155 * the exact value of the fractional number is: 'val + num / den'.
156 * num is assumed to be such as 0 <= num < den
157 * @deprecated Use AVRational instead
158*/
916c80e9 159typedef struct AVFrac {
115329f1 160 int64_t val, num, den;
955ab9a4 161} AVFrac attribute_deprecated;
916c80e9 162
916c80e9 163/*************************************************/
b9a281db 164/* input/output formats */
de6d9b64 165
7caf0cc6
MN
166struct AVCodecTag;
167
de6d9b64 168struct AVFormatContext;
b9a281db 169
43d414ba 170/** this structure contains the data a format has to probe a file */
b9a281db 171typedef struct AVProbeData {
5c91a675 172 const char *filename;
b9a281db
FB
173 unsigned char *buf;
174 int buf_size;
175} AVProbeData;
176
0288a747 177#define AVPROBE_SCORE_MAX 100 ///< max score, half of that is used for file extension based detection
87e87886 178#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
de6d9b64
FB
179
180typedef struct AVFormatParameters {
c0df9d75 181 AVRational time_base;
de6d9b64
FB
182 int sample_rate;
183 int channels;
184 int width;
185 int height;
4606ac8d 186 enum PixelFormat pix_fmt;
43d414ba 187 int channel; /**< used to select dv channel */
43d414ba 188 const char *standard; /**< tv standard, NTSC, PAL, SECAM */
72e043dd
EH
189 unsigned int mpeg2ts_raw:1; /**< force raw MPEG2 transport stream output, if possible */
190 unsigned int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport
191 stream packet (only meaningful if
192 mpeg2ts_raw is TRUE) */
193 unsigned int initial_pause:1; /**< do not begin to play the stream
194 immediately (RTSP only) */
195 unsigned int prealloced_context:1;
71957315 196#if LIBAVFORMAT_VERSION_INT < (53<<16)
5b6d5596
MN
197 enum CodecID video_codec_id;
198 enum CodecID audio_codec_id;
71957315 199#endif
de6d9b64
FB
200} AVFormatParameters;
201
40d9c544
RD
202//! demuxer will use url_fopen, no opened file should be provided by the caller
203#define AVFMT_NOFILE 0x0001
43d414ba
PI
204#define AVFMT_NEEDNUMBER 0x0002 /**< needs '%d' in filename */
205#define AVFMT_SHOW_IDS 0x0008 /**< show format stream IDs numbers */
206#define AVFMT_RAWPICTURE 0x0020 /**< format wants AVPicture structure for
fb025625 207 raw picture data */
43d414ba 208#define AVFMT_GLOBALHEADER 0x0040 /**< format wants global header */
755bfeab 209#define AVFMT_NOTIMESTAMPS 0x0080 /**< format does not need / have any timestamps */
43d414ba 210#define AVFMT_GENERIC_INDEX 0x0100 /**< use generic index building code */
ff9c8d7c 211#define AVFMT_TS_DISCONT 0x0200 /**< format allows timestamo discontinuities */
b9a281db
FB
212
213typedef struct AVOutputFormat {
de6d9b64 214 const char *name;
bde15e74
SS
215 /**
216 * Descriptive name for the format, meant to be more human-readable
217 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro
218 * to define it.
219 */
de6d9b64
FB
220 const char *long_name;
221 const char *mime_type;
cf29452b 222 const char *extensions; /**< comma separated filename extensions */
43d414ba 223 /** size of private data so that it can be allocated in the wrapper */
b9a281db 224 int priv_data_size;
de6d9b64 225 /* output support */
43d414ba
PI
226 enum CodecID audio_codec; /**< default audio codec */
227 enum CodecID video_codec; /**< default video codec */
de6d9b64 228 int (*write_header)(struct AVFormatContext *);
e928649b 229 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
de6d9b64 230 int (*write_trailer)(struct AVFormatContext *);
43d414ba 231 /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
b9a281db 232 int flags;
43d414ba 233 /** currently only used to set pixel format if not YUV420P */
290c5fa6 234 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
fe2d6fe2 235 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
7caf0cc6
MN
236
237 /**
238 * list of supported codec_id-codec_tag pairs, ordered by "better choice first"
239 * the arrays are all CODEC_ID_NONE terminated
240 */
c1854592 241 const struct AVCodecTag * const *codec_tag;
7caf0cc6 242
11bf3847
AJ
243 enum CodecID subtitle_codec; /**< default subtitle codec */
244
b9a281db
FB
245 /* private fields */
246 struct AVOutputFormat *next;
247} AVOutputFormat;
de6d9b64 248
b9a281db
FB
249typedef struct AVInputFormat {
250 const char *name;
bde15e74
SS
251 /**
252 * Descriptive name for the format, meant to be more human-readable
253 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro
254 * to define it.
255 */
b9a281db 256 const char *long_name;
43d414ba 257 /** size of private data so that it can be allocated in the wrapper */
b9a281db 258 int priv_data_size;
65d7d68b 259 /**
5d81d641
DB
260 * Tell if a given file has a chance of being parsed by this format.
261 * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
262 * big so you do not have to check for that unless you need more.
65d7d68b 263 */
b9a281db 264 int (*read_probe)(AVProbeData *);
43d414ba 265 /** read the format header and initialize the AVFormatContext
de6d9b64 266 structure. Return 0 if OK. 'ap' if non NULL contains
e42dba48 267 additional paramters. Only used in raw format right
b9a281db 268 now. 'av_new_stream' should be called to create new streams. */
de6d9b64
FB
269 int (*read_header)(struct AVFormatContext *,
270 AVFormatParameters *ap);
43d414ba 271 /** read one packet and put it in 'pkt'. pts and flags are also
b9a281db 272 set. 'av_new_stream' can be called only if the flag
da24c5e3 273 AVFMTCTX_NOHEADER is used. */
de6d9b64 274 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
43d414ba 275 /** close the stream. The AVFormatContext and AVStreams are not
de6d9b64
FB
276 freed by this function */
277 int (*read_close)(struct AVFormatContext *);
115329f1
DB
278 /**
279 * seek to a given timestamp relative to the frames in
3ba1438d
MN
280 * stream component stream_index
281 * @param stream_index must not be -1
115329f1 282 * @param flags selects which direction should be preferred if no exact
3ba1438d 283 * match is available
05ce0f11 284 * @return >= 0 on success (but not necessarily the new offset)
3ba1438d 285 */
115329f1 286 int (*read_seek)(struct AVFormatContext *,
3ba1438d 287 int stream_index, int64_t timestamp, int flags);
8d14a25c 288 /**
2576a9ec 289 * gets the next timestamp in stream[stream_index].time_base units.
d9526386 290 * @return the timestamp or AV_NOPTS_VALUE if an error occurred
8d14a25c
MN
291 */
292 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
293 int64_t *pos, int64_t pos_limit);
43d414ba 294 /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
de6d9b64 295 int flags;
43d414ba 296 /** if extensions are defined, then no probe is done. You should
b9a281db
FB
297 usually not use extension format guessing because it is not
298 reliable enough */
299 const char *extensions;
43d414ba 300 /** general purpose read only value that the format can use */
b9a281db 301 int value;
fb2758c8 302
43d414ba 303 /** start/resume playing - only meaningful if using a network based format
fb2758c8
FB
304 (RTSP) */
305 int (*read_play)(struct AVFormatContext *);
306
43d414ba 307 /** pause playing - only meaningful if using a network based format
fb2758c8
FB
308 (RTSP) */
309 int (*read_pause)(struct AVFormatContext *);
310
c1854592 311 const struct AVCodecTag * const *codec_tag;
7caf0cc6 312
b9a281db
FB
313 /* private fields */
314 struct AVInputFormat *next;
315} AVInputFormat;
de6d9b64 316
57004ff1
AJ
317enum AVStreamParseType {
318 AVSTREAM_PARSE_NONE,
319 AVSTREAM_PARSE_FULL, /**< full parsing and repack */
320 AVSTREAM_PARSE_HEADERS, /**< only parse headers, don't repack */
321 AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
322};
323
fb2758c8
FB
324typedef struct AVIndexEntry {
325 int64_t pos;
326 int64_t timestamp;
327#define AVINDEX_KEYFRAME 0x0001
30a43f2d 328 int flags:2;
90b5b51e 329 int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align).
43d414ba 330 int min_distance; /**< min distance between this and the previous keyframe, used to avoid unneeded searching */
fb2758c8
FB
331} AVIndexEntry;
332
90c2295b
ES
333#define AV_DISPOSITION_DEFAULT 0x0001
334#define AV_DISPOSITION_DUB 0x0002
335#define AV_DISPOSITION_ORIGINAL 0x0004
336#define AV_DISPOSITION_COMMENT 0x0008
337#define AV_DISPOSITION_LYRICS 0x0010
338#define AV_DISPOSITION_KARAOKE 0x0020
339
ba66ae94
MN
340/**
341 * Stream structure.
342 * New fields can be added to the end with minor version bumps.
8bfb108b 343 * Removal, reordering and changes to existing fields require a major
ba66ae94 344 * version bump.
8bfb108b 345 * sizeof(AVStream) must not be used outside libav*.
ba66ae94 346 */
de6d9b64 347typedef struct AVStream {
43d414ba
PI
348 int index; /**< stream index in AVFormatContext */
349 int id; /**< format specific stream id */
350 AVCodecContext *codec; /**< codec context */
b4b87d48 351 /**
8bfb108b
DB
352 * Real base frame rate of the stream.
353 * This is the lowest frame rate with which all timestamps can be
864ff8c1 354 * represented accurately (it is the least common multiple of all
8bfb108b
DB
355 * frame rates in the stream), Note, this value is just a guess!
356 * For example if the timebase is 1/90000 and all frames have either
357 * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1.
b4b87d48
MN
358 */
359 AVRational r_frame_rate;
de6d9b64 360 void *priv_data;
82583548 361
b9a281db 362 /* internal data used in av_find_stream_info() */
82583548 363 int64_t first_dts;
43d414ba 364 /** encoding: PTS generation when outputing stream */
a9fd2b19 365 struct AVFrac pts;
5b28c8c3
MN
366
367 /**
8bfb108b
DB
368 * This is the fundamental unit of time (in seconds) in terms
369 * of which frame timestamps are represented. For fixed-fps content,
370 * timebase should be 1/frame rate and timestamp increments should be
5b28c8c3
MN
371 * identically 1.
372 */
9ee91c2f 373 AVRational time_base;
43d414ba 374 int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
a48b7a6b 375 /* ffmpeg.c private use */
15786dc4 376 int stream_copy; /**< if set, just copy stream */
755bfeab 377 enum AVDiscard discard; ///< selects which packets can be discarded at will and do not need to be demuxed
b4aea108 378 //FIXME move stuff to a flags field?
43d414ba 379 /** quality, as it has been removed from AVCodecContext and put in AVVideoFrame
755bfeab 380 * MN: dunno if that is the right place for it */
115329f1 381 float quality;
6d96a9b9 382 /**
8bfb108b
DB
383 * Decoding: pts of the first frame of the stream, in stream time base.
384 * Only set this if you are absolutely 100% sure that the value you set
385 * it to really is the pts of the first frame.
4854c253 386 * This may be undefined (AV_NOPTS_VALUE).
8bfb108b
DB
387 * @note The ASF header does NOT contain a correct start_time the ASF
388 * demuxer must NOT set this.
6d96a9b9 389 */
115329f1 390 int64_t start_time;
e26381b6 391 /**
8bfb108b 392 * Decoding: duration of the stream, in stream time base.
e26381b6
NB
393 * If a source file does not specify a duration, but does specify
394 * a bitrate, this value will be estimates from bit rate and file size.
395 */
ee404803 396 int64_t duration;
fb2758c8 397
43d414ba 398 char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
09730260 399
fb2758c8 400 /* av_read_frame() support */
57004ff1 401 enum AVStreamParseType need_parsing;
fb2758c8 402 struct AVCodecParserContext *parser;
6ec87caa 403
fb2758c8 404 int64_t cur_dts;
635fbcb1
MN
405 int last_IP_duration;
406 int64_t last_IP_pts;
fb2758c8 407 /* av_seek_frame() support */
43d414ba 408 AVIndexEntry *index_entries; /**< only used if the format does not
fb2758c8
FB
409 support seeking natively */
410 int nb_index_entries;
191e8ca7 411 unsigned int index_entries_allocated_size;
115329f1 412
b4b87d48 413 int64_t nb_frames; ///< number of frames in this stream if known or 0
504ee036 414
0d84a8f6
BC
415#if LIBAVFORMAT_VERSION_INT < (53<<16)
416 int64_t unused[4+1];
417#endif
f8d7c9d3
ES
418
419 char *filename; /**< source filename of the stream */
90c2295b
ES
420
421 int disposition; /**< AV_DISPOSITION_* bitfield */
0bef08e5
MN
422
423 AVProbeData probe_data;
0d84a8f6
BC
424#define MAX_REORDER_DELAY 16
425 int64_t pts_buffer[MAX_REORDER_DELAY+1];
c30a4489
AJ
426
427 /**
428 * sample aspect ratio (0 if unknown)
429 * - encoding: Set by user.
430 * - decoding: Set by libavformat.
431 */
432 AVRational sample_aspect_ratio;
de6d9b64
FB
433} AVStream;
434
15afa396
NS
435#define AV_PROGRAM_RUNNING 1
436
ba66ae94 437/**
ba66ae94 438 * New fields can be added to the end with minor version bumps.
8bfb108b 439 * Removal, reordering and changes to existing fields require a major
ba66ae94 440 * version bump.
8bfb108b 441 * sizeof(AVProgram) must not be used outside libav*.
ba66ae94 442 */
15afa396
NS
443typedef struct AVProgram {
444 int id;
445 char *provider_name; ///< Network name for DVB streams
446 char *name; ///< Service name for DVB streams
447 int flags;
448 enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
526efa10
NS
449 unsigned int *stream_index;
450 unsigned int nb_stream_indexes;
15afa396
NS
451} AVProgram;
452
43d414ba 453#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
da24c5e3
FB
454 (streams are added dynamically) */
455
79d7836a 456typedef struct AVChapter {
d2974f16
MN
457 int id; ///< Unique id to identify the chapter
458 AVRational time_base; ///< Timebase in which the start/end timestamps are specified
8931e7b4 459 int64_t start, end; ///< chapter start/end time in time_base units
c2fb6be4 460 char *title; ///< chapter title
79d7836a
AK
461} AVChapter;
462
de6d9b64
FB
463#define MAX_STREAMS 20
464
252f17e2
MN
465/**
466 * format I/O context.
467 * New fields can be added to the end with minor version bumps.
8bfb108b 468 * Removal, reordering and changes to existing fields require a major
252f17e2 469 * version bump.
8bfb108b 470 * sizeof(AVFormatContext) must not be used outside libav*.
252f17e2 471 */
de6d9b64 472typedef struct AVFormatContext {
43d414ba 473 const AVClass *av_class; /**< set by av_alloc_format_context */
b9a281db
FB
474 /* can only be iformat or oformat, not both at the same time */
475 struct AVInputFormat *iformat;
476 struct AVOutputFormat *oformat;
de6d9b64 477 void *priv_data;
899681cd 478 ByteIOContext *pb;
db69c2e5 479 unsigned int nb_streams;
de6d9b64 480 AVStream *streams[MAX_STREAMS];
43d414ba 481 char filename[1024]; /**< input or output filename */
de6d9b64 482 /* stream info */
4568325a 483 int64_t timestamp;
de6d9b64
FB
484 char title[512];
485 char author[512];
486 char copyright[512];
487 char comment[512];
6a58e151 488 char album[512];
43d414ba
PI
489 int year; /**< ID3 year, 0 if none */
490 int track; /**< track number, 0 if none */
491 char genre[32]; /**< ID3 genre */
6a58e151 492
43d414ba 493 int ctx_flags; /**< format specific flags, see AVFMTCTX_xx */
916c80e9 494 /* private data for pts handling (do not modify directly) */
43d414ba 495 /** This buffer is only needed when packets were already buffered but
de6d9b64
FB
496 not decoded, for example to get the codec parameters in mpeg
497 streams */
ee404803
FB
498 struct AVPacketList *packet_buffer;
499
43d414ba 500 /** decoding: position of the first frame of the component, in
ee404803
FB
501 AV_TIME_BASE fractional seconds. NEVER set this value directly:
502 it is deduced from the AVStream values. */
115329f1 503 int64_t start_time;
43d414ba 504 /** decoding: duration of the stream, in AV_TIME_BASE fractional
ee404803
FB
505 seconds. NEVER set this value directly: it is deduced from the
506 AVStream values. */
507 int64_t duration;
43d414ba 508 /** decoding: total file size. 0 if unknown */
ee404803 509 int64_t file_size;
43d414ba 510 /** decoding: total stream bitrate in bit/s, 0 if not
ee404803
FB
511 available. Never set it directly if the file_size and the
512 duration are known as ffmpeg can compute it automatically. */
513 int bit_rate;
fb2758c8
FB
514
515 /* av_read_frame() support */
516 AVStream *cur_st;
517 const uint8_t *cur_ptr;
518 int cur_len;
519 AVPacket cur_pkt;
520
fb2758c8 521 /* av_seek_frame() support */
43d414ba 522 int64_t data_offset; /** offset of the first packet */
fb2758c8 523 int index_built;
115329f1 524
2db3c638
MN
525 int mux_rate;
526 int packet_size;
17c88cb0
MN
527 int preload;
528 int max_delay;
8108551a 529
115329f1
DB
530#define AVFMT_NOOUTPUTLOOP -1
531#define AVFMT_INFINITEOUTPUTLOOP 0
43d414ba 532 /** number of times to loop output in formats that support it */
8108551a 533 int loop_output;
115329f1 534
30bc6613
MN
535 int flags;
536#define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames
2c00106c 537#define AVFMT_FLAG_IGNIDX 0x0002 ///< ignore index
bf09c2e2 538#define AVFMT_FLAG_NONBLOCK 0x0004 ///< do not block when reading packets from input
5894e1bb
VP
539
540 int loop_input;
43d414ba 541 /** decoding: size of data to probe; encoding unused */
9e6c9470 542 unsigned int probesize;
a44b3c4d
MN
543
544 /**
545 * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info()
546 */
547 int max_analyze_duration;
c964c2c7
RD
548
549 const uint8_t *key;
550 int keylen;
15afa396
NS
551
552 unsigned int nb_programs;
553 AVProgram **programs;
62600469
MN
554
555 /**
556 * Forced video codec_id.
557 * demuxing: set by user
558 */
559 enum CodecID video_codec_id;
560 /**
561 * Forced audio codec_id.
562 * demuxing: set by user
563 */
564 enum CodecID audio_codec_id;
565 /**
566 * Forced subtitle codec_id.
567 * demuxing: set by user
568 */
569 enum CodecID subtitle_codec_id;
3dea63bd
PK
570
571 /**
572 * Maximum amount of memory in bytes to use per stream for the index.
573 * If the needed index exceeds this size entries will be discarded as
574 * needed to maintain a smaller size. This can lead to slower or less
575 * accurate seeking (depends on demuxer).
576 * Demuxers for which a full in memory index is mandatory will ignore
577 * this.
578 * muxing : unused
579 * demuxing: set by user
580 */
581 unsigned int max_index_size;
ab8ab30c
RP
582
583 /**
ffa71b2b 584 * Maximum amount of memory in bytes to use for buffering frames
ab8ab30c
RP
585 * obtained from real-time capture devices.
586 */
587 unsigned int max_picture_buffer;
79d7836a 588
fbabf1e9 589 unsigned int nb_chapters;
79d7836a 590 AVChapter **chapters;
45b2b05f
MN
591
592 /**
593 * Flags to enable debuging.
594 */
595 int debug;
596#define FF_FDEBUG_TS 0x0001
0bef08e5
MN
597
598 /**
599 * raw packets from the demuxer, prior to parsing and decoding.
600 * This buffer is used for buffering packets until the codec can
601 * be identified, as parsing cannot be done without knowing the
602 * codec.
603 */
604 struct AVPacketList *raw_packet_buffer;
5c5b1731
MR
605 struct AVPacketList *raw_packet_buffer_end;
606
607 struct AVPacketList *packet_buffer_end;
de6d9b64
FB
608} AVFormatContext;
609
610typedef struct AVPacketList {
611 AVPacket pkt;
612 struct AVPacketList *next;
613} AVPacketList;
614
84be6e72 615#if LIBAVFORMAT_VERSION_INT < (53<<16)
b9a281db
FB
616extern AVInputFormat *first_iformat;
617extern AVOutputFormat *first_oformat;
84be6e72
MN
618#endif
619
620AVInputFormat *av_iformat_next(AVInputFormat *f);
621AVOutputFormat *av_oformat_next(AVOutputFormat *f);
de6d9b64 622
5b6d5596 623enum CodecID av_guess_image2_codec(const char *filename);
290c5fa6 624
b9a281db
FB
625/* XXX: use automatic init with either ELF sections or C file parser */
626/* modules */
de6d9b64 627
b9a281db 628/* utils.c */
b9a281db
FB
629void av_register_input_format(AVInputFormat *format);
630void av_register_output_format(AVOutputFormat *format);
115329f1 631AVOutputFormat *guess_stream_format(const char *short_name,
36ada60c 632 const char *filename, const char *mime_type);
115329f1 633AVOutputFormat *guess_format(const char *short_name,
b9a281db 634 const char *filename, const char *mime_type);
3217cb42
PI
635
636/**
637 * Guesses the codec id based upon muxer and filename.
638 */
115329f1 639enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
5b6d5596 640 const char *filename, const char *mime_type, enum CodecType type);
de6d9b64 641
3217cb42 642/**
750f0e1f
PI
643 * Send a nice hexadecimal dump of a buffer to the specified file stream.
644 *
645 * @param f The file stream pointer where the dump should be sent to.
3217cb42
PI
646 * @param buf buffer
647 * @param size buffer size
750f0e1f
PI
648 *
649 * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
3217cb42 650 */
fb2758c8 651void av_hex_dump(FILE *f, uint8_t *buf, int size);
3217cb42
PI
652
653/**
750f0e1f
PI
654 * Send a nice hexadecimal dump of a buffer to the log.
655 *
656 * @param avcl A pointer to an arbitrary struct of which the first field is a
657 * pointer to an AVClass struct.
658 * @param level The importance level of the message, lower values signifying
659 * higher importance.
660 * @param buf buffer
661 * @param size buffer size
662 *
663 * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
664 */
665void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
666
667/**
668 * Send a nice dump of a packet to the specified file stream.
669 *
670 * @param f The file stream pointer where the dump should be sent to.
3217cb42
PI
671 * @param pkt packet to dump
672 * @param dump_payload true if the payload must be displayed too
673 */
fb2758c8 674void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
de6d9b64 675
750f0e1f
PI
676/**
677 * Send a nice dump of a packet to the log.
678 *
679 * @param avcl A pointer to an arbitrary struct of which the first field is a
680 * pointer to an AVClass struct.
681 * @param level The importance level of the message, lower values signifying
682 * higher importance.
683 * @param pkt packet to dump
684 * @param dump_payload true if the payload must be displayed too
685 */
686void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
687
94988531 688void av_register_all(void);
de6d9b64 689
43d414ba 690/** codec tag <-> codec id */
6c77805f
MN
691enum CodecID av_codec_get_id(const struct AVCodecTag **tags, unsigned int tag);
692unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id);
7caf0cc6 693
b9a281db 694/* media file input */
3217cb42
PI
695
696/**
697 * finds AVInputFormat based on input format's short name.
698 */
b9a281db 699AVInputFormat *av_find_input_format(const char *short_name);
3217cb42
PI
700
701/**
702 * Guess file format.
703 *
704 * @param is_opened whether the file is already opened, determines whether
705 * demuxers with or without AVFMT_NOFILE are probed
706 */
94988531 707AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
3217cb42
PI
708
709/**
710 * Allocates all the structures needed to read an input stream.
711 * This does not open the needed codecs for decoding the stream[s].
712 */
115329f1
DB
713int av_open_input_stream(AVFormatContext **ic_ptr,
714 ByteIOContext *pb, const char *filename,
da24c5e3 715 AVInputFormat *fmt, AVFormatParameters *ap);
3217cb42
PI
716
717/**
864ff8c1 718 * Open a media file as input. The codecs are not opened. Only the file
3217cb42
PI
719 * header (if present) is read.
720 *
721 * @param ic_ptr the opened media file handle is put here
722 * @param filename filename to open.
723 * @param fmt if non NULL, force the file format to use
724 * @param buf_size optional buffer size (zero if default is OK)
e42dba48 725 * @param ap additional parameters needed when opening the file (NULL if default)
3217cb42
PI
726 * @return 0 if OK. AVERROR_xxx otherwise.
727 */
115329f1 728int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
b9a281db
FB
729 AVInputFormat *fmt,
730 int buf_size,
731 AVFormatParameters *ap);
88808c60
MN
732/**
733 * Allocate an AVFormatContext.
5d81d641 734 * Can be freed with av_free() but do not forget to free everything you
88808c60
MN
735 * explicitly allocated as well!
736 */
bc874dae 737AVFormatContext *av_alloc_format_context(void);
b9a281db 738
3217cb42
PI
739/**
740 * Read packets of a media file to get stream information. This
741 * is useful for file formats with no headers such as MPEG. This
742 * function also computes the real frame rate in case of mpeg2 repeat
743 * frame mode.
744 * The logical file position is not changed by this function;
745 * examined packets may be buffered for later processing.
746 *
747 * @param ic media file handle
748 * @return >=0 if OK. AVERROR_xxx if error.
4e8988a3 749 * @todo Let user decide somehow what information is needed so we do not waste time getting stuff the user does not need.
3217cb42 750 */
b9a281db 751int av_find_stream_info(AVFormatContext *ic);
3217cb42
PI
752
753/**
754 * Read a transport packet from a media file.
755 *
864ff8c1 756 * This function is obsolete and should never be used.
3217cb42
PI
757 * Use av_read_frame() instead.
758 *
759 * @param s media file handle
760 * @param pkt is filled
761 * @return 0 if OK. AVERROR_xxx if error.
762 */
de6d9b64 763int av_read_packet(AVFormatContext *s, AVPacket *pkt);
3217cb42
PI
764
765/**
766 * Return the next frame of a stream.
767 *
768 * The returned packet is valid
769 * until the next av_read_frame() or until av_close_input_file() and
770 * must be freed with av_free_packet. For video, the packet contains
771 * exactly one frame. For audio, it contains an integer number of
772 * frames if each frame has a known fixed size (e.g. PCM or ADPCM
773 * data). If the audio frames have a variable size (e.g. MPEG audio),
774 * then it contains one frame.
775 *
776 * pkt->pts, pkt->dts and pkt->duration are always set to correct
a050f802 777 * values in AVStream.timebase units (and guessed if the format cannot
3217cb42
PI
778 * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format
779 * has B frames, so it is better to rely on pkt->dts if you do not
780 * decompress the payload.
781 *
782 * @return 0 if OK, < 0 if error or end of file.
783 */
fb2758c8 784int av_read_frame(AVFormatContext *s, AVPacket *pkt);
3217cb42
PI
785
786/**
787 * Seek to the key frame at timestamp.
788 * 'timestamp' in 'stream_index'.
789 * @param stream_index If stream_index is (-1), a default
790 * stream is selected, and timestamp is automatically converted
791 * from AV_TIME_BASE units to the stream specific time_base.
792 * @param timestamp timestamp in AVStream.time_base units
793 * or if there is no stream specified then in AV_TIME_BASE units
794 * @param flags flags which select direction and seeking mode
795 * @return >= 0 on success
796 */
3ba1438d 797int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
3217cb42
PI
798
799/**
800 * start playing a network based stream (e.g. RTSP stream) at the
801 * current position
802 */
fb2758c8 803int av_read_play(AVFormatContext *s);
3217cb42
PI
804
805/**
806 * Pause a network based stream (e.g. RTSP stream).
807 *
808 * Use av_read_play() to resume it.
809 */
fb2758c8 810int av_read_pause(AVFormatContext *s);
3217cb42
PI
811
812/**
2506fd54
RD
813 * Free a AVFormatContext allocated by av_open_input_stream.
814 * @param s context to free
815 */
816void av_close_input_stream(AVFormatContext *s);
817
818/**
3217cb42
PI
819 * Close a media file (but not its codecs).
820 *
821 * @param s media file handle
822 */
de6d9b64 823void av_close_input_file(AVFormatContext *s);
3217cb42
PI
824
825/**
826 * Add a new stream to a media file.
827 *
828 * Can only be called in the read_header() function. If the flag
829 * AVFMTCTX_NOHEADER is in the format context, then new streams
830 * can be added in read_packet too.
831 *
832 * @param s media file handle
833 * @param id file format dependent stream id
834 */
b9a281db 835AVStream *av_new_stream(AVFormatContext *s, int id);
15afa396 836AVProgram *av_new_program(AVFormatContext *s, int id);
3217cb42
PI
837
838/**
79d7836a
AK
839 * Add a new chapter.
840 * This function is NOT part of the public API
841 * and should be ONLY used by demuxers.
842 *
843 * @param s media file handle
7a2a3e8e 844 * @param id unique id for this chapter
abd2256d
MN
845 * @param start chapter start time in time_base units
846 * @param end chapter end time in time_base units
79d7836a 847 * @param title chapter title
5c37f43a
MN
848 *
849 * @return AVChapter or NULL if error.
79d7836a 850 */
abd2256d 851AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title);
79d7836a
AK
852
853/**
3217cb42
PI
854 * Set the pts for a given stream.
855 *
856 * @param s stream
857 * @param pts_wrap_bits number of bits effectively used by the pts
858 * (used for wrap control, 33 is the value for MPEG)
859 * @param pts_num numerator to convert to seconds (MPEG: 1)
860 * @param pts_den denominator to convert to seconds (MPEG: 90000)
861 */
9ee91c2f 862void av_set_pts_info(AVStream *s, int pts_wrap_bits,
916c80e9 863 int pts_num, int pts_den);
de6d9b64 864
3ba1438d
MN
865#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
866#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
27a5fe5f 867#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes
3ba1438d 868
b754978a 869int av_find_default_stream_index(AVFormatContext *s);
3217cb42
PI
870
871/**
872 * Gets the index for a specific timestamp.
873 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to
874 * the timestamp which is <= the requested one, if backward is 0
875 * then it will be >=
876 * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
877 * @return < 0 if no such timestamp could be found
878 */
dc56fc38 879int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
3217cb42
PI
880
881/**
3dea63bd
PK
882 * Ensures the index uses less memory than the maximum specified in
883 * AVFormatContext.max_index_size, by discarding entries if it grows
884 * too large.
885 * This function is not part of the public API and should only be called
886 * by demuxers.
887 */
888void ff_reduce_index(AVFormatContext *s, int stream_index);
889
890/**
3217cb42
PI
891 * Add a index entry into a sorted list updateing if it is already there.
892 *
893 * @param timestamp timestamp in the timebase of the given stream
894 */
3e9245a9 895int av_add_index_entry(AVStream *st,
30a43f2d 896 int64_t pos, int64_t timestamp, int size, int distance, int flags);
3217cb42
PI
897
898/**
899 * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
755bfeab 900 * This is not supposed to be called directly by a user application, but by demuxers.
3217cb42
PI
901 * @param target_ts target timestamp in the time base of the given stream
902 * @param stream_index stream number
903 */
3ba1438d 904int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
3217cb42
PI
905
906/**
907 * Updates cur_dts of all streams based on given timestamp and AVStream.
908 *
909 * Stream ref_st unchanged, others set cur_dts in their native timebase
755bfeab 910 * only needed for timestamp wrapping or if (dts not set and pts!=dts).
3217cb42
PI
911 * @param timestamp new dts expressed in time_base of param ref_st
912 * @param ref_st reference stream giving time_base of param timestamp
913 */
22ffac70 914void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
3217cb42
PI
915
916/**
917 * Does a binary search using read_timestamp().
755bfeab 918 * This is not supposed to be called directly by a user application, but by demuxers.
3217cb42
PI
919 * @param target_ts target timestamp in the time base of the given stream
920 * @param stream_index stream number
921 */
89ddd2a9 922int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
b754978a 923
43d414ba 924/** media file output */
290c5fa6 925int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
3217cb42
PI
926
927/**
755bfeab
DB
928 * Allocate the stream private data and write the stream header to an
929 * output media file.
3217cb42
PI
930 *
931 * @param s media file handle
932 * @return 0 if OK. AVERROR_xxx if error.
933 */
b9a281db 934int av_write_header(AVFormatContext *s);
3217cb42
PI
935
936/**
937 * Write a packet to an output media file.
938 *
939 * The packet shall contain one audio or video frame.
940 * The packet must be correctly interleaved according to the container specification,
941 * if not then av_interleaved_write_frame must be used
942 *
943 * @param s media file handle
944 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
945 * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
946 */
e928649b 947int av_write_frame(AVFormatContext *s, AVPacket *pkt);
3217cb42
PI
948
949/**
950 * Writes a packet to an output media file ensuring correct interleaving.
951 *
952 * The packet must contain one audio or video frame.
953 * If the packets are already correctly interleaved the application should
90b5b51e
DB
954 * call av_write_frame() instead as it is slightly faster. It is also important
955 * to keep in mind that completely non-interleaved input will need huge amounts
956 * of memory to interleave with this, so it is preferable to interleave at the
957 * demuxer level.
3217cb42
PI
958 *
959 * @param s media file handle
960 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
961 * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
962 */
3c895fc0 963int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
3217cb42
PI
964
965/**
966 * Interleave a packet per DTS in an output media file.
967 *
968 * Packets with pkt->destruct == av_destruct_packet will be freed inside this function,
969 * so they cannot be used after it, note calling av_free_packet() on them is still safe.
970 *
971 * @param s media file handle
972 * @param out the interleaved packet will be output here
973 * @param in the input packet
974 * @param flush 1 if no further packets are available as input and all
975 * remaining packets should be output
976 * @return 1 if a packet was output, 0 if no packet could be output,
d9526386 977 * < 0 if an error occurred
3217cb42 978 */
f21c0b4c 979int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush);
e928649b 980
3217cb42
PI
981/**
982 * @brief Write the stream trailer to an output media file and
983 * free the file private data.
984 *
dc76fe13
RD
985 * May only be called after a successful call to av_write_header.
986 *
3217cb42
PI
987 * @param s media file handle
988 * @return 0 if OK. AVERROR_xxx if error.
989 */
b9a281db 990int av_write_trailer(AVFormatContext *s);
de6d9b64
FB
991
992void dump_format(AVFormatContext *ic,
115329f1 993 int index,
de6d9b64
FB
994 const char *url,
995 int is_output);
3217cb42
PI
996
997/**
998 * parses width and height out of string str.
26ef3220 999 * @deprecated Use av_parse_video_frame_size instead.
3217cb42 1000 */
26ef3220 1001attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
3217cb42
PI
1002
1003/**
1004 * Converts frame rate from string to a fraction.
26ef3220 1005 * @deprecated Use av_parse_video_frame_rate instead.
3217cb42 1006 */
26ef3220 1007attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
3217cb42
PI
1008
1009/**
f9436161
SS
1010 * Parses \p datestr and returns a corresponding number of microseconds.
1011 * @param datestr String representing a date or a duration.
1012 * - If a date the syntax is:
3217cb42 1013 * @code
3217cb42 1014 * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
3217cb42 1015 * @endcode
f9436161
SS
1016 * Time is localtime unless Z is appended, in which case it is
1017 * interpreted as UTC.
1018 * If the year-month-day part isn't specified it takes the current
1019 * year-month-day.
1020 * Returns the number of microseconds since 1st of January, 1970 up to
1021 * the time of the parsed date or INT64_MIN if \p datestr cannot be
1022 * successfully parsed.
1023 * - If a duration the syntax is:
1024 * @code
1025 * [-]HH[:MM[:SS[.m...]]]
1026 * [-]S+[.m...]
1027 * @endcode
1028 * Returns the number of microseconds contained in a time interval
1029 * with the specified duration or INT64_MIN if \p datestr cannot be
7338d368 1030 * successfully parsed.
f9436161
SS
1031 * @param duration Flag which tells how to interpret \p datestr, if
1032 * not zero \p datestr is interpreted as a duration, otherwise as a
1033 * date.
3217cb42 1034 */
0c1a9eda 1035int64_t parse_date(const char *datestr, int duration);
de6d9b64 1036
fff5e687 1037/** Gets the current time in microseconds. */
0c1a9eda 1038int64_t av_gettime(void);
94988531 1039
de6d9b64
FB
1040/* ffm specific for ffserver */
1041#define FFM_PACKET_SIZE 4096
1042offset_t ffm_read_write_index(int fd);
1043void ffm_write_write_index(int fd, offset_t pos);
1044void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
1045
3217cb42
PI
1046/**
1047 * Attempts to find a specific tag in a URL.
1048 *
1049 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
1050 * Return 1 if found.
1051 */
de6d9b64
FB
1052int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1053
3217cb42
PI
1054/**
1055 * Returns in 'buf' the path with '%d' replaced by number.
1056
1057 * Also handles the '%0nd' format where 'n' is the total number
1058 * of digits and '%%'.
1059 *
1060 * @param buf destination buffer
1061 * @param buf_size destination buffer size
1062 * @param path numbered sequence string
8ea0e802 1063 * @param number frame number
3217cb42
PI
1064 * @return 0 if OK, -1 if format error.
1065 */
5c07cf53
MB
1066int av_get_frame_filename(char *buf, int buf_size,
1067 const char *path, int number);
3217cb42
PI
1068
1069/**
1070 * Check whether filename actually is a numbered sequence generator.
1071 *
1072 * @param filename possible numbered sequence string
1073 * @return 1 if a valid numbered sequence string, 0 otherwise.
1074 */
5c07cf53 1075int av_filename_number_test(const char *filename);
96baaa6a 1076
c5388c07
LA
1077/**
1078 * Generate an SDP for an RTP session.
1079 *
1080 * @param ac array of AVFormatContexts describing the RTP streams. If the
1081 * array is composed by only one context, such context can contain
1082 * multiple AVStreams (one AVStream per RTP stream). Otherwise,
1083 * all the contexts in the array (an AVCodecContext per RTP stream)
1084 * must contain only one AVStream
8767b80f
LA
1085 * @param n_files number of AVCodecContexts contained in ac
1086 * @param buff buffer where the SDP will be stored (must be allocated by
1087 * the caller
1088 * @param size the size of the buffer
1089 * @return 0 if OK. AVERROR_xxx if error.
c5388c07 1090 */
8767b80f 1091int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
c5388c07 1092
fb025625 1093#ifdef HAVE_AV_CONFIG_H
f71869a4 1094
903a2e86 1095void ff_dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
39f472c3 1096
e4e70d2e 1097#ifdef __GNUC__
39f472c3
FB
1098#define dynarray_add(tab, nb_ptr, elem)\
1099do {\
1100 typeof(tab) _tab = (tab);\
1101 typeof(elem) _elem = (elem);\
1102 (void)sizeof(**_tab == _elem); /* check that types are compatible */\
903a2e86 1103 ff_dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
39f472c3 1104} while(0)
e4e70d2e
FH
1105#else
1106#define dynarray_add(tab, nb_ptr, elem)\
1107do {\
903a2e86 1108 ff_dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
e4e70d2e
FH
1109} while(0)
1110#endif
39f472c3 1111
f71869a4 1112time_t mktimegm(struct tm *tm);
0c9fc6e1 1113struct tm *brktimegm(time_t secs, struct tm *tm);
115329f1 1114const char *small_strptime(const char *p, const char *fmt,
f71869a4
FB
1115 struct tm *dt);
1116
fb025625
FB
1117struct in_addr;
1118int resolve_host(struct in_addr *sin_addr, const char *hostname);
1119
1120void url_split(char *proto, int proto_size,
6ba5cbc6 1121 char *authorization, int authorization_size,
fb025625
FB
1122 char *hostname, int hostname_size,
1123 int *port_ptr,
1124 char *path, int path_size,
1125 const char *url);
1126
a941f391
FB
1127int match_ext(const char *filename, const char *extensions);
1128
fb025625
FB
1129#endif /* HAVE_AV_CONFIG_H */
1130
98790382 1131#endif /* AVFORMAT_AVFORMAT_H */