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.

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