Statistics
| Branch: | Revision:

ffmpeg / libavformat / avformat.h @ c1736936

History | View | Annotate | Download (44.5 KB)

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 39
26
#define LIBAVFORMAT_VERSION_MICRO  2
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

    
85
typedef struct {
86
    char *key;
87
    char *value;
88
}AVMetadataTag;
89

    
90
typedef struct AVMetadata AVMetadata;
91
typedef struct AVMetadataConv AVMetadataConv;
92

    
93
/**
94
 * Gets a metadata element with matching key.
95
 * @param prev Set to the previous matching element to find the next.
96
 * @param flags Allows case as well as suffix-insensitive comparisons.
97
 * @return Found tag or NULL, changing key or value leads to undefined behavior.
98
 */
99
AVMetadataTag *
100
av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
101

    
102
/**
103
 * Sets the given tag in m, overwriting an existing tag.
104
 * @param key tag key to add to m (will be av_strduped)
105
 * @param value tag value to add to m (will be av_strduped)
106
 * @return >= 0 on success otherwise an error code <0
107
 */
108
int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
109

    
110
/**
111
 * Converts all the metadata sets from ctx according to the source and
112
 * destination conversion tables.
113
 * @param d_conv destination tags format conversion table
114
 * @param s_conv source tags format conversion table
115
 */
116
void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
117
                                                  const AVMetadataConv *s_conv);
118

    
119
/**
120
 * Frees all the memory allocated for an AVMetadata struct.
121
 */
122
void av_metadata_free(AVMetadata **m);
123

    
124

    
125
/* packet functions */
126

    
127

    
128
/**
129
 * Allocates and reads the payload of a packet and initializes its
130
 * fields with default values.
131
 *
132
 * @param pkt packet
133
 * @param size desired payload size
134
 * @return >0 (read size) if OK, AVERROR_xxx otherwise
135
 */
136
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
137

    
138

    
139
/*************************************************/
140
/* fractional numbers for exact pts handling */
141

    
142
/**
143
 * The exact value of the fractional number is: 'val + num / den'.
144
 * num is assumed to be 0 <= num < den.
145
 */
146
typedef struct AVFrac {
147
    int64_t val, num, den;
148
} AVFrac;
149

    
150
/*************************************************/
151
/* input/output formats */
152

    
153
struct AVCodecTag;
154

    
155
/** This structure contains the data a format has to probe a file. */
156
typedef struct AVProbeData {
157
    const char *filename;
158
    unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
159
    int buf_size;       /**< Size of buf except extra allocated bytes */
160
} AVProbeData;
161

    
162
#define AVPROBE_SCORE_MAX 100               ///< maximum score, half of that is used for file-extension-based detection
163
#define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
164

    
165
typedef struct AVFormatParameters {
166
    AVRational time_base;
167
    int sample_rate;
168
    int channels;
169
    int width;
170
    int height;
171
    enum PixelFormat pix_fmt;
172
    int channel; /**< Used to select DV channel. */
173
    const char *standard; /**< TV standard, NTSC, PAL, SECAM */
174
    unsigned int mpeg2ts_raw:1;  /**< Force raw MPEG-2 transport stream output, if possible. */
175
    unsigned int mpeg2ts_compute_pcr:1; /**< Compute exact PCR for each transport
176
                                            stream packet (only meaningful if
177
                                            mpeg2ts_raw is TRUE). */
178
    unsigned int initial_pause:1;       /**< Do not begin to play the stream
179
                                            immediately (RTSP only). */
180
    unsigned int prealloced_context:1;
181
#if LIBAVFORMAT_VERSION_INT < (53<<16)
182
    enum CodecID video_codec_id;
183
    enum CodecID audio_codec_id;
184
#endif
185
} AVFormatParameters;
186

    
187
//! Demuxer will use url_fopen, no opened file should be provided by the caller.
188
#define AVFMT_NOFILE        0x0001
189
#define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
190
#define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
191
#define AVFMT_RAWPICTURE    0x0020 /**< Format wants AVPicture structure for
192
                                      raw picture data. */
193
#define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
194
#define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
195
#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
196
#define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. */
197
#define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
198

    
199
typedef struct AVOutputFormat {
200
    const char *name;
201
    /**
202
     * Descriptive name for the format, meant to be more human-readable
203
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
204
     * to define it.
205
     */
206
    const char *long_name;
207
    const char *mime_type;
208
    const char *extensions; /**< comma-separated filename extensions */
209
    /** size of private data so that it can be allocated in the wrapper */
210
    int priv_data_size;
211
    /* output support */
212
    enum CodecID audio_codec; /**< default audio codec */
213
    enum CodecID video_codec; /**< default video codec */
214
    int (*write_header)(struct AVFormatContext *);
215
    int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
216
    int (*write_trailer)(struct AVFormatContext *);
217
    /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
218
    int flags;
219
    /** Currently only used to set pixel format if not YUV420P. */
220
    int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
221
    int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
222
                             AVPacket *in, int flush);
223

    
224
    /**
225
     * List of supported codec_id-codec_tag pairs, ordered by "better
226
     * choice first". The arrays are all terminated by CODEC_ID_NONE.
227
     */
228
    const struct AVCodecTag * const *codec_tag;
229

    
230
    enum CodecID subtitle_codec; /**< default subtitle codec */
231

    
232
    const AVMetadataConv *metadata_conv;
233

    
234
    /* private fields */
