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.

2017 lines
70KB

  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. /**
  23. * @file
  24. * @ingroup libavf
  25. * Main libavformat public API header
  26. */
  27. /**
  28. * @defgroup libavf I/O and Muxing/Demuxing Library
  29. * @{
  30. *
  31. * @defgroup lavf_decoding Demuxing
  32. * @{
  33. * @}
  34. *
  35. * @defgroup lavf_encoding Muxing
  36. * @{
  37. * @}
  38. *
  39. * @defgroup lavf_io I/O Read/Write
  40. * @{
  41. * @}
  42. *
  43. * @defgroup lavf_codec Demuxers
  44. * @{
  45. * @defgroup lavf_codec_native Native Demuxers
  46. * @{
  47. * @}
  48. * @defgroup lavf_codec_wrappers External library wrappers
  49. * @{
  50. * @}
  51. * @}
  52. * @defgroup lavf_protos I/O Protocols
  53. * @{
  54. * @}
  55. * @defgroup lavf_internal Internal
  56. * @{
  57. * @}
  58. * @}
  59. *
  60. */
  61. /**
  62. * Return the LIBAVFORMAT_VERSION_INT constant.
  63. */
  64. unsigned avformat_version(void);
  65. /**
  66. * Return the libavformat build-time configuration.
  67. */
  68. const char *avformat_configuration(void);
  69. /**
  70. * Return the libavformat license.
  71. */
  72. const char *avformat_license(void);
  73. #include <time.h>
  74. #include <stdio.h> /* FILE */
  75. #include "libavcodec/avcodec.h"
  76. #include "libavutil/dict.h"
  77. #include "libavutil/log.h"
  78. #include "avio.h"
  79. #include "libavformat/version.h"
  80. struct AVFormatContext;
  81. /**
  82. * @defgroup metadata_api Public Metadata API
  83. * @{
  84. * @ingroup libavf
  85. * The metadata API allows libavformat to export metadata tags to a client
  86. * application when demuxing. Conversely it allows a client application to
  87. * set metadata when muxing.
  88. *
  89. * Metadata is exported or set as pairs of key/value strings in the 'metadata'
  90. * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
  91. * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
  92. * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
  93. * exported by demuxers isn't checked to be valid UTF-8 in most cases.
  94. *
  95. * Important concepts to keep in mind:
  96. * - Keys are unique; there can never be 2 tags with the same key. This is
  97. * also meant semantically, i.e., a demuxer should not knowingly produce
  98. * several keys that are literally different but semantically identical.
  99. * E.g., key=Author5, key=Author6. In this example, all authors must be
  100. * placed in the same tag.
  101. * - Metadata is flat, not hierarchical; there are no subtags. If you
  102. * want to store, e.g., the email address of the child of producer Alice
  103. * and actor Bob, that could have key=alice_and_bobs_childs_email_address.
  104. * - Several modifiers can be applied to the tag name. This is done by
  105. * appending a dash character ('-') and the modifier name in the order
  106. * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
  107. * - language -- a tag whose value is localized for a particular language
  108. * is appended with the ISO 639-2/B 3-letter language code.
  109. * For example: Author-ger=Michael, Author-eng=Mike
  110. * The original/default language is in the unqualified "Author" tag.
  111. * A demuxer should set a default if it sets any translated tag.
  112. * - sorting -- a modified version of a tag that should be used for
  113. * sorting will have '-sort' appended. E.g. artist="The Beatles",
  114. * artist-sort="Beatles, The".
  115. *
  116. * - Demuxers attempt to export metadata in a generic format, however tags
  117. * with no generic equivalents are left as they are stored in the container.
  118. * Follows a list of generic tag names:
  119. *
  120. @verbatim
  121. album -- name of the set this work belongs to
  122. album_artist -- main creator of the set/album, if different from artist.
  123. e.g. "Various Artists" for compilation albums.
  124. artist -- main creator of the work
  125. comment -- any additional description of the file.
  126. composer -- who composed the work, if different from artist.
  127. copyright -- name of copyright holder.
  128. creation_time-- date when the file was created, preferably in ISO 8601.
  129. date -- date when the work was created, preferably in ISO 8601.
  130. disc -- number of a subset, e.g. disc in a multi-disc collection.
  131. encoder -- name/settings of the software/hardware that produced the file.
  132. encoded_by -- person/group who created the file.
  133. filename -- original name of the file.
  134. genre -- <self-evident>.
  135. language -- main language in which the work is performed, preferably
  136. in ISO 639-2 format. Multiple languages can be specified by
  137. separating them with commas.
  138. performer -- artist who performed the work, if different from artist.
  139. E.g for "Also sprach Zarathustra", artist would be "Richard
  140. Strauss" and performer "London Philharmonic Orchestra".
  141. publisher -- name of the label/publisher.
  142. service_name -- name of the service in broadcasting (channel name).
  143. service_provider -- name of the service provider in broadcasting.
  144. title -- name of the work.
  145. track -- number of this work in the set, can be in form current/total.
  146. variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
  147. @endverbatim
  148. *
  149. * Look in the examples section for an application example how to use the Metadata API.
  150. *
  151. * @}
  152. */
  153. #if FF_API_OLD_METADATA2
  154. /**
  155. * @defgroup old_metadata Old metadata API
  156. * The following functions are deprecated, use
  157. * their equivalents from libavutil/dict.h instead.
  158. * @{
  159. */
  160. #define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE
  161. #define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX
  162. #define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
  163. #define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
  164. #define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE
  165. typedef attribute_deprecated AVDictionary AVMetadata;
  166. typedef attribute_deprecated AVDictionaryEntry AVMetadataTag;
  167. typedef struct AVMetadataConv AVMetadataConv;
  168. /**
  169. * Get a metadata element with matching key.
  170. *
  171. * @param prev Set to the previous matching element to find the next.
  172. * If set to NULL the first matching element is returned.
  173. * @param flags Allows case as well as suffix-insensitive comparisons.
  174. * @return Found tag or NULL, changing key or value leads to undefined behavior.
  175. */
  176. attribute_deprecated AVDictionaryEntry *
  177. av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
  178. /**
  179. * Set the given tag in *pm, overwriting an existing tag.
  180. *
  181. * @param pm pointer to a pointer to a metadata struct. If *pm is NULL
  182. * a metadata struct is allocated and put in *pm.
  183. * @param key tag key to add to *pm (will be av_strduped depending on flags)
  184. * @param value tag value to add to *pm (will be av_strduped depending on flags).
  185. * Passing a NULL value will cause an existing tag to be deleted.
  186. * @return >= 0 on success otherwise an error code <0
  187. */
  188. attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags);
  189. /**
  190. * This function is provided for compatibility reason and currently does nothing.
  191. */
  192. attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
  193. const AVMetadataConv *s_conv);
  194. /**
  195. * Copy metadata from one AVDictionary struct into another.
  196. * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
  197. * this function will allocate a struct for you and put it in *dst
  198. * @param src pointer to source AVDictionary struct
  199. * @param flags flags to use when setting metadata in *dst
  200. * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
  201. */
  202. attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
  203. /**
  204. * Free all the memory allocated for an AVDictionary struct.
  205. */
  206. attribute_deprecated void av_metadata_free(AVDictionary **m);
  207. /**
  208. * @}
  209. */
  210. #endif
  211. /* packet functions */
  212. /**
  213. * Allocate and read the payload of a packet and initialize its
  214. * fields with default values.
  215. *
  216. * @param pkt packet
  217. * @param size desired payload size
  218. * @return >0 (read size) if OK, AVERROR_xxx otherwise
  219. */
  220. int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
  221. /**
  222. * Read data and append it to the current content of the AVPacket.
  223. * If pkt->size is 0 this is identical to av_get_packet.
  224. * Note that this uses av_grow_packet and thus involves a realloc
  225. * which is inefficient. Thus this function should only be used
  226. * when there is no reasonable way to know (an upper bound of)
  227. * the final size.
  228. *
  229. * @param pkt packet
  230. * @param size amount of data to read
  231. * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
  232. * will not be lost even if an error occurs.
  233. */
  234. int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
  235. /*************************************************/
  236. /* fractional numbers for exact pts handling */
  237. /**
  238. * The exact value of the fractional number is: 'val + num / den'.
  239. * num is assumed to be 0 <= num < den.
  240. */
  241. typedef struct AVFrac {
  242. int64_t val, num, den;
  243. } AVFrac;
  244. /*************************************************/
  245. /* input/output formats */
  246. struct AVCodecTag;
  247. /**
  248. * This structure contains the data a format has to probe a file.
  249. */
  250. typedef struct AVProbeData {
  251. const char *filename;
  252. unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
  253. int buf_size; /**< Size of buf except extra allocated bytes */
  254. } AVProbeData;
  255. #define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection
  256. #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
  257. typedef struct AVFormatParameters {
  258. #if FF_API_FORMAT_PARAMETERS
  259. attribute_deprecated AVRational time_base;
  260. attribute_deprecated int sample_rate;
  261. attribute_deprecated int channels;
  262. attribute_deprecated int width;
  263. attribute_deprecated int height;
  264. attribute_deprecated enum PixelFormat pix_fmt;
  265. attribute_deprecated int channel; /**< Used to select DV channel. */
  266. attribute_deprecated const char *standard; /**< deprecated, use demuxer-specific options instead. */
  267. attribute_deprecated unsigned int mpeg2ts_raw:1; /**< deprecated, use mpegtsraw demuxer */
  268. /**< deprecated, use mpegtsraw demuxer-specific options instead */
  269. attribute_deprecated unsigned int mpeg2ts_compute_pcr:1;
  270. attribute_deprecated unsigned int initial_pause:1; /**< Do not begin to play the stream
  271. immediately (RTSP only). */
  272. attribute_deprecated unsigned int prealloced_context:1;
  273. #endif
  274. } AVFormatParameters;
  275. /// Demuxer will use avio_open, no opened file should be provided by the caller.
  276. #define AVFMT_NOFILE 0x0001
  277. #define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */
  278. #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */
  279. #define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for
  280. raw picture data. */
  281. #define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */
  282. #define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */
  283. #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
  284. #define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */
  285. #define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */
  286. #define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */
  287. #define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */
  288. #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */
  289. #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */
  290. #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */
  291. #define AVFMT_TS_NONSTRICT 0x8000000 /**< Format does not require strictly
  292. increasing timestamps, but they must
  293. still be monotonic */
  294. /**
  295. * @addtogroup lavf_encoding
  296. * @{
  297. */
  298. typedef struct AVOutputFormat {
  299. const char *name;
  300. /**
  301. * Descriptive name for the format, meant to be more human-readable
  302. * than name. You should use the NULL_IF_CONFIG_SMALL() macro
  303. * to define it.
  304. */
  305. const char *long_name;
  306. const char *mime_type;
  307. const char *extensions; /**< comma-separated filename extensions */
  308. /**
  309. * size of private data so that it can be allocated in the wrapper
  310. */
  311. int priv_data_size;
  312. /* output support */
  313. enum CodecID audio_codec; /**< default audio codec */
  314. enum CodecID video_codec; /**< default video codec */
  315. int (*write_header)(struct AVFormatContext *);
  316. int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
  317. int (*write_trailer)(struct AVFormatContext *);
  318. /**
  319. * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
  320. * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
  321. * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS
  322. */
  323. int flags;
  324. void *dummy;
  325. int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
  326. AVPacket *in, int flush);
  327. /**
  328. * List of supported codec_id-codec_tag pairs, ordered by "better
  329. * choice first". The arrays are all terminated by CODEC_ID_NONE.
  330. */
  331. const struct AVCodecTag * const *codec_tag;
  332. enum CodecID subtitle_codec; /**< default subtitle codec */
  333. #if FF_API_OLD_METADATA2
  334. const AVMetadataConv *metadata_conv;
  335. #endif
  336. const AVClass *priv_class; ///< AVClass for the private context
  337. /**
  338. * Test if the given codec can be stored in this container.
  339. *
  340. * @return 1 if the codec is supported, 0 if it is not.
  341. * A negative number if unknown.
  342. */
  343. int (*query_codec)(enum CodecID id, int std_compliance);
  344. void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
  345. int64_t *dts, int64_t *wall);
  346. /* private fields */
  347. struct AVOutputFormat *next;
  348. } AVOutputFormat;
  349. /**
  350. * @}
  351. */
  352. /**
  353. * @addtogroup lavf_decoding
  354. * @{
  355. */
  356. typedef struct AVInputFormat {
  357. /**
  358. * A comma separated list of short names for the format. New names
  359. * may be appended with a minor bump.
  360. */
  361. const char *name;
  362. /**
  363. * Descriptive name for the format, meant to be more human-readable
  364. * than name. You should use the NULL_IF_CONFIG_SMALL() macro
  365. * to define it.
  366. */
  367. const char *long_name;
  368. /**
  369. * Size of private data so that it can be allocated in the wrapper.
  370. */
  371. int priv_data_size;
  372. /**
  373. * Tell if a given file has a chance of being parsed as this format.
  374. * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
  375. * big so you do not have to check for that unless you need more.
  376. */
  377. int (*read_probe)(AVProbeData *);
  378. /**
  379. * Read the format header and initialize the AVFormatContext
  380. * structure. Return 0 if OK. 'ap' if non-NULL contains
  381. * additional parameters. Only used in raw format right
  382. * now. 'av_new_stream' should be called to create new streams.
  383. */
  384. int (*read_header)(struct AVFormatContext *,
  385. AVFormatParameters *ap);
  386. /**
  387. * Read one packet and put it in 'pkt'. pts and flags are also
  388. * set. 'av_new_stream' can be called only if the flag
  389. * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
  390. * background thread).
  391. * @return 0 on success, < 0 on error.
  392. * When returning an error, pkt must not have been allocated
  393. * or must be freed before returning
  394. */
  395. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  396. /**
  397. * Close the stream. The AVFormatContext and AVStreams are not
  398. * freed by this function
  399. */
  400. int (*read_close)(struct AVFormatContext *);
  401. #if FF_API_READ_SEEK
  402. /**
  403. * Seek to a given timestamp relative to the frames in
  404. * stream component stream_index.
  405. * @param stream_index Must not be -1.
  406. * @param flags Selects which direction should be preferred if no exact
  407. * match is available.
  408. * @return >= 0 on success (but not necessarily the new offset)
  409. */
  410. attribute_deprecated int (*read_seek)(struct AVFormatContext *,
  411. int stream_index, int64_t timestamp, int flags);
  412. #endif
  413. /**
  414. * Gets the next timestamp in stream[stream_index].time_base units.
  415. * @return the timestamp or AV_NOPTS_VALUE if an error occurred
  416. */
  417. int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
  418. int64_t *pos, int64_t pos_limit);
  419. /**
  420. * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
  421. * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
  422. * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK.
  423. */
  424. int flags;
  425. /**
  426. * If extensions are defined, then no probe is done. You should
  427. * usually not use extension format guessing because it is not
  428. * reliable enough
  429. */
  430. const char *extensions;
  431. /**
  432. * General purpose read-only value that the format can use.
  433. */
  434. int value;
  435. /**
  436. * Start/resume playing - only meaningful if using a network-based format
  437. * (RTSP).
  438. */
  439. int (*read_play)(struct AVFormatContext *);
  440. /**
  441. * Pause playing - only meaningful if using a network-based format
  442. * (RTSP).
  443. */
  444. int (*read_pause)(struct AVFormatContext *);
  445. const struct AVCodecTag * const *codec_tag;
  446. /**
  447. * Seek to timestamp ts.
  448. * Seeking will be done so that the point from which all active streams
  449. * can be presented successfully will be closest to ts and within min/max_ts.
  450. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
  451. */
  452. int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
  453. #if FF_API_OLD_METADATA2
  454. const AVMetadataConv *metadata_conv;
  455. #endif
  456. const AVClass *priv_class; ///< AVClass for the private context
  457. /* private fields */
  458. struct AVInputFormat *next;
  459. } AVInputFormat;
  460. /**
  461. * @}
  462. */
  463. enum AVStreamParseType {
  464. AVSTREAM_PARSE_NONE,
  465. AVSTREAM_PARSE_FULL, /**< full parsing and repack */
  466. AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */
  467. AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
  468. AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */
  469. };
  470. typedef struct AVIndexEntry {
  471. int64_t pos;
  472. int64_t timestamp; /**<
  473. * Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available
  474. * when seeking to this entry. That means preferable PTS on keyframe based formats.
  475. * But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better
  476. * is known
  477. */
  478. #define AVINDEX_KEYFRAME 0x0001
  479. int flags:2;
  480. 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).
  481. int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
  482. } AVIndexEntry;
  483. #define AV_DISPOSITION_DEFAULT 0x0001
  484. #define AV_DISPOSITION_DUB 0x0002
  485. #define AV_DISPOSITION_ORIGINAL 0x0004
  486. #define AV_DISPOSITION_COMMENT 0x0008
  487. #define AV_DISPOSITION_LYRICS 0x0010
  488. #define AV_DISPOSITION_KARAOKE 0x0020
  489. /**
  490. * Track should be used during playback by default.
  491. * Useful for subtitle track that should be displayed
  492. * even when user did not explicitly ask for subtitles.
  493. */
  494. #define AV_DISPOSITION_FORCED 0x0040
  495. #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */
  496. #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */
  497. #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */
  498. /**
  499. * Stream structure.
  500. * New fields can be added to the end with minor version bumps.
  501. * Removal, reordering and changes to existing fields require a major
  502. * version bump.
  503. * sizeof(AVStream) must not be used outside libav*.
  504. */
  505. typedef struct AVStream {
  506. int index; /**< stream index in AVFormatContext */
  507. int id; /**< format-specific stream ID */
  508. AVCodecContext *codec; /**< codec context */
  509. /**
  510. * Real base framerate of the stream.
  511. * This is the lowest framerate with which all timestamps can be
  512. * represented accurately (it is the least common multiple of all
  513. * framerates in the stream). Note, this value is just a guess!
  514. * For example, if the time base is 1/90000 and all frames have either
  515. * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
  516. */
  517. AVRational r_frame_rate;
  518. void *priv_data;
  519. #if FF_API_REORDER_PRIVATE
  520. /* internal data used in av_find_stream_info() */
  521. int64_t first_dts;
  522. #endif
  523. /**
  524. * encoding: pts generation when outputting stream
  525. */
  526. struct AVFrac pts;
  527. /**
  528. * This is the fundamental unit of time (in seconds) in terms
  529. * of which frame timestamps are represented. For fixed-fps content,
  530. * time base should be 1/framerate and timestamp increments should be 1.
  531. * decoding: set by libavformat
  532. * encoding: set by libavformat in av_write_header
  533. */
  534. AVRational time_base;
  535. #if FF_API_REORDER_PRIVATE
  536. int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
  537. #endif
  538. #if FF_API_STREAM_COPY
  539. /* ffmpeg.c private use */
  540. attribute_deprecated int stream_copy; /**< If set, just copy stream. */
  541. #endif
  542. enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
  543. #if FF_API_AVSTREAM_QUALITY
  544. //FIXME move stuff to a flags field?
  545. /**
  546. * Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
  547. * MN: dunno if that is the right place for it
  548. */
  549. attribute_deprecated float quality;
  550. #endif
  551. /**
  552. * Decoding: pts of the first frame of the stream in presentation order, in stream time base.
  553. * Only set this if you are absolutely 100% sure that the value you set
  554. * it to really is the pts of the first frame.
  555. * This may be undefined (AV_NOPTS_VALUE).
  556. * @note The ASF header does NOT contain a correct start_time the ASF
  557. * demuxer must NOT set this.
  558. */
  559. int64_t start_time;
  560. /**
  561. * Decoding: duration of the stream, in stream time base.
  562. * If a source file does not specify a duration, but does specify
  563. * a bitrate, this value will be estimated from bitrate and file size.
  564. */
  565. int64_t duration;
  566. #if FF_API_REORDER_PRIVATE
  567. /* av_read_frame() support */
  568. enum AVStreamParseType need_parsing;
  569. struct AVCodecParserContext *parser;
  570. int64_t cur_dts;
  571. int last_IP_duration;
  572. int64_t last_IP_pts;
  573. /* av_seek_frame() support */
  574. AVIndexEntry *index_entries; /**< Only used if the format does not
  575. support seeking natively. */
  576. int nb_index_entries;
  577. unsigned int index_entries_allocated_size;
  578. #endif
  579. int64_t nb_frames; ///< number of frames in this stream if known or 0
  580. int disposition; /**< AV_DISPOSITION_* bit field */
  581. #if FF_API_REORDER_PRIVATE
  582. AVProbeData probe_data;
  583. #define MAX_REORDER_DELAY 16
  584. int64_t pts_buffer[MAX_REORDER_DELAY+1];
  585. #endif
  586. /**
  587. * sample aspect ratio (0 if unknown)
  588. * - encoding: Set by user.
  589. * - decoding: Set by libavformat.
  590. */
  591. AVRational sample_aspect_ratio;
  592. AVDictionary *metadata;
  593. #if FF_API_REORDER_PRIVATE
  594. /* Intended mostly for av_read_frame() support. Not supposed to be used by */
  595. /* external applications; try to use something else if at all possible. */
  596. const uint8_t *cur_ptr;
  597. int cur_len;
  598. AVPacket cur_pkt;
  599. // Timestamp generation support:
  600. /**
  601. * Timestamp corresponding to the last dts sync point.
  602. *
  603. * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
  604. * a DTS is received from the underlying container. Otherwise set to
  605. * AV_NOPTS_VALUE by default.
  606. */
  607. int64_t reference_dts;
  608. /**
  609. * Number of packets to buffer for codec probing
  610. * NOT PART OF PUBLIC API
  611. */
  612. #define MAX_PROBE_PACKETS 2500
  613. int probe_packets;
  614. /**
  615. * last packet in packet_buffer for this stream when muxing.
  616. * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav*
  617. */
  618. struct AVPacketList *last_in_packet_buffer;
  619. #endif
  620. /**
  621. * Average framerate
  622. */
  623. AVRational avg_frame_rate;
  624. /*****************************************************************
  625. * All fields below this line are not part of the public API. They
  626. * may not be used outside of libavformat and can be changed and
  627. * removed at will.
  628. * New public fields should be added right above.
  629. *****************************************************************
  630. */
  631. /**
  632. * Number of frames that have been demuxed during av_find_stream_info()
  633. */
  634. int codec_info_nb_frames;
  635. /**
  636. * Stream Identifier
  637. * This is the MPEG-TS stream identifier +1
  638. * 0 means unknown
  639. */
  640. int stream_identifier;
  641. int64_t interleaver_chunk_size;
  642. int64_t interleaver_chunk_duration;
  643. /**
  644. * Stream informations used internally by av_find_stream_info()
  645. */
  646. #define MAX_STD_TIMEBASES (60*12+5)
  647. struct {
  648. int64_t last_dts;
  649. int64_t duration_gcd;
  650. int duration_count;
  651. double duration_error[2][2][MAX_STD_TIMEBASES];
  652. int64_t codec_info_duration;
  653. int nb_decoded_frames;
  654. } *info;
  655. /**
  656. * flag to indicate that probing is requested
  657. * NOT PART OF PUBLIC API
  658. */
  659. int request_probe;
  660. #if !FF_API_REORDER_PRIVATE
  661. const uint8_t *cur_ptr;
  662. int cur_len;
  663. AVPacket cur_pkt;
  664. // Timestamp generation support:
  665. /**
  666. * Timestamp corresponding to the last dts sync point.
  667. *
  668. * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
  669. * a DTS is received from the underlying container. Otherwise set to
  670. * AV_NOPTS_VALUE by default.
  671. */
  672. int64_t reference_dts;
  673. int64_t first_dts;
  674. int64_t cur_dts;
  675. int last_IP_duration;
  676. int64_t last_IP_pts;
  677. /**
  678. * Number of packets to buffer for codec probing
  679. */
  680. #define MAX_PROBE_PACKETS 2500
  681. int probe_packets;
  682. /**
  683. * last packet in packet_buffer for this stream when muxing.
  684. */
  685. struct AVPacketList *last_in_packet_buffer;
  686. AVProbeData probe_data;
  687. #define MAX_REORDER_DELAY 16
  688. int64_t pts_buffer[MAX_REORDER_DELAY+1];
  689. /* av_read_frame() support */
  690. enum AVStreamParseType need_parsing;
  691. struct AVCodecParserContext *parser;
  692. AVIndexEntry *index_entries; /**< Only used if the format does not
  693. support seeking natively. */
  694. int nb_index_entries;
  695. unsigned int index_entries_allocated_size;
  696. int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
  697. #endif
  698. } AVStream;
  699. #define AV_PROGRAM_RUNNING 1
  700. /**
  701. * New fields can be added to the end with minor version bumps.
  702. * Removal, reordering and changes to existing fields require a major
  703. * version bump.
  704. * sizeof(AVProgram) must not be used outside libav*.
  705. */
  706. typedef struct AVProgram {
  707. int id;
  708. int flags;
  709. enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
  710. unsigned int *stream_index;
  711. unsigned int nb_stream_indexes;
  712. AVDictionary *metadata;
  713. int program_num;
  714. int pmt_pid;
  715. int pcr_pid;
  716. } AVProgram;
  717. #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
  718. (streams are added dynamically) */
  719. typedef struct AVChapter {
  720. int id; ///< unique ID to identify the chapter
  721. AVRational time_base; ///< time base in which the start/end timestamps are specified
  722. int64_t start, end; ///< chapter start/end time in time_base units
  723. AVDictionary *metadata;
  724. } AVChapter;
  725. /**
  726. * Format I/O context.
  727. * New fields can be added to the end with minor version bumps.
  728. * Removal, reordering and changes to existing fields require a major
  729. * version bump.
  730. * sizeof(AVFormatContext) must not be used outside libav*, use
  731. * avformat_alloc_context() to create an AVFormatContext.
  732. */
  733. typedef struct AVFormatContext {
  734. /**
  735. * A class for logging and AVOptions. Set by avformat_alloc_context().
  736. * Exports (de)muxer private options if they exist.
  737. */
  738. const AVClass *av_class;
  739. /**
  740. * Can only be iformat or oformat, not both at the same time.
  741. *
  742. * decoding: set by avformat_open_input().
  743. * encoding: set by the user.
  744. */
  745. struct AVInputFormat *iformat;
  746. struct AVOutputFormat *oformat;
  747. /**
  748. * Format private data. This is an AVOptions-enabled struct
  749. * if and only if iformat/oformat.priv_class is not NULL.
  750. */
  751. void *priv_data;
  752. /*
  753. * I/O context.
  754. *
  755. * decoding: either set by the user before avformat_open_input() (then
  756. * the user must close it manually) or set by avformat_open_input().
  757. * encoding: set by the user.
  758. *
  759. * Do NOT set this field if AVFMT_NOFILE flag is set in
  760. * iformat/oformat.flags. In such a case, the (de)muxer will handle
  761. * I/O in some other way and this field will be NULL.
  762. */
  763. AVIOContext *pb;
  764. /**
  765. * A list of all streams in the file. New streams are created with
  766. * avformat_new_stream().
  767. *
  768. * decoding: streams are created by libavformat in avformat_open_input().
  769. * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also
  770. * appear in av_read_frame().
  771. * encoding: streams are created by the user before avformat_write_header().
  772. */
  773. unsigned int nb_streams;
  774. AVStream **streams;
  775. char filename[1024]; /**< input or output filename */
  776. /* stream info */
  777. #if FF_API_TIMESTAMP
  778. /**
  779. * @deprecated use 'creation_time' metadata tag instead
  780. */
  781. attribute_deprecated int64_t timestamp;
  782. #endif
  783. int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
  784. #if FF_API_REORDER_PRIVATE
  785. /* private data for pts handling (do not modify directly). */
  786. /**
  787. * This buffer is only needed when packets were already buffered but
  788. * not decoded, for example to get the codec parameters in MPEG
  789. * streams.
  790. */
  791. struct AVPacketList *packet_buffer;
  792. #endif
  793. /**
  794. * Decoding: position of the first frame of the component, in
  795. * AV_TIME_BASE fractional seconds. NEVER set this value directly:
  796. * It is deduced from the AVStream values.
  797. */
  798. int64_t start_time;
  799. /**
  800. * Decoding: duration of the stream, in AV_TIME_BASE fractional
  801. * seconds. Only set this value if you know none of the individual stream
  802. * durations and also dont set any of them. This is deduced from the
  803. * AVStream values if not set.
  804. */
  805. int64_t duration;
  806. #if FF_API_FILESIZE
  807. /**
  808. * decoding: total file size, 0 if unknown
  809. */
  810. attribute_deprecated int64_t file_size;
  811. #endif
  812. /**
  813. * Decoding: total stream bitrate in bit/s, 0 if not
  814. * available. Never set it directly if the file_size and the
  815. * duration are known as FFmpeg can compute it automatically.
  816. */
  817. int bit_rate;
  818. #if FF_API_REORDER_PRIVATE
  819. /* av_read_frame() support */
  820. AVStream *cur_st;
  821. /* av_seek_frame() support */
  822. int64_t data_offset; /**< offset of the first packet */
  823. #endif
  824. #if FF_API_MUXRATE
  825. /**
  826. * use mpeg muxer private options instead
  827. */
  828. attribute_deprecated int mux_rate;
  829. #endif
  830. unsigned int packet_size;
  831. #if FF_API_PRELOAD
  832. attribute_deprecated int preload;
  833. #endif
  834. int max_delay;
  835. #if FF_API_LOOP_OUTPUT
  836. #define AVFMT_NOOUTPUTLOOP -1
  837. #define AVFMT_INFINITEOUTPUTLOOP 0
  838. /**
  839. * number of times to loop output in formats that support it
  840. *
  841. * @deprecated use the 'loop' private option in the gif muxer.
  842. */
  843. attribute_deprecated int loop_output;
  844. #endif
  845. int flags;
  846. #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
  847. #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
  848. #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
  849. #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
  850. #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
  851. #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
  852. #if FF_API_FLAG_RTP_HINT
  853. #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
  854. #endif
  855. #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
  856. #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
  857. #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
  858. #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
  859. #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
  860. #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate.
  861. #if FF_API_LOOP_INPUT
  862. /**
  863. * @deprecated, use the 'loop' img2 demuxer private option.
  864. */
  865. attribute_deprecated int loop_input;
  866. #endif
  867. /**
  868. * decoding: size of data to probe; encoding: unused.
  869. */
  870. unsigned int probesize;
  871. /**
  872. * decoding: maximum time (in AV_TIME_BASE units) during which the input should
  873. * be analyzed in avformat_find_stream_info().
  874. */
  875. int max_analyze_duration;
  876. const uint8_t *key;
  877. int keylen;
  878. unsigned int nb_programs;
  879. AVProgram **programs;
  880. /**
  881. * Forced video codec_id.
  882. * Demuxing: Set by user.
  883. */
  884. enum CodecID video_codec_id;
  885. /**
  886. * Forced audio codec_id.
  887. * Demuxing: Set by user.
  888. */
  889. enum CodecID audio_codec_id;
  890. /**
  891. * Forced subtitle codec_id.
  892. * Demuxing: Set by user.
  893. */
  894. enum CodecID subtitle_codec_id;
  895. /**
  896. * Maximum amount of memory in bytes to use for the index of each stream.
  897. * If the index exceeds this size, entries will be discarded as
  898. * needed to maintain a smaller size. This can lead to slower or less
  899. * accurate seeking (depends on demuxer).
  900. * Demuxers for which a full in-memory index is mandatory will ignore
  901. * this.
  902. * muxing : unused
  903. * demuxing: set by user
  904. */
  905. unsigned int max_index_size;
  906. /**
  907. * Maximum amount of memory in bytes to use for buffering frames
  908. * obtained from realtime capture devices.
  909. */
  910. unsigned int max_picture_buffer;
  911. unsigned int nb_chapters;
  912. AVChapter **chapters;
  913. /**
  914. * Flags to enable debugging.
  915. */
  916. int debug;
  917. #define FF_FDEBUG_TS 0x0001
  918. #if FF_API_REORDER_PRIVATE
  919. /**
  920. * Raw packets from the demuxer, prior to parsing and decoding.
  921. * This buffer is used for buffering packets until the codec can
  922. * be identified, as parsing cannot be done without knowing the
  923. * codec.
  924. */
  925. struct AVPacketList *raw_packet_buffer;
  926. struct AVPacketList *raw_packet_buffer_end;
  927. struct AVPacketList *packet_buffer_end;
  928. #endif
  929. AVDictionary *metadata;
  930. #if FF_API_REORDER_PRIVATE
  931. /**
  932. * Remaining size available for raw_packet_buffer, in bytes.
  933. * NOT PART OF PUBLIC API
  934. */
  935. #define RAW_PACKET_BUFFER_SIZE 2500000
  936. int raw_packet_buffer_remaining_size;
  937. #endif
  938. /**
  939. * Start time of the stream in real world time, in microseconds
  940. * since the unix epoch (00:00 1st January 1970). That is, pts=0
  941. * in the stream was captured at this real world time.
  942. * - encoding: Set by user.
  943. * - decoding: Unused.
  944. */
  945. int64_t start_time_realtime;
  946. /**
  947. * decoding: number of frames used to probe fps
  948. */
  949. int fps_probe_size;
  950. /**
  951. * Error recognition; higher values will detect more errors but may
  952. * misdetect some more or less valid parts as errors.
  953. * - encoding: unused
  954. * - decoding: Set by user.
  955. */
  956. int error_recognition;
  957. /**
  958. * Custom interrupt callbacks for the I/O layer.
  959. *
  960. * decoding: set by the user before avformat_open_input().
  961. * encoding: set by the user before avformat_write_header()
  962. * (mainly useful for AVFMT_NOFILE formats). The callback
  963. * should also be passed to avio_open2() if it's used to
  964. * open the file.
  965. */
  966. AVIOInterruptCB interrupt_callback;
  967. /**
  968. * Transport stream id.
  969. * This will be moved into demuxer private options. Thus no API/ABI compatibility
  970. */
  971. int ts_id;
  972. /**
  973. * Audio preload in microseconds.
  974. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  975. * - encoding: Set by user via AVOptions (NO direct access)
  976. * - decoding: unused
  977. */
  978. int audio_preload;
  979. /**
  980. * Max chunk time in microseconds.
  981. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  982. * - encoding: Set by user via AVOptions (NO direct access)
  983. * - decoding: unused
  984. */
  985. int max_chunk_duration;
  986. /**
  987. * Max chunk size in bytes
  988. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  989. * - encoding: Set by user via AVOptions (NO direct access)
  990. * - decoding: unused
  991. */
  992. int max_chunk_size;
  993. /*****************************************************************
  994. * All fields below this line are not part of the public API. They
  995. * may not be used outside of libavformat and can be changed and
  996. * removed at will.
  997. * New public fields should be added right above.
  998. *****************************************************************
  999. */
  1000. #if !FF_API_REORDER_PRIVATE
  1001. /**
  1002. * Raw packets from the demuxer, prior to parsing and decoding.
  1003. * This buffer is used for buffering packets until the codec can
  1004. * be identified, as parsing cannot be done without knowing the
  1005. * codec.
  1006. */
  1007. struct AVPacketList *raw_packet_buffer;
  1008. struct AVPacketList *raw_packet_buffer_end;
  1009. /**
  1010. * Remaining size available for raw_packet_buffer, in bytes.
  1011. */
  1012. #define RAW_PACKET_BUFFER_SIZE 2500000
  1013. int raw_packet_buffer_remaining_size;
  1014. /**
  1015. * This buffer is only needed when packets were already buffered but
  1016. * not decoded, for example to get the codec parameters in MPEG
  1017. * streams.
  1018. */
  1019. struct AVPacketList *packet_buffer;
  1020. struct AVPacketList *packet_buffer_end;
  1021. /* av_read_frame() support */
  1022. AVStream *cur_st;
  1023. /* av_seek_frame() support */
  1024. int64_t data_offset; /**< offset of the first packet */
  1025. #endif
  1026. } AVFormatContext;
  1027. typedef struct AVPacketList {
  1028. AVPacket pkt;
  1029. struct AVPacketList *next;
  1030. } AVPacketList;
  1031. /**
  1032. * If f is NULL, returns the first registered input format,
  1033. * if f is non-NULL, returns the next registered input format after f
  1034. * or NULL if f is the last one.
  1035. */
  1036. AVInputFormat *av_iformat_next(AVInputFormat *f);
  1037. /**
  1038. * If f is NULL, returns the first registered output format,
  1039. * if f is non-NULL, returns the next registered output format after f
  1040. * or NULL if f is the last one.
  1041. */
  1042. AVOutputFormat *av_oformat_next(AVOutputFormat *f);
  1043. #if FF_API_GUESS_IMG2_CODEC
  1044. attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename);
  1045. #endif
  1046. /* XXX: Use automatic init with either ELF sections or C file parser */
  1047. /* modules. */
  1048. /* utils.c */
  1049. void av_register_input_format(AVInputFormat *format);
  1050. void av_register_output_format(AVOutputFormat *format);
  1051. /**
  1052. * Return the output format in the list of registered output formats
  1053. * which best matches the provided parameters, or return NULL if
  1054. * there is no match.
  1055. *
  1056. * @param short_name if non-NULL checks if short_name matches with the
  1057. * names of the registered formats
  1058. * @param filename if non-NULL checks if filename terminates with the
  1059. * extensions of the registered formats
  1060. * @param mime_type if non-NULL checks if mime_type matches with the
  1061. * MIME type of the registered formats
  1062. */
  1063. AVOutputFormat *av_guess_format(const char *short_name,
  1064. const char *filename,
  1065. const char *mime_type);
  1066. /**
  1067. * Guess the codec ID based upon muxer and filename.
  1068. */
  1069. enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
  1070. const char *filename, const char *mime_type,
  1071. enum AVMediaType type);
  1072. /**
  1073. * Send a nice hexadecimal dump of a buffer to the specified file stream.
  1074. *
  1075. * @param f The file stream pointer where the dump should be sent to.
  1076. * @param buf buffer
  1077. * @param size buffer size
  1078. *
  1079. * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
  1080. */
  1081. void av_hex_dump(FILE *f, uint8_t *buf, int size);
  1082. /**
  1083. * Send a nice hexadecimal dump of a buffer to the log.
  1084. *
  1085. * @param avcl A pointer to an arbitrary struct of which the first field is a
  1086. * pointer to an AVClass struct.
  1087. * @param level The importance level of the message, lower values signifying
  1088. * higher importance.
  1089. * @param buf buffer
  1090. * @param size buffer size
  1091. *
  1092. * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
  1093. */
  1094. void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
  1095. /**
  1096. * Send a nice dump of a packet to the specified file stream.
  1097. *
  1098. * @param f The file stream pointer where the dump should be sent to.
  1099. * @param pkt packet to dump
  1100. * @param dump_payload True if the payload must be displayed, too.
  1101. * @param st AVStream that the packet belongs to
  1102. */
  1103. void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
  1104. /**
  1105. * Send a nice dump of a packet to the log.
  1106. *
  1107. * @param avcl A pointer to an arbitrary struct of which the first field is a
  1108. * pointer to an AVClass struct.
  1109. * @param level The importance level of the message, lower values signifying
  1110. * higher importance.
  1111. * @param pkt packet to dump
  1112. * @param dump_payload True if the payload must be displayed, too.
  1113. * @param st AVStream that the packet belongs to
  1114. */
  1115. void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
  1116. AVStream *st);
  1117. #if FF_API_PKT_DUMP
  1118. attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  1119. attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
  1120. int dump_payload);
  1121. #endif
  1122. /**
  1123. * Initialize libavformat and register all the muxers, demuxers and
  1124. * protocols. If you do not call this function, then you can select
  1125. * exactly which formats you want to support.
  1126. *
  1127. * @see av_register_input_format()
  1128. * @see av_register_output_format()
  1129. * @see av_register_protocol()
  1130. */
  1131. void av_register_all(void);
  1132. /**
  1133. * Get the CodecID for the given codec tag tag.
  1134. * If no codec id is found returns CODEC_ID_NONE.
  1135. *
  1136. * @param tags list of supported codec_id-codec_tag pairs, as stored
  1137. * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
  1138. */
  1139. enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
  1140. /**
  1141. * Get the codec tag for the given codec id id.
  1142. * If no codec tag is found returns 0.
  1143. *
  1144. * @param tags list of supported codec_id-codec_tag pairs, as stored
  1145. * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
  1146. */
  1147. unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
  1148. /**
  1149. * Allocate an AVFormatContext.
  1150. * avformat_free_context() can be used to free the context and everything
  1151. * allocated by the framework within it.
  1152. */
  1153. AVFormatContext *avformat_alloc_context(void);
  1154. #if FF_API_ALLOC_OUTPUT_CONTEXT
  1155. /**
  1156. * @deprecated deprecated in favor of avformat_alloc_output_context2()
  1157. */
  1158. attribute_deprecated
  1159. AVFormatContext *avformat_alloc_output_context(const char *format,
  1160. AVOutputFormat *oformat,
  1161. const char *filename);
  1162. #endif
  1163. /**
  1164. * Allocate an AVFormatContext for an output format.
  1165. * avformat_free_context() can be used to free the context and
  1166. * everything allocated by the framework within it.
  1167. *
  1168. * @param *ctx is set to the created format context, or to NULL in
  1169. * case of failure
  1170. * @param oformat format to use for allocating the context, if NULL
  1171. * format_name and filename are used instead
  1172. * @param format_name the name of output format to use for allocating the
  1173. * context, if NULL filename is used instead
  1174. * @param filename the name of the filename to use for allocating the
  1175. * context, may be NULL
  1176. * @return >= 0 in case of success, a negative AVERROR code in case of
  1177. * failure
  1178. */
  1179. int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat,
  1180. const char *format_name, const char *filename);
  1181. /**
  1182. * @addtogroup lavf_decoding
  1183. * @{
  1184. */
  1185. /**
  1186. * Find AVInputFormat based on the short name of the input format.
  1187. */
  1188. AVInputFormat *av_find_input_format(const char *short_name);
  1189. /**
  1190. * Guess the file format.
  1191. *
  1192. * @param is_opened Whether the file is already opened; determines whether
  1193. * demuxers with or without AVFMT_NOFILE are probed.
  1194. */
  1195. AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
  1196. /**
  1197. * Guess the file format.
  1198. *
  1199. * @param is_opened Whether the file is already opened; determines whether
  1200. * demuxers with or without AVFMT_NOFILE are probed.
  1201. * @param score_max A probe score larger that this is required to accept a
  1202. * detection, the variable is set to the actual detection
  1203. * score afterwards.
  1204. * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended
  1205. * to retry with a larger probe buffer.
  1206. */
  1207. AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
  1208. /**
  1209. * Guess the file format.
  1210. *
  1211. * @param is_opened Whether the file is already opened; determines whether
  1212. * demuxers with or without AVFMT_NOFILE are probed.
  1213. * @param score_ret The score of the best detection.
  1214. */
  1215. AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret);
  1216. /**
  1217. * Probe a bytestream to determine the input format. Each time a probe returns
  1218. * with a score that is too low, the probe buffer size is increased and another
  1219. * attempt is made. When the maximum probe size is reached, the input format
  1220. * with the highest score is returned.
  1221. *
  1222. * @param pb the bytestream to probe
  1223. * @param fmt the input format is put here
  1224. * @param filename the filename of the stream
  1225. * @param logctx the log context
  1226. * @param offset the offset within the bytestream to probe from
  1227. * @param max_probe_size the maximum probe buffer size (zero for default)
  1228. * @return 0 in case of success, a negative value corresponding to an
  1229. * AVERROR code otherwise
  1230. */
  1231. int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
  1232. const char *filename, void *logctx,
  1233. unsigned int offset, unsigned int max_probe_size);
  1234. #if FF_API_FORMAT_PARAMETERS
  1235. /**
  1236. * Allocate all the structures needed to read an input stream.
  1237. * This does not open the needed codecs for decoding the stream[s].
  1238. * @deprecated use avformat_open_input instead.
  1239. */
  1240. attribute_deprecated int av_open_input_stream(AVFormatContext **ic_ptr,
  1241. AVIOContext *pb, const char *filename,
  1242. AVInputFormat *fmt, AVFormatParameters *ap);
  1243. /**
  1244. * Open a media file as input. The codecs are not opened. Only the file
  1245. * header (if present) is read.
  1246. *
  1247. * @param ic_ptr The opened media file handle is put here.
  1248. * @param filename filename to open
  1249. * @param fmt If non-NULL, force the file format to use.
  1250. * @param buf_size optional buffer size (zero if default is OK)
  1251. * @param ap Additional parameters needed when opening the file
  1252. * (NULL if default).
  1253. * @return 0 if OK, AVERROR_xxx otherwise
  1254. *
  1255. * @deprecated use avformat_open_input instead.
  1256. */
  1257. attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  1258. AVInputFormat *fmt,
  1259. int buf_size,
  1260. AVFormatParameters *ap);
  1261. #endif
  1262. /**
  1263. * Open an input stream and read the header. The codecs are not opened.
  1264. * The stream must be closed with av_close_input_file().
  1265. *
  1266. * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
  1267. * May be a pointer to NULL, in which case an AVFormatContext is allocated by this
  1268. * function and written into ps.
  1269. * Note that a user-supplied AVFormatContext will be freed on failure.
  1270. * @param filename Name of the stream to open.
  1271. * @param fmt If non-NULL, this parameter forces a specific input format.
  1272. * Otherwise the format is autodetected.
  1273. * @param options A dictionary filled with AVFormatContext and demuxer-private options.
  1274. * On return this parameter will be destroyed and replaced with a dict containing
  1275. * options that were not found. May be NULL.
  1276. *
  1277. * @return 0 on success, a negative AVERROR on failure.
  1278. *
  1279. * @note If you want to use custom IO, preallocate the format context and set its pb field.
  1280. */
  1281. int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
  1282. int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap);
  1283. #if FF_API_FORMAT_PARAMETERS
  1284. /**
  1285. * Read packets of a media file to get stream information. This
  1286. * is useful for file formats with no headers such as MPEG. This
  1287. * function also computes the real framerate in case of MPEG-2 repeat
  1288. * frame mode.
  1289. * The logical file position is not changed by this function;
  1290. * examined packets may be buffered for later processing.
  1291. *
  1292. * @param ic media file handle
  1293. * @return >=0 if OK, AVERROR_xxx on error
  1294. * @todo Let the user decide somehow what information is needed so that
  1295. * we do not waste time getting stuff the user does not need.
  1296. *
  1297. * @deprecated use avformat_find_stream_info.
  1298. */
  1299. attribute_deprecated
  1300. int av_find_stream_info(AVFormatContext *ic);
  1301. #endif
  1302. /**
  1303. * Read packets of a media file to get stream information. This
  1304. * is useful for file formats with no headers such as MPEG. This
  1305. * function also computes the real framerate in case of MPEG-2 repeat
  1306. * frame mode.
  1307. * The logical file position is not changed by this function;
  1308. * examined packets may be buffered for later processing.
  1309. *
  1310. * @param ic media file handle
  1311. * @param options If non-NULL, an ic.nb_streams long array of pointers to
  1312. * dictionaries, where i-th member contains options for
  1313. * codec corresponding to i-th stream.
  1314. * On return each dictionary will be filled with options that were not found.
  1315. * @return >=0 if OK, AVERROR_xxx on error
  1316. *
  1317. * @note this function isn't guaranteed to open all the codecs, so
  1318. * options being non-empty at return is a perfectly normal behavior.
  1319. *
  1320. * @todo Let the user decide somehow what information is needed so that
  1321. * we do not waste time getting stuff the user does not need.
  1322. */
  1323. int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
  1324. /**
  1325. * Find the programs which belong to a given stream.
  1326. *
  1327. * @param ic media file handle
  1328. * @param last the last found program, the search will start after this
  1329. * program, or from the beginning if it is NULL
  1330. * @param s stream index
  1331. * @return the next program which belongs to s, NULL if no program is found or
  1332. * the last program is not among the programs of ic.
  1333. */
  1334. AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);
  1335. /**
  1336. * Find the "best" stream in the file.
  1337. * The best stream is determined according to various heuristics as the most
  1338. * likely to be what the user expects.
  1339. * If the decoder parameter is non-NULL, av_find_best_stream will find the
  1340. * default decoder for the stream's codec; streams for which no decoder can
  1341. * be found are ignored.
  1342. *
  1343. * @param ic media file handle
  1344. * @param type stream type: video, audio, subtitles, etc.
  1345. * @param wanted_stream_nb user-requested stream number,
  1346. * or -1 for automatic selection
  1347. * @param related_stream try to find a stream related (eg. in the same
  1348. * program) to this one, or -1 if none
  1349. * @param decoder_ret if non-NULL, returns the decoder for the
  1350. * selected stream
  1351. * @param flags flags; none are currently defined
  1352. * @return the non-negative stream number in case of success,
  1353. * AVERROR_STREAM_NOT_FOUND if no stream with the requested type
  1354. * could be found,
  1355. * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
  1356. * @note If av_find_best_stream returns successfully and decoder_ret is not
  1357. * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
  1358. */
  1359. int av_find_best_stream(AVFormatContext *ic,
  1360. enum AVMediaType type,
  1361. int wanted_stream_nb,
  1362. int related_stream,
  1363. AVCodec **decoder_ret,
  1364. int flags);
  1365. /**
  1366. * Read a transport packet from a media file.
  1367. *
  1368. * This function is obsolete and should never be used.
  1369. * Use av_read_frame() instead.
  1370. *
  1371. * @param s media file handle
  1372. * @param pkt is filled
  1373. * @return 0 if OK, AVERROR_xxx on error
  1374. */
  1375. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  1376. /**
  1377. * Return the next frame of a stream.
  1378. * This function returns what is stored in the file, and does not validate
  1379. * that what is there are valid frames for the decoder. It will split what is
  1380. * stored in the file into frames and return one for each call. It will not
  1381. * omit invalid data between valid frames so as to give the decoder the maximum
  1382. * information possible for decoding.
  1383. *
  1384. * The returned packet is valid
  1385. * until the next av_read_frame() or until av_close_input_file() and
  1386. * must be freed with av_free_packet. For video, the packet contains
  1387. * exactly one frame. For audio, it contains an integer number of
  1388. * frames if each frame has a known fixed size (e.g. PCM or ADPCM
  1389. * data). If the audio frames have a variable size (e.g. MPEG audio),
  1390. * then it contains one frame.
  1391. *
  1392. * pkt->pts, pkt->dts and pkt->duration are always set to correct
  1393. * values in AVStream.time_base units (and guessed if the format cannot
  1394. * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
  1395. * has B-frames, so it is better to rely on pkt->dts if you do not
  1396. * decompress the payload.
  1397. *
  1398. * @return 0 if OK, < 0 on error or end of file
  1399. */
  1400. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  1401. /**
  1402. * Seek to the keyframe at timestamp.
  1403. * 'timestamp' in 'stream_index'.
  1404. * @param stream_index If stream_index is (-1), a default
  1405. * stream is selected, and timestamp is automatically converted
  1406. * from AV_TIME_BASE units to the stream specific time_base.
  1407. * @param timestamp Timestamp in AVStream.time_base units
  1408. * or, if no stream is specified, in AV_TIME_BASE units.
  1409. * @param flags flags which select direction and seeking mode
  1410. * @return >= 0 on success
  1411. */
  1412. int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
  1413. int flags);
  1414. /**
  1415. * Seek to timestamp ts.
  1416. * Seeking will be done so that the point from which all active streams
  1417. * can be presented successfully will be closest to ts and within min/max_ts.
  1418. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
  1419. *
  1420. * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
  1421. * are the file position (this may not be supported by all demuxers).
  1422. * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
  1423. * in the stream with stream_index (this may not be supported by all demuxers).
  1424. * Otherwise all timestamps are in units of the stream selected by stream_index
  1425. * or if stream_index is -1, in AV_TIME_BASE units.
  1426. * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
  1427. * keyframes (this may not be supported by all demuxers).
  1428. *
  1429. * @param stream_index index of the stream which is used as time base reference
  1430. * @param min_ts smallest acceptable timestamp
  1431. * @param ts target timestamp
  1432. * @param max_ts largest acceptable timestamp
  1433. * @param flags flags
  1434. * @return >=0 on success, error code otherwise
  1435. *
  1436. * @note This is part of the new seek API which is still under construction.
  1437. * Thus do not use this yet. It may change at any time, do not expect
  1438. * ABI compatibility yet!
  1439. */
  1440. int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
  1441. /**
  1442. * Start playing a network-based stream (e.g. RTSP stream) at the
  1443. * current position.
  1444. */
  1445. int av_read_play(AVFormatContext *s);
  1446. /**
  1447. * Pause a network-based stream (e.g. RTSP stream).
  1448. *
  1449. * Use av_read_play() to resume it.
  1450. */
  1451. int av_read_pause(AVFormatContext *s);
  1452. /**
  1453. * Free a AVFormatContext allocated by av_open_input_stream.
  1454. * @param s context to free
  1455. */
  1456. void av_close_input_stream(AVFormatContext *s);
  1457. /**
  1458. * Close a media file (but not its codecs).
  1459. *
  1460. * @param s media file handle
  1461. */
  1462. void av_close_input_file(AVFormatContext *s);
  1463. /**
  1464. * @}
  1465. */
  1466. /**
  1467. * Free an AVFormatContext and all its streams.
  1468. * @param s context to free
  1469. */
  1470. void avformat_free_context(AVFormatContext *s);
  1471. #if FF_API_NEW_STREAM
  1472. /**
  1473. * Add a new stream to a media file.
  1474. *
  1475. * Can only be called in the read_header() function. If the flag
  1476. * AVFMTCTX_NOHEADER is in the format context, then new streams
  1477. * can be added in read_packet too.
  1478. *
  1479. * @param s media file handle
  1480. * @param id file-format-dependent stream ID
  1481. */
  1482. attribute_deprecated
  1483. AVStream *av_new_stream(AVFormatContext *s, int id);
  1484. #endif
  1485. /**
  1486. * Add a new stream to a media file.
  1487. *
  1488. * When demuxing, it is called by the demuxer in read_header(). If the
  1489. * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
  1490. * be called in read_packet().
  1491. *
  1492. * When muxing, should be called by the user before avformat_write_header().
  1493. *
  1494. * @param c If non-NULL, the AVCodecContext corresponding to the new stream
  1495. * will be initialized to use this codec. This is needed for e.g. codec-specific
  1496. * defaults to be set, so codec should be provided if it is known.
  1497. *
  1498. * @return newly created stream or NULL on error.
  1499. */
  1500. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
  1501. AVProgram *av_new_program(AVFormatContext *s, int id);
  1502. #if FF_API_SET_PTS_INFO
  1503. /**
  1504. * @deprecated this function is not supposed to be called outside of lavf
  1505. */
  1506. attribute_deprecated
  1507. void av_set_pts_info(AVStream *s, int pts_wrap_bits,
  1508. unsigned int pts_num, unsigned int pts_den);
  1509. #endif
  1510. #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
  1511. #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
  1512. #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
  1513. #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
  1514. int av_find_default_stream_index(AVFormatContext *s);
  1515. /**
  1516. * Get the index for a specific timestamp.
  1517. * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
  1518. * to the timestamp which is <= the requested one, if backward
  1519. * is 0, then it will be >=
  1520. * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
  1521. * @return < 0 if no such timestamp could be found
  1522. */
  1523. int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  1524. /**
  1525. * Add an index entry into a sorted list. Update the entry if the list
  1526. * already contains it.
  1527. *
  1528. * @param timestamp timestamp in the time base of the given stream
  1529. */
  1530. int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
  1531. int size, int distance, int flags);
  1532. #if FF_API_SEEK_PUBLIC
  1533. attribute_deprecated
  1534. int av_seek_frame_binary(AVFormatContext *s, int stream_index,
  1535. int64_t target_ts, int flags);
  1536. attribute_deprecated
  1537. void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
  1538. attribute_deprecated
  1539. int64_t av_gen_search(AVFormatContext *s, int stream_index,
  1540. int64_t target_ts, int64_t pos_min,
  1541. int64_t pos_max, int64_t pos_limit,
  1542. int64_t ts_min, int64_t ts_max,
  1543. int flags, int64_t *ts_ret,
  1544. int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
  1545. #endif
  1546. #if FF_API_FORMAT_PARAMETERS
  1547. /**
  1548. * @deprecated pass the options to avformat_write_header directly.
  1549. */
  1550. attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
  1551. #endif
  1552. /**
  1553. * Split a URL string into components.
  1554. *
  1555. * The pointers to buffers for storing individual components may be null,
  1556. * in order to ignore that component. Buffers for components not found are
  1557. * set to empty strings. If the port is not found, it is set to a negative
  1558. * value.
  1559. *
  1560. * @param proto the buffer for the protocol
  1561. * @param proto_size the size of the proto buffer
  1562. * @param authorization the buffer for the authorization
  1563. * @param authorization_size the size of the authorization buffer
  1564. * @param hostname the buffer for the host name
  1565. * @param hostname_size the size of the hostname buffer
  1566. * @param port_ptr a pointer to store the port number in
  1567. * @param path the buffer for the path
  1568. * @param path_size the size of the path buffer
  1569. * @param url the URL to split
  1570. */
  1571. void av_url_split(char *proto, int proto_size,
  1572. char *authorization, int authorization_size,
  1573. char *hostname, int hostname_size,
  1574. int *port_ptr,
  1575. char *path, int path_size,
  1576. const char *url);
  1577. /**
  1578. * @addtogroup lavf_encoding
  1579. * @{
  1580. */
  1581. /**
  1582. * Allocate the stream private data and write the stream header to
  1583. * an output media file.
  1584. *
  1585. * @param s Media file handle, must be allocated with avformat_alloc_context().
  1586. * Its oformat field must be set to the desired output format;
  1587. * Its pb field must be set to an already openened AVIOContext.
  1588. * @param options An AVDictionary filled with AVFormatContext and muxer-private options.
  1589. * On return this parameter will be destroyed and replaced with a dict containing
  1590. * options that were not found. May be NULL.
  1591. *
  1592. * @return 0 on success, negative AVERROR on failure.
  1593. *
  1594. * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
  1595. */
  1596. int avformat_write_header(AVFormatContext *s, AVDictionary **options);
  1597. #if FF_API_FORMAT_PARAMETERS
  1598. /**
  1599. * Allocate the stream private data and write the stream header to an
  1600. * output media file.
  1601. * @note: this sets stream time-bases, if possible to stream->codec->time_base
  1602. * but for some formats it might also be some other time base
  1603. *
  1604. * @param s media file handle
  1605. * @return 0 if OK, AVERROR_xxx on error
  1606. *
  1607. * @deprecated use avformat_write_header.
  1608. */
  1609. attribute_deprecated int av_write_header(AVFormatContext *s);
  1610. #endif
  1611. /**
  1612. * Write a packet to an output media file.
  1613. *
  1614. * The packet shall contain one audio or video frame.
  1615. * The packet must be correctly interleaved according to the container
  1616. * specification, if not then av_interleaved_write_frame must be used.
  1617. *
  1618. * @param s media file handle
  1619. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  1620. dts/pts, ...
  1621. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  1622. */
  1623. int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  1624. /**
  1625. * Write a packet to an output media file ensuring correct interleaving.
  1626. *
  1627. * The packet must contain one audio or video frame.
  1628. * If the packets are already correctly interleaved, the application should
  1629. * call av_write_frame() instead as it is slightly faster. It is also important
  1630. * to keep in mind that completely non-interleaved input will need huge amounts
  1631. * of memory to interleave with this, so it is preferable to interleave at the
  1632. * demuxer level.
  1633. *
  1634. * @param s media file handle
  1635. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  1636. dts/pts, ...
  1637. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  1638. */
  1639. int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
  1640. /**
  1641. * Interleave a packet per dts in an output media file.
  1642. *
  1643. * Packets with pkt->destruct == av_destruct_packet will be freed inside this
  1644. * function, so they cannot be used after it. Note that calling av_free_packet()
  1645. * on them is still safe.
  1646. *
  1647. * @param s media file handle
  1648. * @param out the interleaved packet will be output here
  1649. * @param pkt the input packet
  1650. * @param flush 1 if no further packets are available as input and all
  1651. * remaining packets should be output
  1652. * @return 1 if a packet was output, 0 if no packet could be output,
  1653. * < 0 if an error occurred
  1654. */
  1655. int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
  1656. AVPacket *pkt, int flush);
  1657. /**
  1658. * Write the stream trailer to an output media file and free the
  1659. * file private data.
  1660. *
  1661. * May only be called after a successful call to av_write_header.
  1662. *
  1663. * @param s media file handle
  1664. * @return 0 if OK, AVERROR_xxx on error
  1665. */
  1666. int av_write_trailer(AVFormatContext *s);
  1667. /**
  1668. * @}
  1669. */
  1670. /**
  1671. * Get timing information for the data currently output.
  1672. * The exact meaning of "currently output" depends on the format.
  1673. * It is mostly relevant for devices that have an internal buffer and/or
  1674. * work in real time.
  1675. * @param s media file handle
  1676. * @param stream stream in the media file
  1677. * @param dts[out] DTS of the last packet output for the stream, in stream
  1678. * time_base units
  1679. * @param wall[out] absolute time when that packet whas output,
  1680. * in microsecond
  1681. * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it
  1682. * Note: some formats or devices may not allow to measure dts and wall
  1683. * atomically.
  1684. */
  1685. int av_get_output_timestamp(struct AVFormatContext *s, int stream,
  1686. int64_t *dts, int64_t *wall);
  1687. #if FF_API_DUMP_FORMAT
  1688. /**
  1689. * @deprecated Deprecated in favor of av_dump_format().
  1690. */
  1691. attribute_deprecated void dump_format(AVFormatContext *ic,
  1692. int index,
  1693. const char *url,
  1694. int is_output);
  1695. #endif
  1696. void av_dump_format(AVFormatContext *ic,
  1697. int index,
  1698. const char *url,
  1699. int is_output);
  1700. #if FF_API_PARSE_DATE
  1701. /**
  1702. * Parse datestr and return a corresponding number of microseconds.
  1703. *
  1704. * @param datestr String representing a date or a duration.
  1705. * See av_parse_time() for the syntax of the provided string.
  1706. * @deprecated in favor of av_parse_time()
  1707. */
  1708. attribute_deprecated
  1709. int64_t parse_date(const char *datestr, int duration);
  1710. #endif
  1711. /**
  1712. * Get the current time in microseconds.
  1713. */
  1714. int64_t av_gettime(void);
  1715. #if FF_API_FIND_INFO_TAG
  1716. /**
  1717. * @deprecated use av_find_info_tag in libavutil instead.
  1718. */
  1719. attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  1720. #endif
  1721. /**
  1722. * Return in 'buf' the path with '%d' replaced by a number.
  1723. *
  1724. * Also handles the '%0nd' format where 'n' is the total number
  1725. * of digits and '%%'.
  1726. *
  1727. * @param buf destination buffer
  1728. * @param buf_size destination buffer size
  1729. * @param path numbered sequence string
  1730. * @param number frame number
  1731. * @return 0 if OK, -1 on format error
  1732. */
  1733. int av_get_frame_filename(char *buf, int buf_size,
  1734. const char *path, int number);
  1735. /**
  1736. * Check whether filename actually is a numbered sequence generator.
  1737. *
  1738. * @param filename possible numbered sequence string
  1739. * @return 1 if a valid numbered sequence string, 0 otherwise
  1740. */
  1741. int av_filename_number_test(const char *filename);
  1742. /**
  1743. * Generate an SDP for an RTP session.
  1744. *
  1745. * @param ac array of AVFormatContexts describing the RTP streams. If the
  1746. * array is composed by only one context, such context can contain
  1747. * multiple AVStreams (one AVStream per RTP stream). Otherwise,
  1748. * all the contexts in the array (an AVCodecContext per RTP stream)
  1749. * must contain only one AVStream.
  1750. * @param n_files number of AVCodecContexts contained in ac
  1751. * @param buf buffer where the SDP will be stored (must be allocated by
  1752. * the caller)
  1753. * @param size the size of the buffer
  1754. * @return 0 if OK, AVERROR_xxx on error
  1755. */
  1756. int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
  1757. #if FF_API_SDP_CREATE
  1758. attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
  1759. #endif
  1760. /**
  1761. * Return a positive value if the given filename has one of the given
  1762. * extensions, 0 otherwise.
  1763. *
  1764. * @param extensions a comma-separated list of filename extensions
  1765. */
  1766. int av_match_ext(const char *filename, const char *extensions);
  1767. /**
  1768. * Test if the given container can store a codec.
  1769. *
  1770. * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
  1771. *
  1772. * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
  1773. * A negative number if this information is not available.
  1774. */
  1775. int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance);
  1776. /**
  1777. * Get the AVClass for AVFormatContext. It can be used in combination with
  1778. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  1779. *
  1780. * @see av_opt_find().
  1781. */
  1782. const AVClass *avformat_get_class(void);
  1783. /**
  1784. * Do global initialization of network components. This is optional,
  1785. * but recommended, since it avoids the overhead of implicitly
  1786. * doing the setup for each session.
  1787. *
  1788. * Calling this function will become mandatory if using network
  1789. * protocols at some major version bump.
  1790. */
  1791. int avformat_network_init(void);
  1792. /**
  1793. * Undo the initialization done by avformat_network_init.
  1794. */
  1795. int avformat_network_deinit(void);
  1796. #endif /* AVFORMAT_AVFORMAT_H */