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.

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