235
    struct AVOutputFormat *next;
236
} AVOutputFormat;
237

    
238
typedef struct AVInputFormat {
239
    const char *name;
240
    /**
241
     * Descriptive name for the format, meant to be more human-readable
242
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
243
     * to define it.
244
     */
245
    const char *long_name;
246
    /** Size of private data so that it can be allocated in the wrapper. */
247
    int priv_data_size;
248
    /**
249
     * Tell if a given file has a chance of being parsed as this format.
250
     * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
251
     * big so you do not have to check for that unless you need more.
252
     */
253
    int (*read_probe)(AVProbeData *);
254
    /** Read the format header and initialize the AVFormatContext
255
       structure. Return 0 if OK. 'ap' if non-NULL contains
256
       additional parameters. Only used in raw format right
257
       now. 'av_new_stream' should be called to create new streams.  */
258
    int (*read_header)(struct AVFormatContext *,
259
                       AVFormatParameters *ap);
260
    /** Read one packet and put it in 'pkt'. pts and flags are also
261
       set. 'av_new_stream' can be called only if the flag
262
       AVFMTCTX_NOHEADER is used.
263
       @return 0 on success, < 0 on error.
264
               When returning an error, pkt must not have been allocated
265
               or must be freed before returning */
266
    int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
267
    /** Close the stream. The AVFormatContext and AVStreams are not
268
       freed by this function */
269
    int (*read_close)(struct AVFormatContext *);
270

    
271
#if LIBAVFORMAT_VERSION_MAJOR < 53
272
    /**
273
     * Seek to a given timestamp relative to the frames in
274
     * stream component stream_index.
275
     * @param stream_index Must not be -1.
276
     * @param flags Selects which direction should be preferred if no exact
277
     *              match is available.
278
     * @return >= 0 on success (but not necessarily the new offset)
279
     */
280
    int (*read_seek)(struct AVFormatContext *,
281
                     int stream_index, int64_t timestamp, int flags);
282
#endif
283
    /**
284
     * Gets the next timestamp in stream[stream_index].time_base units.
285
     * @return the timestamp or AV_NOPTS_VALUE if an error occurred
286
     */
287
    int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
288
                              int64_t *pos, int64_t pos_limit);
289
    /** Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER. */
290
    int flags;
291
    /** If extensions are defined, then no probe is done. You should
292
       usually not use extension format guessing because it is not
293
       reliable enough */
294
    const char *extensions;
295
    /** General purpose read-only value that the format can use. */
296
    int value;
297

    
298
    /** Starts/resumes playing - only meaningful if using a network-based format
299
       (RTSP). */
300
    int (*read_play)(struct AVFormatContext *);
301

    
302
    /** Pauses playing - only meaningful if using a network-based format
303
       (RTSP). */
304
    int (*read_pause)(struct AVFormatContext *);
305

    
306
    const struct AVCodecTag * const *codec_tag;
307

    
308
    /**
309
     * Seeks to timestamp ts.
310
     * Seeking will be done so that the point from which all active streams
311
     * can be presented successfully will be closest to ts and within min/max_ts.
312
     * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
313
     */
314
    int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
315

    
316
    const AVMetadataConv *metadata_conv;
317

    
318
    /* private fields */
319
    struct AVInputFormat *next;
320
} AVInputFormat;
321

    
322
enum AVStreamParseType {
323
    AVSTREAM_PARSE_NONE,
324
    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
325
    AVSTREAM_PARSE_HEADERS,    /**< Only parse headers, do not repack. */
326
    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
327
};
328

    
329
typedef struct AVIndexEntry {
330
    int64_t pos;
331
    int64_t timestamp;
332
#define AVINDEX_KEYFRAME 0x0001
333
    int flags:2;
334
    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).
335
    int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
336
} AVIndexEntry;
337

    
338
#define AV_DISPOSITION_DEFAULT   0x0001
339
#define AV_DISPOSITION_DUB       0x0002
340
#define AV_DISPOSITION_ORIGINAL  0x0004
341
#define AV_DISPOSITION_COMMENT   0x0008
342
#define AV_DISPOSITION_LYRICS    0x0010
343
#define AV_DISPOSITION_KARAOKE   0x0020
344

    
345
/**
346
 * Stream structure.
347
 * New fields can be added to the end with minor version bumps.
348
 * Removal, reordering and changes to existing fields require a major
349
 * version bump.
350
 * sizeof(AVStream) must not be used outside libav*.
351
 */
