You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1293 lines
45KB

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