352
typedef struct AVStream {
353
    int index;    /**< stream index in AVFormatContext */
354
    int id;       /**< format-specific stream ID */
355
    AVCodecContext *codec; /**< codec context */
356
    /**
357
     * Real base framerate of the stream.
358
     * This is the lowest framerate with which all timestamps can be
359
     * represented accurately (it is the least common multiple of all
360
     * framerates in the stream). Note, this value is just a guess!
361
     * For example, if the time base is 1/90000 and all frames have either
362
     * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
363
     */
364
    AVRational r_frame_rate;
365
    void *priv_data;
366

    
367
    /* internal data used in av_find_stream_info() */
368
    int64_t first_dts;
369
    /** encoding: pts generation when outputting stream */
370
    struct AVFrac pts;
371

    
372
    /**
373
     * This is the fundamental unit of time (in seconds) in terms
374
     * of which frame timestamps are represented. For fixed-fps content,
375
     * time base should be 1/framerate and timestamp increments should be 1.
376
     */
377
    AVRational time_base;
378
    int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
379
    /* ffmpeg.c private use */
380
    int stream_copy; /**< If set, just copy stream. */
381
    enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
382
    //FIXME move stuff to a flags field?
383
    /** Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
384
     * MN: dunno if that is the right place for it */
385
    float quality;
386
    /**
387
     * Decoding: pts of the first frame of the stream, in stream time base.
388
     * Only set this if you are absolutely 100% sure that the value you set
389
     * it to really is the pts of the first frame.
390
     * This may be undefined (AV_NOPTS_VALUE).
391
     * @note The ASF header does NOT contain a correct start_time the ASF
392
     * demuxer must NOT set this.
393
     */
394
    int64_t start_time;
395
    /**
396
     * Decoding: duration of the stream, in stream time base.
397
     * If a source file does not specify a duration, but does specify
398
     * a bitrate, this value will be estimated from bitrate and file size.
399
     */
400
    int64_t duration;
401

    
402
#if LIBAVFORMAT_VERSION_INT < (53<<16)
403
    char language[4]; /** ISO 639-2/B 3-letter language code (empty string if undefined) */
404
#endif
405

    
406
    /* av_read_frame() support */
407
    enum AVStreamParseType need_parsing;
408
    struct AVCodecParserContext *parser;
409

    
410
    int64_t cur_dts;
411
    int last_IP_duration;
412
    int64_t last_IP_pts;
413
    /* av_seek_frame() support */
414
    AVIndexEntry *index_entries; /**< Only used if the format does not
415
                                    support seeking natively. */
416
    int nb_index_entries;
417
    unsigned int index_entries_allocated_size;
418

    
419
    int64_t nb_frames;                 ///< number of frames in this stream if known or 0
420

    
421
#if LIBAVFORMAT_VERSION_INT < (53<<16)
422
    int64_t unused[4+1];
423

    
424
    char *filename; /**< source filename of the stream */
425
#endif
426

    
427
    int disposition; /**< AV_DISPOSITION_* bit field */
428

    
429
    AVProbeData probe_data;
430
#define MAX_REORDER_DELAY 16
431
    int64_t pts_buffer[MAX_REORDER_DELAY+1];
432

    
433
    /**
434
     * sample aspect ratio (0 if unknown)
435
     * - encoding: Set by user.
436
     * - decoding: Set by libavformat.
437
     */
438
    AVRational sample_aspect_ratio;
439

    
440
    AVMetadata *metadata;
441

    
442
    /* av_read_frame() support */
443
    const uint8_t *cur_ptr;
444
    int cur_len;
445
    AVPacket cur_pkt;
446

    
447
    // Timestamp generation support:
448
    /**
449
     * Timestamp corresponding to the last dts sync point.
450
     *
451
     * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
452
     * a DTS is received from the underlying container. Otherwise set to
453
     * AV_NOPTS_VALUE by default.
454
     */
455
    int64_t reference_dts;
456

    
457
    /**
458
     * Number of packets to buffer for codec probing
459
     * NOT PART OF PUBLIC API
460
     */
461
#define MAX_PROBE_PACKETS 2500
462
    int probe_packets;
463

    
464
    /**
465
     * last packet in packet_buffer for this stream when muxing.
466
     * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav*
467
     */
468
    struct AVPacketList *last_in_packet_buffer;
469
} AVStream;
470

    
471
#define AV_PROGRAM_RUNNING 1
472

    
473
/**
474
 * New fields can be added to the end with minor version bumps.
475
 * Removal, reordering and changes to existing fields require a major
476
 * version bump.
477
 * sizeof(AVProgram) must not be used outside libav*.
478
 */
479
typedef struct AVProgram {
480
    int            id;
481
#if LIBAVFORMAT_VERSION_INT < (53<<16)
482
    char           *provider_name; ///< network name for DVB streams
483
    char           *name;          ///< service name for DVB streams
484
#endif
485
    int            flags;
486
    enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
487
    unsigned int   *stream_index;
488
    unsigned int   nb_stream_indexes;
489
    AVMetadata *metadata;
490
} AVProgram;
491

    
492
#define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
493
                                         (streams are added dynamically) */
494

    
495
typedef struct AVChapter {
496
    int id;                 ///< unique ID to identify the chapter
497
    AVRational time_base;   ///< time base in which the start/end timestamps are specified
498
    int64_t start, end;     ///< chapter start/end time in time_base units
499
#if LIBAVFORMAT_VERSION_INT < (53<<16)
500
    char *title;            ///< chapter title
501
#endif
502
    AVMetadata *metadata;
503
} AVChapter;
504

    
505
#define MAX_STREAMS 20
506

    
507
/**
508
 * Format I/O context.
509
 * New fields can be added to the end with minor version bumps.
510
 * Removal, reordering and changes to existing fields require a major
511
 * version bump.
512
 * sizeof(AVFormatContext) must not be used outside libav*.
513
 */
514
typedef struct AVFormatContext {
515
    const AVClass *av_class; /**< Set by avformat_alloc_context. */
516
    /* Can only be iformat or oformat, not both at the same time. */
517
    struct AVInputFormat *iformat;
518
    struct AVOutputFormat *oformat;
519
    void *priv_data;
520
    ByteIOContext *pb;
521
    unsigned int nb_streams;
522
    AVStream *streams[MAX_STREAMS];
523
    char filename[1024]; /**< input or output filename */
524
    /* stream info */
525
    int64_t timestamp;
526
#if LIBAVFORMAT_VERSION_INT < (53<<16)
527
    char title[512];
528
    char author[512];
529
    char copyright[512];
530
    char comment[512];
531
    char album[512];
532
    int year;  /**< ID3 year, 0 if none */
533
    int track; /**< track number, 0 if none */
534
    char genre[32]; /**< ID3 genre */
535
#endif
536

    
537
    int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
538
    /* private data for pts handling (do not modify directly). */
539
    /** This buffer is only needed when packets were already buffered but
540
       not decoded, for example to get the codec parameters in MPEG
541
       streams. */
542
    struct AVPacketList *packet_buffer;
543

    
544
    /** Decoding: position of the first frame of the component, in
545
       AV_TIME_BASE fractional seconds. NEVER set this value directly:
546
       It is deduced from the AVStream values.  */
547
    int64_t start_time;
548
    /** Decoding: duration of the stream, in AV_TIME_BASE fractional
549
       seconds. NEVER set this value directly: it is deduced from the
550
       AVStream values.  */
551
    int64_t duration;
552
    /** decoding: total file size, 0 if unknown */
553
    int64_t file_size;
554
    /** Decoding: total stream bitrate in bit/s, 0 if not
555
       available. Never set it directly if the file_size and the
556
       duration are known as FFmpeg can compute it automatically. */
557
    int bit_rate;
558

    
559
    /* av_read_frame() support */
560
    AVStream *cur_st;
561
#if LIBAVFORMAT_VERSION_INT < (53<<16)
562
    const uint8_t *cur_ptr_deprecated;
563
    int cur_len_deprecated;
564
    AVPacket cur_pkt_deprecated;
565
#endif
566

    
567
    /* av_seek_frame() support */
568
    int64_t data_offset; /** offset of the first packet */
569
    int index_built;
570

    
571
    int mux_rate;
572
    unsigned int packet_size;
573
    int preload;
574
    int max_delay;
575

    
576
#define AVFMT_NOOUTPUTLOOP -1
577
#define AVFMT_INFINITEOUTPUTLOOP 0
578
    /** number of times to loop output in formats that support it */
579
    int loop_output;
580

    
581
    int flags;
582
#define AVFMT_FLAG_GENPTS       0x0001 ///< Generate missing pts even if it requires parsing future frames.
583
#define AVFMT_FLAG_IGNIDX       0x0002 ///< Ignore index.
584
#define AVFMT_FLAG_NONBLOCK     0x0004 ///< Do not block when reading packets from input.
585

    
586
    int loop_input;
587
    /** decoding: size of data to probe; encoding: unused. */
588
    unsigned int probesize;
589

    
590
    /**
591
     * Maximum time (in AV_TIME_BASE units) during which the input should
592
     * be analyzed in av_find_stream_info().
593
     */
594
    int max_analyze_duration;
595

    
596
    const uint8_t *key;
597
    int keylen;
598

    
599
    unsigned int nb_programs;
600
    AVProgram **programs;
601

    
602
    /**
603
     * Forced video codec_id.
604
     * Demuxing: Set by user.
605
     */
606
    enum CodecID video_codec_id;
607
    /**
608
     * Forced audio codec_id.
609
     * Demuxing: Set by user.
610
     */
611
    enum CodecID audio_codec_id;
612
    /**
613
     * Forced subtitle codec_id.
614
     * Demuxing: Set by user.
615
     */
616
    enum CodecID subtitle_codec_id;
617

    
618
    /**
619
     * Maximum amount of memory in bytes to use for the index of each stream.
620
     * If the index exceeds this size, entries will be discarded as
621
     * needed to maintain a smaller size. This can lead to slower or less
622
     * accurate seeking (depends on demuxer).
623
     * Demuxers for which a full in-memory index is mandatory will ignore
624
     * this.
625
     * muxing  : unused
626
     * demuxing: set by user
627
     */
628
    unsigned int max_index_size;
629

    
630
    /**
631
     * Maximum amount of memory in bytes to use for buffering frames
632
     * obtained from realtime capture devices.
633
     */
634
    unsigned int max_picture_buffer;
635

    
636
    unsigned int nb_chapters;
637
    AVChapter **chapters;
638

    
639
    /**
640
     * Flags to enable debugging.
641
     */
642
    int debug;
643
#define FF_FDEBUG_TS        0x0001
644

    
645
    /**
646
     * Raw packets from the demuxer, prior to parsing and decoding.
647
     * This buffer is used for buffering packets until the codec can
648
     * be identified, as parsing cannot be done without knowing the
649
     * codec.
650
     */
651
    struct AVPacketList *raw_packet_buffer;
652
    struct AVPacketList *raw_packet_buffer_end;
653

    
654
    struct AVPacketList *packet_buffer_end;
655

    
656
    AVMetadata *metadata;
657

    
658
    /**
659
     * Remaining size available for raw_packet_buffer, in bytes.
660
     * NOT PART OF PUBLIC API
661
     */
662
#define RAW_PACKET_BUFFER_SIZE 2500000
663
    int raw_packet_buffer_remaining_size;
664
} AVFormatContext;
665

    
666
typedef struct AVPacketList {
667
    AVPacket pkt;
668
    struct AVPacketList *next;
669
} AVPacketList;
670

    
671
#if LIBAVFORMAT_VERSION_INT < (53<<16)
672
extern AVInputFormat *first_iformat;
673
extern AVOutputFormat *first_oformat;
674
#endif
675

    
676
/**
677
 * If f is NULL, returns the first registered input format,
678
 * if f is non-NULL, returns the next registered input format after f
679
 * or NULL if f is the last one.
680
 */
681
AVInputFormat  *av_iformat_next(AVInputFormat  *f);
682

    
683
/**
684
 * If f is NULL, returns the first registered output format,
685
 * if f is non-NULL, returns the next registered output format after f
686
 * or NULL if f is the last one.
687
 */
688
AVOutputFormat *av_oformat_next(AVOutputFormat *f);
689

    
690
enum CodecID av_guess_image2_codec(const char *filename);
691

    
692
/* XXX: Use automatic init with either ELF sections or C file parser */
693
/* modules. */
694

    
695
/* utils.c */
696
void av_register_input_format(AVInputFormat *format);
697
void av_register_output_format(AVOutputFormat *format);
698
AVOutputFormat *guess_stream_format(const char *short_name,
699
                                    const char *filename,
700
                                    const char *mime_type);
701
AVOutputFormat *guess_format(const char *short_name,
702
                             const char *filename,
703
                             const char *mime_type);
704

    
705
/**
706
 * Guesses the codec ID based upon muxer and filename.
707
 */
708
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
709
                            const char *filename, const char *mime_type,
710
                            enum CodecType type);
711

    
712
/**
713
 * Sends a nice hexadecimal dump of a buffer to the specified file stream.
714
 *
715
 * @param f The file stream pointer where the dump should be sent to.
716
 * @param buf buffer
717
 * @param size buffer size
718
 *
719
 * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
720
 */
721
void av_hex_dump(FILE *f, uint8_t *buf, int size);
722

    
723
/**
724
 * Sends a nice hexadecimal dump of a buffer to the log.
725
 *
726
 * @param avcl A pointer to an arbitrary struct of which the first field is a
727
 * pointer to an AVClass struct.
728
 * @param level The importance level of the message, lower values signifying
729
 * higher importance.
730
 * @param buf buffer
731
 * @param size buffer size
732
 *
733
 * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
734
 */
735
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
736

    
737
/**
738
 * Sends a nice dump of a packet to the specified file stream.
739
 *
740
 * @param f The file stream pointer where the dump should be sent to.
741
 * @param pkt packet to dump
742
 * @param dump_payload True if the payload must be displayed, too.
743
 */
744
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
745

    
746
/**
747
 * Sends a nice dump of a packet to the log.
748
 *
749
 * @param avcl A pointer to an arbitrary struct of which the first field is a
750
 * pointer to an AVClass struct.
751
 * @param level The importance level of the message, lower values signifying
752
 * higher importance.
753
 * @param pkt packet to dump
754
 * @param dump_payload True if the payload must be displayed, too.
755
 */
756
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
757

    
758
/**
759
 * Initializes libavformat and registers all the muxers, demuxers and
760
 * protocols. If you do not call this function, then you can select
761
 * exactly which formats you want to support.
762
 *
763
 * @see av_register_input_format()
764
 * @see av_register_output_format()
765
 * @see av_register_protocol()
766
 */
767
void av_register_all(void);
768

    
769
/** codec tag <-> codec id */
770
enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
771
unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
772

    
773
/* media file input */
774

    
775
/**
776
 * Finds AVInputFormat based on the short name of the input format.
777
 */
778
AVInputFormat *av_find_input_format(const char *short_name);
779

    
780
/**
781
 * Guesses the file format.
782
 *
783
 * @param is_opened Whether the file is already opened; determines whether
784
 *                  demuxers with or without AVFMT_NOFILE are probed.
785
 */
786
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
787

    
788
/**
789
 * Allocates all the structures needed to read an input stream.
790
 *        This does not open the needed codecs for decoding the stream[s].
791
 */
792
int av_open_input_stream(AVFormatContext **ic_ptr,
793
                         ByteIOContext *pb, const char *filename,
794
                         AVInputFormat *fmt, AVFormatParameters *ap);
795

    
796
/**
797
 * Opens a media file as input. The codecs are not opened. Only the file
798
 * header (if present) is read.
799
 *
800
 * @param ic_ptr The opened media file handle is put here.
801
 * @param filename filename to open
802
 * @param fmt If non-NULL, force the file format to use.
803
 * @param buf_size optional buffer size (zero if default is OK)
804
 * @param ap Additional parameters needed when opening the file
805
 *           (NULL if default).
806
 * @return 0 if OK, AVERROR_xxx otherwise
807
 */
808
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
809
                       AVInputFormat *fmt,
810
                       int buf_size,
811
                       AVFormatParameters *ap);
812

    
813
#if LIBAVFORMAT_VERSION_MAJOR < 53
814
/**
815
 * @deprecated Use avformat_alloc_context() instead.
816
 */
817
attribute_deprecated AVFormatContext *av_alloc_format_context(void);
818
#endif
819

    
820
/**
821
 * Allocates an AVFormatContext.
822
 * Can be freed with av_free() but do not forget to free everything you
823
 * explicitly allocated as well!
824
 */
825
AVFormatContext *avformat_alloc_context(void);
826

    
827
/**
828
 * Reads packets of a media file to get stream information. This
829
 * is useful for file formats with no headers such as MPEG. This
830
 * function also computes the real framerate in case of MPEG-2 repeat
831
 * frame mode.
832
 * The logical file position is not changed by this function;
833
 * examined packets may be buffered for later processing.
834
 *
835
 * @param ic media file handle
836
 * @return >=0 if OK, AVERROR_xxx on error
837
 * @todo Let the user decide somehow what information is needed so that
838
 *       we do not waste time getting stuff the user does not need.
839
 */
840
int av_find_stream_info(AVFormatContext *ic);
841

    
842
/**
843
 * Reads a transport packet from a media file.
844
 *
845
 * This function is obsolete and should never be used.
846
 * Use av_read_frame() instead.
847
 *
848
 * @param s media file handle
849
 * @param pkt is filled
850
 * @return 0 if OK, AVERROR_xxx on error
851
 */
852
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
853

    
854
/**
855
 * Returns the next frame of a stream.
856
 *
857
 * The returned packet is valid
858
 * until the next av_read_frame() or until av_close_input_file() and
859
 * must be freed with av_free_packet. For video, the packet contains
860
 * exactly one frame. For audio, it contains an integer number of
861
 * frames if each frame has a known fixed size (e.g. PCM or ADPCM
862
 * data). If the audio frames have a variable size (e.g. MPEG audio),
863
 * then it contains one frame.
864
 *
865
 * pkt->pts, pkt->dts and pkt->duration are always set to correct
866
 * values in AVStream.time_base units (and guessed if the format cannot
867
 * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
868
 * has B-frames, so it is better to rely on pkt->dts if you do not
869
 * decompress the payload.
870
 *
871
 * @return 0 if OK, < 0 on error or end of file
872
 */
873
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
874

    
875
/**
876
 * Seeks to the keyframe at timestamp.
877
 * 'timestamp' in 'stream_index'.
878
 * @param stream_index If stream_index is (-1), a default
879
 * stream is selected, and timestamp is automatically converted
880
 * from AV_TIME_BASE units to the stream specific time_base.
881
 * @param timestamp Timestamp in AVStream.time_base units
882
 *        or, if no stream is specified, in AV_TIME_BASE units.
883
 * @param flags flags which select direction and seeking mode
884
 * @return >= 0 on success
885
 */
886
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
887
                  int flags);
888

    
889
/**
890
 * Seeks to timestamp ts.
891
 * Seeking will be done so that the point from which all active streams
892
 * can be presented successfully will be closest to ts and within min/max_ts.
893
 * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
894
 *
895
 * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
896
 * are the file position (this may not be supported by all demuxers).
897
 * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
898
 * in the stream with stream_index (this may not be supported by all demuxers).
899
 * Otherwise all timestamps are in units of the stream selected by stream_index
900
 * or if stream_index is -1, in AV_TIME_BASE units.
901
 * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
902
 * keyframes (this may not be supported by all demuxers).
903
 *
904
 * @param stream_index index of the stream which is used as time base reference
905
 * @param min_ts smallest acceptable timestamp
906
 * @param ts target timestamp
907
 * @param max_ts largest acceptable timestamp
908
 * @param flags flags
909
 * @returns >=0 on success, error code otherwise
910
 *
911
 * @NOTE This is part of the new seek API which is still under construction.
912
 *       Thus do not use this yet. It may change at any time, do not expect
913
 *       ABI compatibility yet!
914
 */
915
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
916

    
917
/**
918
 * Starts playing a network-based stream (e.g. RTSP stream) at the
919
 * current position.
920
 */
921
int av_read_play(AVFormatContext *s);
922

    
923
/**
924
 * Pauses a network-based stream (e.g. RTSP stream).
925
 *
926
 * Use av_read_play() to resume it.
927
 */
928
int av_read_pause(AVFormatContext *s);
929

    
930
/**
931
 * Frees a AVFormatContext allocated by av_open_input_stream.
932
 * @param s context to free
933
 */
934
void av_close_input_stream(AVFormatContext *s);
935

    
936
/**
937
 * Closes a media file (but not its codecs).
938
 *
939
 * @param s media file handle
940
 */
941
void av_close_input_file(AVFormatContext *s);
942

    
943
/**
944
 * Adds a new stream to a media file.
945
 *
946
 * Can only be called in the read_header() function. If the flag
947
 * AVFMTCTX_NOHEADER is in the format context, then new streams
948
 * can be added in read_packet too.
949
 *
950
 * @param s media file handle
951
 * @param id file-format-dependent stream ID
952
 */
953
AVStream *av_new_stream(AVFormatContext *s, int id);
954
AVProgram *av_new_program(AVFormatContext *s, int id);
955

    
956
/**
957
 * Adds a new chapter.
958
 * This function is NOT part of the public API
959
 * and should ONLY be used by demuxers.
960
 *
961
 * @param s media file handle
962
 * @param id unique ID for this chapter
963
 * @param start chapter start time in time_base units
964
 * @param end chapter end time in time_base units
965
 * @param title chapter title
966
 *
967
 * @return AVChapter or NULL on error
968
 */
969
AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
970
                          int64_t start, int64_t end, const char *title);
971

    
972
/**
973
 * Sets the pts for a given stream.
974
 *
975
 * @param s stream
976
 * @param pts_wrap_bits number of bits effectively used by the pts
977
 *        (used for wrap control, 33 is the value for MPEG)
978
 * @param pts_num numerator to convert to seconds (MPEG: 1)
979
 * @param pts_den denominator to convert to seconds (MPEG: 90000)
980
 */
981
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
982
                     unsigned int pts_num, unsigned int pts_den);
983

    
984
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
985
#define AVSEEK_FLAG_BYTE     2 ///< seeking based on position in bytes
986
#define AVSEEK_FLAG_ANY      4 ///< seek to any frame, even non-keyframes
987
#define AVSEEK_FLAG_FRAME    8 ///< seeking based on frame number
988

    
989
int av_find_default_stream_index(AVFormatContext *s);
990

    
991
/**
992
 * Gets the index for a specific timestamp.
993
 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
994
 *                 to the timestamp which is <= the requested one, if backward
995
 *                 is 0, then it will be >=
996
 *              if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
997
 * @return < 0 if no such timestamp could be found
998
 */
999
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1000

    
1001
/**
1002
 * Ensures the index uses less memory than the maximum specified in
1003
 * AVFormatContext.max_index_size by discarding entries if it grows
1004
 * too large.
1005
 * This function is not part of the public API and should only be called
1006
 * by demuxers.
1007
 */
1008
void ff_reduce_index(AVFormatContext *s, int stream_index);
1009

    
1010
/**
1011
 * Adds an index entry into a sorted list. Updates the entry if the list
1012
 * already contains it.
1013
 *
1014
 * @param timestamp timestamp in the time base of the given stream
1015
 */
1016
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1017
                       int size, int distance, int flags);
1018

    
1019
/**
1020
 * Does a binary search using av_index_search_timestamp() and
1021
 * AVCodec.read_timestamp().
1022
 * This is not supposed to be called directly by a user application,
1023
 * but by demuxers.
1024
 * @param target_ts target timestamp in the time base of the given stream
1025
 * @param stream_index stream number
1026
 */
1027
int av_seek_frame_binary(AVFormatContext *s, int stream_index,
1028
                         int64_t target_ts, int flags);
1029

    
1030
/**
1031
 * Updates cur_dts of all streams based on the given timestamp and AVStream.
1032
 *
1033
 * Stream ref_st unchanged, others set cur_dts in their native time base.
1034
 * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
1035
 * @param timestamp new dts expressed in time_base of param ref_st
1036
 * @param ref_st reference stream giving time_base of param timestamp
1037
 */
1038
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
1039

    
1040
/**
1041
 * Does a binary search using read_timestamp().
1042
 * This is not supposed to be called directly by a user application,
1043
 * but by demuxers.
1044
 * @param target_ts target timestamp in the time base of the given stream
1045
 * @param stream_index stream number
1046
 */
1047
int64_t av_gen_search(AVFormatContext *s, int stream_index,
1048
                      int64_t target_ts, int64_t pos_min,
1049
                      int64_t pos_max, int64_t pos_limit,
1050
                      int64_t ts_min, int64_t ts_max,
1051
                      int flags, int64_t *ts_ret,
1052
                      int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
1053

    
1054
/** media file output */
1055
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1056

    
1057
/**
1058
 * Allocates the stream private data and writes the stream header to an
1059
 * output media file.
1060
 *
1061
 * @param s media file handle
1062
 * @return 0 if OK, AVERROR_xxx on error
1063
 */
1064
int av_write_header(AVFormatContext *s);
1065

    
1066
/**
1067
 * Writes a packet to an output media file.
1068
 *
1069
 * The packet shall contain one audio or video frame.
1070
 * The packet must be correctly interleaved according to the container
1071
 * specification, if not then av_interleaved_write_frame must be used.
1072
 *
1073
 * @param s media file handle
1074
 * @param pkt The packet, which contains the stream_index, buf/buf_size,
1075
              dts/pts, ...
1076
 * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
1077
 */
1078
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
1079

    
1080
/**
1081
 * Writes a packet to an output media file ensuring correct interleaving.
1082
 *
1083
 * The packet must contain one audio or video frame.
1084
 * If the packets are already correctly interleaved, the application should
1085
 * call av_write_frame() instead as it is slightly faster. It is also important
1086
 * to keep in mind that completely non-interleaved input will need huge amounts
1087
 * of memory to interleave with this, so it is preferable to interleave at the
1088
 * demuxer level.
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_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
1096

    
1097
/**
1098
 * Interleaves a packet per dts in an output media file.
1099
 *
1100
 * Packets with pkt->destruct == av_destruct_packet will be freed inside this
1101
 * function, so they cannot be used after it. Note that calling av_free_packet()
1102
 * on them is still safe.
1103
 *
1104
 * @param s media file handle
1105
 * @param out the interleaved packet will be output here
1106
 * @param in the input packet
1107
 * @param flush 1 if no further packets are available as input and all
1108
 *              remaining packets should be output
1109
 * @return 1 if a packet was output, 0 if no packet could be output,
1110
 *         < 0 if an error occurred
1111
 */
1112
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
1113
                                 AVPacket *pkt, int flush);
1114

    
1115
/**
1116
 * Writes the stream trailer to an output media file and frees the
1117
 * file private data.
1118
 *
1119
 * May only be called after a successful call to av_write_header.
1120
 *
1121
 * @param s media file handle
1122
 * @return 0 if OK, AVERROR_xxx on error
1123
 */
1124
int av_write_trailer(AVFormatContext *s);
1125

    
1126
void dump_format(AVFormatContext *ic,
1127
                 int index,
1128
                 const char *url,
1129
                 int is_output);
1130

    
1131
#if LIBAVFORMAT_VERSION_MAJOR < 53
1132
/**
1133
 * Parses width and height out of string str.
1134
 * @deprecated Use av_parse_video_frame_size instead.
1135
 */
1136
attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
1137
                                          const char *str);
1138

    
1139
/**
1140
 * Converts framerate from a string to a fraction.
1141
 * @deprecated Use av_parse_video_frame_rate instead.
1142
 */
1143
attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
1144
                                          const char *arg);
1145
#endif
1146

    
1147
/**
1148
 * Parses datestr and returns a corresponding number of microseconds.
1149
 * @param datestr String representing a date or a duration.
1150
 * - If a date the syntax is:
1151
 * @code
1152
 *  [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
1153
 * @endcode
1154
 * Time is local time unless Z is appended, in which case it is
1155
 * interpreted as UTC.
1156
 * If the year-month-day part is not specified it takes the current
1157
 * year-month-day.
1158
 * Returns the number of microseconds since 1st of January, 1970 up to
1159
 * the time of the parsed date or INT64_MIN if datestr cannot be
1160
 * successfully parsed.
1161
 * - If a duration the syntax is:
1162
 * @code
1163
 *  [-]HH[:MM[:SS[.m...]]]
1164
 *  [-]S+[.m...]
1165
 * @endcode
1166
 * Returns the number of microseconds contained in a time interval
1167
 * with the specified duration or INT64_MIN if datestr cannot be
1168
 * successfully parsed.
1169
 * @param duration Flag which tells how to interpret datestr, if
1170
 * not zero datestr is interpreted as a duration, otherwise as a
1171
 * date.
1172
 */
1173
int64_t parse_date(const char *datestr, int duration);
1174

    
1175
/** Gets the current time in microseconds. */
1176
int64_t av_gettime(void);
1177

    
1178
/* ffm-specific for ffserver */
1179
#define FFM_PACKET_SIZE 4096
1180
int64_t ffm_read_write_index(int fd);
1181
int ffm_write_write_index(int fd, int64_t pos);
1182
void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
1183

    
1184
/**
1185
 * Attempts to find a specific tag in a URL.
1186
 *
1187
 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
1188
 * Return 1 if found.
1189
 */
1190
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1191

    
1192
/**
1193
 * Returns in 'buf' the path with '%d' replaced by a number.
1194
 *
1195
 * Also handles the '%0nd' format where 'n' is the total number
1196
 * of digits and '%%'.
1197
 *
1198
 * @param buf destination buffer
1199
 * @param buf_size destination buffer size
1200
 * @param path numbered sequence string
1201
 * @param number frame number
1202
 * @return 0 if OK, -1 on format error
1203
 */
1204
int av_get_frame_filename(char *buf, int buf_size,
1205
                          const char *path, int number);
1206

    
1207
/**
1208
 * Checks whether filename actually is a numbered sequence generator.
1209
 *
1210
 * @param filename possible numbered sequence string
1211
 * @return 1 if a valid numbered sequence string, 0 otherwise
1212
 */
1213
int av_filename_number_test(const char *filename);
1214

    
1215
/**
1216
 * Generates an SDP for an RTP session.
1217
 *
1218
 * @param ac array of AVFormatContexts describing the RTP streams. If the
1219
 *           array is composed by only one context, such context can contain
1220
 *           multiple AVStreams (one AVStream per RTP stream). Otherwise,
1221
 *           all the contexts in the array (an AVCodecContext per RTP stream)
1222
 *           must contain only one AVStream.
1223
 * @param n_files number of AVCodecContexts contained in ac
1224
 * @param buff buffer where the SDP will be stored (must be allocated by
1225
 *             the caller)
1226
 * @param size the size of the buffer
1227
 * @return 0 if OK, AVERROR_xxx on error
1228
 */
1229
int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1230

    
1231
#ifdef HAVE_AV_CONFIG_H
1232

    
1233
void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
1234

    
1235
#ifdef __GNUC__
1236
#define dynarray_add(tab, nb_ptr, elem)\
1237
do {\
1238
    __typeof__(tab) _tab = (tab);\
1239
    __typeof__(elem) _elem = (elem);\
1240
    (void)sizeof(**_tab == _elem); /* check that types are compatible */\
1241
    ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
1242
} while(0)
1243
#else
1244
#define dynarray_add(tab, nb_ptr, elem)\
1245
do {\
1246
    ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
1247
} while(0)
1248
#endif
1249

    
1250
time_t mktimegm(struct tm *tm);
1251
struct tm *brktimegm(time_t secs, struct tm *tm);
1252
const char *small_strptime(const char *p, const char *fmt,
1253
                           struct tm *dt);
1254

    
1255
struct in_addr;
1256
int resolve_host(struct in_addr *sin_addr, const char *hostname);
1257

    
1258
void url_split(char *proto, int proto_size,
1259
               char *authorization, int authorization_size,
1260
               char *hostname, int hostname_size,
1261
               int *port_ptr,
1262
               char *path, int path_size,
1263
               const char *url);
1264

    
1265
/**
1266
 * Returns a positive value if the given filename has one of the given
1267
 * extensions, 0 otherwise.
1268
 *
1269
 * @param extensions a comma-separated list of filename extensions
1270
 */
1271
int match_ext(const char *filename, const char *extensions);
1272

    
1273
#endif /* HAVE_AV_CONFIG_H */
1274

    
1275
#endif /* AVFORMAT_AVFORMAT_H */