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.

2018 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, do not read or
  617. * write from outside of libav*
  618. */
  619. struct AVPacketList *last_in_packet_buffer;
  620. #endif
  621. /**
  622. * Average framerate
  623. */
  624. AVRational avg_frame_rate;
  625. /*****************************************************************
  626. * All fields below this line are not part of the public API. They
  627. * may not be used outside of libavformat and can be changed and
  628. * removed at will.
  629. * New public fields should be added right above.
  630. *****************************************************************
  631. */
  632. /**
  633. * Number of frames that have been demuxed during av_find_stream_info()
  634. */
  635. int codec_info_nb_frames;
  636. /**
  637. * Stream Identifier
  638. * This is the MPEG-TS stream identifier +1
  639. * 0 means unknown
  640. */
  641. int stream_identifier;
  642. int64_t interleaver_chunk_size;
  643. int64_t interleaver_chunk_duration;
  644. /**
  645. * Stream information used internally by av_find_stream_info()
  646. */
  647. #define MAX_STD_TIMEBASES (60*12+5)
  648. struct {
  649. int64_t last_dts;
  650. int64_t duration_gcd;
  651. int duration_count;
  652. double duration_error[2][2][MAX_STD_TIMEBASES];
  653. int64_t codec_info_duration;
  654. int nb_decoded_frames;
  655. } *info;
  656. /**
  657. * flag to indicate that probing is requested
  658. * NOT PART OF PUBLIC API
  659. */
  660. int request_probe;
  661. #if !FF_API_REORDER_PRIVATE
  662. const uint8_t *cur_ptr;
  663. int cur_len;
  664. AVPacket cur_pkt;
  665. // Timestamp generation support:
  666. /**
  667. * Timestamp corresponding to the last dts sync point.
  668. *
  669. * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
  670. * a DTS is received from the underlying container. Otherwise set to
  671. * AV_NOPTS_VALUE by default.
  672. */
  673. int64_t reference_dts;
  674. int64_t first_dts;
  675. int64_t cur_dts;
  676. int last_IP_duration;
  677. int64_t last_IP_pts;
  678. /**
  679. * Number of packets to buffer for codec probing
  680. */
  681. #define MAX_PROBE_PACKETS 2500
  682. int probe_packets;
  683. /**
  684. * last packet in packet_buffer for this stream when muxing.
  685. */
  686. struct AVPacketList *last_in_packet_buffer;
  687. AVProbeData probe_data;
  688. #define MAX_REORDER_DELAY 16
  689. int64_t pts_buffer[MAX_REORDER_DELAY+1];
  690. /* av_read_frame() support */
  691. enum AVStreamParseType need_parsing;
  692. struct AVCodecParserContext *parser;
  693. AVIndexEntry *index_entries; /**< Only used if the format does not
  694. support seeking natively. */
  695. int nb_index_entries;
  696. unsigned int index_entries_allocated_size;
  697. int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
  698. #endif
  699. } AVStream;
  700. #define AV_PROGRAM_RUNNING 1
  701. /**
  702. * New fields can be added to the end with minor version bumps.
  703. * Removal, reordering and changes to existing fields require a major
  704. * version bump.
  705. * sizeof(AVProgram) must not be used outside libav*.
  706. */
  707. typedef struct AVProgram {
  708. int id;
  709. int flags;
  710. enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
  711. unsigned int *stream_index;
  712. unsigned int nb_stream_indexes;
  713. AVDictionary *metadata;
  714. int program_num;
  715. int pmt_pid;
  716. int pcr_pid;
  717. } AVProgram;
  718. #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
  719. (streams are added dynamically) */
  720. typedef struct AVChapter {
  721. int id; ///< unique ID to identify the chapter
  722. AVRational time_base; ///< time base in which the start/end timestamps are specified
  723. int64_t start, end; ///< chapter start/end time in time_base units
  724. AVDictionary *metadata;
  725. } AVChapter;
  726. /**
  727. * Format I/O context.
  728. * New fields can be added to the end with minor version bumps.
  729. * Removal, reordering and changes to existing fields require a major
  730. * version bump.
  731. * sizeof(AVFormatContext) must not be used outside libav*, use
  732. * avformat_alloc_context() to create an AVFormatContext.
  733. */
  734. typedef struct AVFormatContext {
  735. /**
  736. * A class for logging and AVOptions. Set by avformat_alloc_context().
  737. * Exports (de)muxer private options if they exist.
  738. */
  739. const AVClass *av_class;
  740. /**
  741. * Can only be iformat or oformat, not both at the same time.
  742. *
  743. * decoding: set by avformat_open_input().
  744. * encoding: set by the user.
  745. */
  746. struct AVInputFormat *iformat;
  747. struct AVOutputFormat *oformat;
  748. /**
  749. * Format private data. This is an AVOptions-enabled struct
  750. * if and only if iformat/oformat.priv_class is not NULL.
  751. */
  752. void *priv_data;
  753. /*
  754. * I/O context.
  755. *
  756. * decoding: either set by the user before avformat_open_input() (then
  757. * the user must close it manually) or set by avformat_open_input().
  758. * encoding: set by the user.
  759. *
  760. * Do NOT set this field if AVFMT_NOFILE flag is set in
  761. * iformat/oformat.flags. In such a case, the (de)muxer will handle
  762. * I/O in some other way and this field will be NULL.
  763. */
  764. AVIOContext *pb;
  765. /**
  766. * A list of all streams in the file. New streams are created with
  767. * avformat_new_stream().
  768. *
  769. * decoding: streams are created by libavformat in avformat_open_input().
  770. * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also
  771. * appear in av_read_frame().
  772. * encoding: streams are created by the user before avformat_write_header().
  773. */
  774. unsigned int nb_streams;
  775. AVStream **streams;
  776. char filename[1024]; /**< input or output filename */
  777. /* stream info */
  778. #if FF_API_TIMESTAMP
  779. /**
  780. * @deprecated use 'creation_time' metadata tag instead
  781. */
  782. attribute_deprecated int64_t timestamp;
  783. #endif
  784. int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
  785. #if FF_API_REORDER_PRIVATE
  786. /* private data for pts handling (do not modify directly). */
  787. /**
  788. * This buffer is only needed when packets were already buffered but
  789. * not decoded, for example to get the codec parameters in MPEG
  790. * streams.
  791. */
  792. struct AVPacketList *packet_buffer;
  793. #endif
  794. /**
  795. * Decoding: position of the first frame of the component, in
  796. * AV_TIME_BASE fractional seconds. NEVER set this value directly:
  797. * It is deduced from the AVStream values.
  798. */
  799. int64_t start_time;
  800. /**
  801. * Decoding: duration of the stream, in AV_TIME_BASE fractional
  802. * seconds. Only set this value if you know none of the individual stream
  803. * durations and also do not set any of them. This is deduced from the
  804. * AVStream values if not set.
  805. */
  806. int64_t duration;
  807. #if FF_API_FILESIZE
  808. /**
  809. * decoding: total file size, 0 if unknown
  810. */
  811. attribute_deprecated int64_t file_size;
  812. #endif
  813. /**
  814. * Decoding: total stream bitrate in bit/s, 0 if not
  815. * available. Never set it directly if the file_size and the
  816. * duration are known as FFmpeg can compute it automatically.
  817. */
  818. int bit_rate;
  819. #if FF_API_REORDER_PRIVATE
  820. /* av_read_frame() support */
  821. AVStream *cur_st;
  822. /* av_seek_frame() support */
  823. int64_t data_offset; /**< offset of the first packet */
  824. #endif
  825. #if FF_API_MUXRATE
  826. /**
  827. * use mpeg muxer private options instead
  828. */
  829. attribute_deprecated int mux_rate;
  830. #endif
  831. unsigned int packet_size;
  832. #if FF_API_PRELOAD
  833. attribute_deprecated int preload;
  834. #endif
  835. int max_delay;
  836. #if FF_API_LOOP_OUTPUT
  837. #define AVFMT_NOOUTPUTLOOP -1
  838. #define AVFMT_INFINITEOUTPUTLOOP 0
  839. /**
  840. * number of times to loop output in formats that support it
  841. *
  842. * @deprecated use the 'loop' private option in the gif muxer.
  843. */
  844. attribute_deprecated int loop_output;
  845. #endif
  846. int flags;
  847. #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
  848. #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
  849. #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
  850. #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
  851. #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
  852. #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
  853. #if FF_API_FLAG_RTP_HINT
  854. #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
  855. #endif
  856. #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
  857. #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
  858. #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
  859. #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
  860. #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)
  861. #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate.
  862. #if FF_API_LOOP_INPUT
  863. /**
  864. * @deprecated, use the 'loop' img2 demuxer private option.
  865. */
  866. attribute_deprecated int loop_input;
  867. #endif
  868. /**
  869. * decoding: size of data to probe; encoding: unused.
  870. */
  871. unsigned int probesize;
  872. /**
  873. * decoding: maximum time (in AV_TIME_BASE units) during which the input should
  874. * be analyzed in avformat_find_stream_info().
  875. */
  876. int max_analyze_duration;
  877. const uint8_t *key;
  878. int keylen;
  879. unsigned int nb_programs;
  880. AVProgram **programs;
  881. /**
  882. * Forced video codec_id.
  883. * Demuxing: Set by user.
  884. */
  885. enum CodecID video_codec_id;
  886. /**
  887. * Forced audio codec_id.
  888. * Demuxing: Set by user.
  889. */
  890. enum CodecID audio_codec_id;
  891. /**
  892. * Forced subtitle codec_id.
  893. * Demuxing: Set by user.
  894. */
  895. enum CodecID subtitle_codec_id;
  896. /**
  897. * Maximum amount of memory in bytes to use for the index of each stream.
  898. * If the index exceeds this size, entries will be discarded as
  899. * needed to maintain a smaller size. This can lead to slower or less
  900. * accurate seeking (depends on demuxer).
  901. * Demuxers for which a full in-memory index is mandatory will ignore
  902. * this.
  903. * muxing : unused
  904. * demuxing: set by user
  905. */
  906. unsigned int max_index_size;
  907. /**
  908. * Maximum amount of memory in bytes to use for buffering frames
  909. * obtained from realtime capture devices.
  910. */
  911. unsigned int max_picture_buffer;
  912. unsigned int nb_chapters;
  913. AVChapter **chapters;
  914. /**
  915. * Flags to enable debugging.
  916. */
  917. int debug;
  918. #define FF_FDEBUG_TS 0x0001
  919. #if FF_API_REORDER_PRIVATE
  920. /**
  921. * Raw packets from the demuxer, prior to parsing and decoding.
  922. * This buffer is used for buffering packets until the codec can
  923. * be identified, as parsing cannot be done without knowing the
  924. * codec.
  925. */
  926. struct AVPacketList *raw_packet_buffer;
  927. struct AVPacketList *raw_packet_buffer_end;
  928. struct AVPacketList *packet_buffer_end;
  929. #endif
  930. AVDictionary *metadata;
  931. #if FF_API_REORDER_PRIVATE
  932. /**
  933. * Remaining size available for raw_packet_buffer, in bytes.
  934. * NOT PART OF PUBLIC API
  935. */
  936. #define RAW_PACKET_BUFFER_SIZE 2500000
  937. int raw_packet_buffer_remaining_size;
  938. #endif
  939. /**
  940. * Start time of the stream in real world time, in microseconds
  941. * since the unix epoch (00:00 1st January 1970). That is, pts=0
  942. * in the stream was captured at this real world time.
  943. * - encoding: Set by user.
  944. * - decoding: Unused.
  945. */
  946. int64_t start_time_realtime;
  947. /**
  948. * decoding: number of frames used to probe fps
  949. */
  950. int fps_probe_size;
  951. /**
  952. * Error recognition; higher values will detect more errors but may
  953. * misdetect some more or less valid parts as errors.
  954. * - encoding: unused
  955. * - decoding: Set by user.
  956. */
  957. int error_recognition;
  958. /**
  959. * Custom interrupt callbacks for the I/O layer.
  960. *
  961. * decoding: set by the user before avformat_open_input().
  962. * encoding: set by the user before avformat_write_header()
  963. * (mainly useful for AVFMT_NOFILE formats). The callback
  964. * should also be passed to avio_open2() if it's used to
  965. * open the file.
  966. */
  967. AVIOInterruptCB interrupt_callback;
  968. /**
  969. * Transport stream id.
  970. * This will be moved into demuxer private options. Thus no API/ABI compatibility
  971. */
  972. int ts_id;
  973. /**
  974. * Audio preload in microseconds.
  975. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  976. * - encoding: Set by user via AVOptions (NO direct access)
  977. * - decoding: unused
  978. */
  979. int audio_preload;
  980. /**
  981. * Max chunk time in microseconds.
  982. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  983. * - encoding: Set by user via AVOptions (NO direct access)
  984. * - decoding: unused
  985. */
  986. int max_chunk_duration;
  987. /**
  988. * Max chunk size in bytes
  989. * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
  990. * - encoding: Set by user via AVOptions (NO direct access)
  991. * - decoding: unused
  992. */
  993. int max_chunk_size;
  994. /*****************************************************************
  995. * All fields below this line are not part of the public API. They
  996. * may not be used outside of libavformat and can be changed and
  997. * removed at will.
  998. * New public fields should be added right above.
  999. *****************************************************************
  1000. */
  1001. #if !FF_API_REORDER_PRIVATE
  1002. /**
  1003. * Raw packets from the demuxer, prior to parsing and decoding.
  1004. * This buffer is used for buffering packets until the codec can
  1005. * be identified, as parsing cannot be done without knowing the
  1006. * codec.
  1007. */
  1008. struct AVPacketList *raw_packet_buffer;
  1009. struct AVPacketList *raw_packet_buffer_end;
  1010. /**
  1011. * Remaining size available for raw_packet_buffer, in bytes.
  1012. */
  1013. #define RAW_PACKET_BUFFER_SIZE 2500000
  1014. int raw_packet_buffer_remaining_size;
  1015. /**
  1016. * This buffer is only needed when packets were already buffered but
  1017. * not decoded, for example to get the codec parameters in MPEG
  1018. * streams.
  1019. */
  1020. struct AVPacketList *packet_buffer;
  1021. struct AVPacketList *packet_buffer_end;
  1022. /* av_read_frame() support */
  1023. AVStream *cur_st;
  1024. /* av_seek_frame() support */
  1025. int64_t data_offset; /**< offset of the first packet */
  1026. #endif
  1027. } AVFormatContext;
  1028. typedef struct AVPacketList {
  1029. AVPacket pkt;
  1030. struct AVPacketList *next;
  1031. } AVPacketList;
  1032. /**
  1033. * If f is NULL, returns the first registered input format,
  1034. * if f is non-NULL, returns the next registered input format after f
  1035. * or NULL if f is the last one.
  1036. */
  1037. AVInputFormat *av_iformat_next(AVInputFormat *f);
  1038. /**
  1039. * If f is NULL, returns the first registered output format,
  1040. * if f is non-NULL, returns the next registered output format after f
  1041. * or NULL if f is the last one.
  1042. */
  1043. AVOutputFormat *av_oformat_next(AVOutputFormat *f);
  1044. #if FF_API_GUESS_IMG2_CODEC
  1045. attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename);
  1046. #endif
  1047. /* XXX: Use automatic init with either ELF sections or C file parser */
  1048. /* modules. */
  1049. /* utils.c */
  1050. void av_register_input_format(AVInputFormat *format);
  1051. void av_register_output_format(AVOutputFormat *format);
  1052. /**
  1053. * Return the output format in the list of registered output formats
  1054. * which best matches the provided parameters, or return NULL if
  1055. * there is no match.
  1056. *
  1057. * @param short_name if non-NULL checks if short_name matches with the
  1058. * names of the registered formats
  1059. * @param filename if non-NULL checks if filename terminates with the
  1060. * extensions of the registered formats
  1061. * @param mime_type if non-NULL checks if mime_type matches with the
  1062. * MIME type of the registered formats
  1063. */
  1064. AVOutputFormat *av_guess_format(const char *short_name,
  1065. const char *filename,
  1066. const char *mime_type);
  1067. /**
  1068. * Guess the codec ID based upon muxer and filename.
  1069. */
  1070. enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
  1071. const char *filename, const char *mime_type,
  1072. enum AVMediaType type);
  1073. /**
  1074. * Send a nice hexadecimal dump of a buffer to the specified file stream.
  1075. *
  1076. * @param f The file stream pointer where the dump should be sent to.
  1077. * @param buf buffer
  1078. * @param size buffer size
  1079. *
  1080. * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
  1081. */
  1082. void av_hex_dump(FILE *f, uint8_t *buf, int size);
  1083. /**
  1084. * Send a nice hexadecimal dump of a buffer to the log.
  1085. *
  1086. * @param avcl A pointer to an arbitrary struct of which the first field is a
  1087. * pointer to an AVClass struct.
  1088. * @param level The importance level of the message, lower values signifying
  1089. * higher importance.
  1090. * @param buf buffer
  1091. * @param size buffer size
  1092. *
  1093. * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
  1094. */
  1095. void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
  1096. /**
  1097. * Send a nice dump of a packet to the specified file stream.
  1098. *
  1099. * @param f The file stream pointer where the dump should be sent to.
  1100. * @param pkt packet to dump
  1101. * @param dump_payload True if the payload must be displayed, too.
  1102. * @param st AVStream that the packet belongs to
  1103. */
  1104. void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
  1105. /**
  1106. * Send a nice dump of a packet to the log.
  1107. *
  1108. * @param avcl A pointer to an arbitrary struct of which the first field is a
  1109. * pointer to an AVClass struct.
  1110. * @param level The importance level of the message, lower values signifying
  1111. * higher importance.
  1112. * @param pkt packet to dump
  1113. * @param dump_payload True if the payload must be displayed, too.
  1114. * @param st AVStream that the packet belongs to
  1115. */
  1116. void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
  1117. AVStream *st);
  1118. #if FF_API_PKT_DUMP
  1119. attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  1120. attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
  1121. int dump_payload);
  1122. #endif
  1123. /**
  1124. * Initialize libavformat and register all the muxers, demuxers and
  1125. * protocols. If you do not call this function, then you can select
  1126. * exactly which formats you want to support.
  1127. *
  1128. * @see av_register_input_format()
  1129. * @see av_register_output_format()
  1130. * @see av_register_protocol()
  1131. */
  1132. void av_register_all(void);
  1133. /**
  1134. * Get the CodecID for the given codec tag tag.
  1135. * If no codec id is found returns CODEC_ID_NONE.
  1136. *
  1137. * @param tags list of supported codec_id-codec_tag pairs, as stored
  1138. * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
  1139. */
  1140. enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
  1141. /**
  1142. * Get the codec tag for the given codec id id.
  1143. * If no codec tag is found returns 0.
  1144. *
  1145. * @param tags list of supported codec_id-codec_tag pairs, as stored
  1146. * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
  1147. */
  1148. unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
  1149. /**
  1150. * Allocate an AVFormatContext.
  1151. * avformat_free_context() can be used to free the context and everything
  1152. * allocated by the framework within it.
  1153. */
  1154. AVFormatContext *avformat_alloc_context(void);
  1155. #if FF_API_ALLOC_OUTPUT_CONTEXT
  1156. /**
  1157. * @deprecated deprecated in favor of avformat_alloc_output_context2()
  1158. */
  1159. attribute_deprecated
  1160. AVFormatContext *avformat_alloc_output_context(const char *format,
  1161. AVOutputFormat *oformat,
  1162. const char *filename);
  1163. #endif
  1164. /**
  1165. * Allocate an AVFormatContext for an output format.
  1166. * avformat_free_context() can be used to free the context and
  1167. * everything allocated by the framework within it.
  1168. *
  1169. * @param *ctx is set to the created format context, or to NULL in
  1170. * case of failure
  1171. * @param oformat format to use for allocating the context, if NULL
  1172. * format_name and filename are used instead
  1173. * @param format_name the name of output format to use for allocating the
  1174. * context, if NULL filename is used instead
  1175. * @param filename the name of the filename to use for allocating the
  1176. * context, may be NULL
  1177. * @return >= 0 in case of success, a negative AVERROR code in case of
  1178. * failure
  1179. */
  1180. int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat,
  1181. const char *format_name, const char *filename);
  1182. /**
  1183. * @addtogroup lavf_decoding
  1184. * @{
  1185. */
  1186. /**
  1187. * Find AVInputFormat based on the short name of the input format.
  1188. */
  1189. AVInputFormat *av_find_input_format(const char *short_name);
  1190. /**
  1191. * Guess the file format.
  1192. *
  1193. * @param is_opened Whether the file is already opened; determines whether
  1194. * demuxers with or without AVFMT_NOFILE are probed.
  1195. */
  1196. AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
  1197. /**
  1198. * Guess the file format.
  1199. *
  1200. * @param is_opened Whether the file is already opened; determines whether
  1201. * demuxers with or without AVFMT_NOFILE are probed.
  1202. * @param score_max A probe score larger that this is required to accept a
  1203. * detection, the variable is set to the actual detection
  1204. * score afterwards.
  1205. * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended
  1206. * to retry with a larger probe buffer.
  1207. */
  1208. AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
  1209. /**
  1210. * Guess the file format.
  1211. *
  1212. * @param is_opened Whether the file is already opened; determines whether
  1213. * demuxers with or without AVFMT_NOFILE are probed.
  1214. * @param score_ret The score of the best detection.
  1215. */
  1216. AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret);
  1217. /**
  1218. * Probe a bytestream to determine the input format. Each time a probe returns
  1219. * with a score that is too low, the probe buffer size is increased and another
  1220. * attempt is made. When the maximum probe size is reached, the input format
  1221. * with the highest score is returned.
  1222. *
  1223. * @param pb the bytestream to probe
  1224. * @param fmt the input format is put here
  1225. * @param filename the filename of the stream
  1226. * @param logctx the log context
  1227. * @param offset the offset within the bytestream to probe from
  1228. * @param max_probe_size the maximum probe buffer size (zero for default)
  1229. * @return 0 in case of success, a negative value corresponding to an
  1230. * AVERROR code otherwise
  1231. */
  1232. int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
  1233. const char *filename, void *logctx,
  1234. unsigned int offset, unsigned int max_probe_size);
  1235. #if FF_API_FORMAT_PARAMETERS
  1236. /**
  1237. * Allocate all the structures needed to read an input stream.
  1238. * This does not open the needed codecs for decoding the stream[s].
  1239. * @deprecated use avformat_open_input instead.
  1240. */
  1241. attribute_deprecated int av_open_input_stream(AVFormatContext **ic_ptr,
  1242. AVIOContext *pb, const char *filename,
  1243. AVInputFormat *fmt, AVFormatParameters *ap);
  1244. /**
  1245. * Open a media file as input. The codecs are not opened. Only the file
  1246. * header (if present) is read.
  1247. *
  1248. * @param ic_ptr The opened media file handle is put here.
  1249. * @param filename filename to open
  1250. * @param fmt If non-NULL, force the file format to use.
  1251. * @param buf_size optional buffer size (zero if default is OK)
  1252. * @param ap Additional parameters needed when opening the file
  1253. * (NULL if default).
  1254. * @return 0 if OK, AVERROR_xxx otherwise
  1255. *
  1256. * @deprecated use avformat_open_input instead.
  1257. */
  1258. attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  1259. AVInputFormat *fmt,
  1260. int buf_size,
  1261. AVFormatParameters *ap);
  1262. #endif
  1263. /**
  1264. * Open an input stream and read the header. The codecs are not opened.
  1265. * The stream must be closed with av_close_input_file().
  1266. *
  1267. * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
  1268. * May be a pointer to NULL, in which case an AVFormatContext is allocated by this
  1269. * function and written into ps.
  1270. * Note that a user-supplied AVFormatContext will be freed on failure.
  1271. * @param filename Name of the stream to open.
  1272. * @param fmt If non-NULL, this parameter forces a specific input format.
  1273. * Otherwise the format is autodetected.
  1274. * @param options A dictionary filled with AVFormatContext and demuxer-private options.
  1275. * On return this parameter will be destroyed and replaced with a dict containing
  1276. * options that were not found. May be NULL.
  1277. *
  1278. * @return 0 on success, a negative AVERROR on failure.
  1279. *
  1280. * @note If you want to use custom IO, preallocate the format context and set its pb field.
  1281. */
  1282. int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
  1283. int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap);
  1284. #if FF_API_FORMAT_PARAMETERS
  1285. /**
  1286. * Read packets of a media file to get stream information. This
  1287. * is useful for file formats with no headers such as MPEG. This
  1288. * function also computes the real framerate in case of MPEG-2 repeat
  1289. * frame mode.
  1290. * The logical file position is not changed by this function;
  1291. * examined packets may be buffered for later processing.
  1292. *
  1293. * @param ic media file handle
  1294. * @return >=0 if OK, AVERROR_xxx on error
  1295. * @todo Let the user decide somehow what information is needed so that
  1296. * we do not waste time getting stuff the user does not need.
  1297. *
  1298. * @deprecated use avformat_find_stream_info.
  1299. */
  1300. attribute_deprecated
  1301. int av_find_stream_info(AVFormatContext *ic);
  1302. #endif
  1303. /**
  1304. * Read packets of a media file to get stream information. This
  1305. * is useful for file formats with no headers such as MPEG. This
  1306. * function also computes the real framerate in case of MPEG-2 repeat
  1307. * frame mode.
  1308. * The logical file position is not changed by this function;
  1309. * examined packets may be buffered for later processing.
  1310. *
  1311. * @param ic media file handle
  1312. * @param options If non-NULL, an ic.nb_streams long array of pointers to
  1313. * dictionaries, where i-th member contains options for
  1314. * codec corresponding to i-th stream.
  1315. * On return each dictionary will be filled with options that were not found.
  1316. * @return >=0 if OK, AVERROR_xxx on error
  1317. *
  1318. * @note this function isn't guaranteed to open all the codecs, so
  1319. * options being non-empty at return is a perfectly normal behavior.
  1320. *
  1321. * @todo Let the user decide somehow what information is needed so that
  1322. * we do not waste time getting stuff the user does not need.
  1323. */
  1324. int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
  1325. /**
  1326. * Find the programs which belong to a given stream.
  1327. *
  1328. * @param ic media file handle
  1329. * @param last the last found program, the search will start after this
  1330. * program, or from the beginning if it is NULL
  1331. * @param s stream index
  1332. * @return the next program which belongs to s, NULL if no program is found or
  1333. * the last program is not among the programs of ic.
  1334. */
  1335. AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);
  1336. /**
  1337. * Find the "best" stream in the file.
  1338. * The best stream is determined according to various heuristics as the most
  1339. * likely to be what the user expects.
  1340. * If the decoder parameter is non-NULL, av_find_best_stream will find the
  1341. * default decoder for the stream's codec; streams for which no decoder can
  1342. * be found are ignored.
  1343. *
  1344. * @param ic media file handle
  1345. * @param type stream type: video, audio, subtitles, etc.
  1346. * @param wanted_stream_nb user-requested stream number,
  1347. * or -1 for automatic selection
  1348. * @param related_stream try to find a stream related (eg. in the same
  1349. * program) to this one, or -1 if none
  1350. * @param decoder_ret if non-NULL, returns the decoder for the
  1351. * selected stream
  1352. * @param flags flags; none are currently defined
  1353. * @return the non-negative stream number in case of success,
  1354. * AVERROR_STREAM_NOT_FOUND if no stream with the requested type
  1355. * could be found,
  1356. * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
  1357. * @note If av_find_best_stream returns successfully and decoder_ret is not
  1358. * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
  1359. */
  1360. int av_find_best_stream(AVFormatContext *ic,
  1361. enum AVMediaType type,
  1362. int wanted_stream_nb,
  1363. int related_stream,
  1364. AVCodec **decoder_ret,
  1365. int flags);
  1366. /**
  1367. * Read a transport packet from a media file.
  1368. *
  1369. * This function is obsolete and should never be used.
  1370. * Use av_read_frame() instead.
  1371. *
  1372. * @param s media file handle
  1373. * @param pkt is filled
  1374. * @return 0 if OK, AVERROR_xxx on error
  1375. */
  1376. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  1377. /**
  1378. * Return the next frame of a stream.
  1379. * This function returns what is stored in the file, and does not validate
  1380. * that what is there are valid frames for the decoder. It will split what is
  1381. * stored in the file into frames and return one for each call. It will not
  1382. * omit invalid data between valid frames so as to give the decoder the maximum
  1383. * information possible for decoding.
  1384. *
  1385. * The returned packet is valid
  1386. * until the next av_read_frame() or until av_close_input_file() and
  1387. * must be freed with av_free_packet. For video, the packet contains
  1388. * exactly one frame. For audio, it contains an integer number of
  1389. * frames if each frame has a known fixed size (e.g. PCM or ADPCM
  1390. * data). If the audio frames have a variable size (e.g. MPEG audio),
  1391. * then it contains one frame.
  1392. *
  1393. * pkt->pts, pkt->dts and pkt->duration are always set to correct
  1394. * values in AVStream.time_base units (and guessed if the format cannot
  1395. * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
  1396. * has B-frames, so it is better to rely on pkt->dts if you do not
  1397. * decompress the payload.
  1398. *
  1399. * @return 0 if OK, < 0 on error or end of file
  1400. */
  1401. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  1402. /**
  1403. * Seek to the keyframe at timestamp.
  1404. * 'timestamp' in 'stream_index'.
  1405. * @param stream_index If stream_index is (-1), a default
  1406. * stream is selected, and timestamp is automatically converted
  1407. * from AV_TIME_BASE units to the stream specific time_base.
  1408. * @param timestamp Timestamp in AVStream.time_base units
  1409. * or, if no stream is specified, in AV_TIME_BASE units.
  1410. * @param flags flags which select direction and seeking mode
  1411. * @return >= 0 on success
  1412. */
  1413. int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
  1414. int flags);
  1415. /**
  1416. * Seek to timestamp ts.
  1417. * Seeking will be done so that the point from which all active streams
  1418. * can be presented successfully will be closest to ts and within min/max_ts.
  1419. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
  1420. *
  1421. * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
  1422. * are the file position (this may not be supported by all demuxers).
  1423. * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
  1424. * in the stream with stream_index (this may not be supported by all demuxers).
  1425. * Otherwise all timestamps are in units of the stream selected by stream_index
  1426. * or if stream_index is -1, in AV_TIME_BASE units.
  1427. * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
  1428. * keyframes (this may not be supported by all demuxers).
  1429. *
  1430. * @param stream_index index of the stream which is used as time base reference
  1431. * @param min_ts smallest acceptable timestamp
  1432. * @param ts target timestamp
  1433. * @param max_ts largest acceptable timestamp
  1434. * @param flags flags
  1435. * @return >=0 on success, error code otherwise
  1436. *
  1437. * @note This is part of the new seek API which is still under construction.
  1438. * Thus do not use this yet. It may change at any time, do not expect
  1439. * ABI compatibility yet!
  1440. */
  1441. int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
  1442. /**
  1443. * Start playing a network-based stream (e.g. RTSP stream) at the
  1444. * current position.
  1445. */
  1446. int av_read_play(AVFormatContext *s);
  1447. /**
  1448. * Pause a network-based stream (e.g. RTSP stream).
  1449. *
  1450. * Use av_read_play() to resume it.
  1451. */
  1452. int av_read_pause(AVFormatContext *s);
  1453. /**
  1454. * Free a AVFormatContext allocated by av_open_input_stream.
  1455. * @param s context to free
  1456. */
  1457. void av_close_input_stream(AVFormatContext *s);
  1458. /**
  1459. * Close a media file (but not its codecs).
  1460. *
  1461. * @param s media file handle
  1462. */
  1463. void av_close_input_file(AVFormatContext *s);
  1464. /**
  1465. * @}
  1466. */
  1467. /**
  1468. * Free an AVFormatContext and all its streams.
  1469. * @param s context to free
  1470. */
  1471. void avformat_free_context(AVFormatContext *s);
  1472. #if FF_API_NEW_STREAM
  1473. /**
  1474. * Add a new stream to a media file.
  1475. *
  1476. * Can only be called in the read_header() function. If the flag
  1477. * AVFMTCTX_NOHEADER is in the format context, then new streams
  1478. * can be added in read_packet too.
  1479. *
  1480. * @param s media file handle
  1481. * @param id file-format-dependent stream ID
  1482. */
  1483. attribute_deprecated
  1484. AVStream *av_new_stream(AVFormatContext *s, int id);
  1485. #endif
  1486. /**
  1487. * Add a new stream to a media file.
  1488. *
  1489. * When demuxing, it is called by the demuxer in read_header(). If the
  1490. * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
  1491. * be called in read_packet().
  1492. *
  1493. * When muxing, should be called by the user before avformat_write_header().
  1494. *
  1495. * @param c If non-NULL, the AVCodecContext corresponding to the new stream
  1496. * will be initialized to use this codec. This is needed for e.g. codec-specific
  1497. * defaults to be set, so codec should be provided if it is known.
  1498. *
  1499. * @return newly created stream or NULL on error.
  1500. */
  1501. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
  1502. AVProgram *av_new_program(AVFormatContext *s, int id);
  1503. #if FF_API_SET_PTS_INFO
  1504. /**
  1505. * @deprecated this function is not supposed to be called outside of lavf
  1506. */
  1507. attribute_deprecated
  1508. void av_set_pts_info(AVStream *s, int pts_wrap_bits,
  1509. unsigned int pts_num, unsigned int pts_den);
  1510. #endif
  1511. #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
  1512. #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
  1513. #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
  1514. #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
  1515. int av_find_default_stream_index(AVFormatContext *s);
  1516. /**
  1517. * Get the index for a specific timestamp.
  1518. * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
  1519. * to the timestamp which is <= the requested one, if backward
  1520. * is 0, then it will be >=
  1521. * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
  1522. * @return < 0 if no such timestamp could be found
  1523. */
  1524. int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  1525. /**
  1526. * Add an index entry into a sorted list. Update the entry if the list
  1527. * already contains it.
  1528. *
  1529. * @param timestamp timestamp in the time base of the given stream
  1530. */
  1531. int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
  1532. int size, int distance, int flags);
  1533. #if FF_API_SEEK_PUBLIC
  1534. attribute_deprecated
  1535. int av_seek_frame_binary(AVFormatContext *s, int stream_index,
  1536. int64_t target_ts, int flags);
  1537. attribute_deprecated
  1538. void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
  1539. attribute_deprecated
  1540. int64_t av_gen_search(AVFormatContext *s, int stream_index,
  1541. int64_t target_ts, int64_t pos_min,
  1542. int64_t pos_max, int64_t pos_limit,
  1543. int64_t ts_min, int64_t ts_max,
  1544. int flags, int64_t *ts_ret,
  1545. int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
  1546. #endif
  1547. #if FF_API_FORMAT_PARAMETERS
  1548. /**
  1549. * @deprecated pass the options to avformat_write_header directly.
  1550. */
  1551. attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
  1552. #endif
  1553. /**
  1554. * Split a URL string into components.
  1555. *
  1556. * The pointers to buffers for storing individual components may be null,
  1557. * in order to ignore that component. Buffers for components not found are
  1558. * set to empty strings. If the port is not found, it is set to a negative
  1559. * value.
  1560. *
  1561. * @param proto the buffer for the protocol
  1562. * @param proto_size the size of the proto buffer
  1563. * @param authorization the buffer for the authorization
  1564. * @param authorization_size the size of the authorization buffer
  1565. * @param hostname the buffer for the host name
  1566. * @param hostname_size the size of the hostname buffer
  1567. * @param port_ptr a pointer to store the port number in
  1568. * @param path the buffer for the path
  1569. * @param path_size the size of the path buffer
  1570. * @param url the URL to split
  1571. */
  1572. void av_url_split(char *proto, int proto_size,
  1573. char *authorization, int authorization_size,
  1574. char *hostname, int hostname_size,
  1575. int *port_ptr,
  1576. char *path, int path_size,
  1577. const char *url);
  1578. /**
  1579. * @addtogroup lavf_encoding
  1580. * @{
  1581. */
  1582. /**
  1583. * Allocate the stream private data and write the stream header to
  1584. * an output media file.
  1585. *
  1586. * @param s Media file handle, must be allocated with avformat_alloc_context().
  1587. * Its oformat field must be set to the desired output format;
  1588. * Its pb field must be set to an already openened AVIOContext.
  1589. * @param options An AVDictionary filled with AVFormatContext and muxer-private options.
  1590. * On return this parameter will be destroyed and replaced with a dict containing
  1591. * options that were not found. May be NULL.
  1592. *
  1593. * @return 0 on success, negative AVERROR on failure.
  1594. *
  1595. * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
  1596. */
  1597. int avformat_write_header(AVFormatContext *s, AVDictionary **options);
  1598. #if FF_API_FORMAT_PARAMETERS
  1599. /**
  1600. * Allocate the stream private data and write the stream header to an
  1601. * output media file.
  1602. * @note: this sets stream time-bases, if possible to stream->codec->time_base
  1603. * but for some formats it might also be some other time base
  1604. *
  1605. * @param s media file handle
  1606. * @return 0 if OK, AVERROR_xxx on error
  1607. *
  1608. * @deprecated use avformat_write_header.
  1609. */
  1610. attribute_deprecated int av_write_header(AVFormatContext *s);
  1611. #endif
  1612. /**
  1613. * Write a packet to an output media file.
  1614. *
  1615. * The packet shall contain one audio or video frame.
  1616. * The packet must be correctly interleaved according to the container
  1617. * specification, if not then av_interleaved_write_frame must be used.
  1618. *
  1619. * @param s media file handle
  1620. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  1621. dts/pts, ...
  1622. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  1623. */
  1624. int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  1625. /**
  1626. * Write a packet to an output media file ensuring correct interleaving.
  1627. *
  1628. * The packet must contain one audio or video frame.
  1629. * If the packets are already correctly interleaved, the application should
  1630. * call av_write_frame() instead as it is slightly faster. It is also important
  1631. * to keep in mind that completely non-interleaved input will need huge amounts
  1632. * of memory to interleave with this, so it is preferable to interleave at the
  1633. * demuxer level.
  1634. *
  1635. * @param s media file handle
  1636. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  1637. dts/pts, ...
  1638. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  1639. */
  1640. int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
  1641. /**
  1642. * Interleave a packet per dts in an output media file.
  1643. *
  1644. * Packets with pkt->destruct == av_destruct_packet will be freed inside this
  1645. * function, so they cannot be used after it. Note that calling av_free_packet()
  1646. * on them is still safe.
  1647. *
  1648. * @param s media file handle
  1649. * @param out the interleaved packet will be output here
  1650. * @param pkt the input packet
  1651. * @param flush 1 if no further packets are available as input and all
  1652. * remaining packets should be output
  1653. * @return 1 if a packet was output, 0 if no packet could be output,
  1654. * < 0 if an error occurred
  1655. */
  1656. int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
  1657. AVPacket *pkt, int flush);
  1658. /**
  1659. * Write the stream trailer to an output media file and free the
  1660. * file private data.
  1661. *
  1662. * May only be called after a successful call to av_write_header.
  1663. *
  1664. * @param s media file handle
  1665. * @return 0 if OK, AVERROR_xxx on error
  1666. */
  1667. int av_write_trailer(AVFormatContext *s);
  1668. /**
  1669. * @}
  1670. */
  1671. /**
  1672. * Get timing information for the data currently output.
  1673. * The exact meaning of "currently output" depends on the format.
  1674. * It is mostly relevant for devices that have an internal buffer and/or
  1675. * work in real time.
  1676. * @param s media file handle
  1677. * @param stream stream in the media file
  1678. * @param dts[out] DTS of the last packet output for the stream, in stream
  1679. * time_base units
  1680. * @param wall[out] absolute time when that packet whas output,
  1681. * in microsecond
  1682. * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it
  1683. * Note: some formats or devices may not allow to measure dts and wall
  1684. * atomically.
  1685. */
  1686. int av_get_output_timestamp(struct AVFormatContext *s, int stream,
  1687. int64_t *dts, int64_t *wall);
  1688. #if FF_API_DUMP_FORMAT
  1689. /**
  1690. * @deprecated Deprecated in favor of av_dump_format().
  1691. */
  1692. attribute_deprecated void dump_format(AVFormatContext *ic,
  1693. int index,
  1694. const char *url,
  1695. int is_output);
  1696. #endif
  1697. void av_dump_format(AVFormatContext *ic,
  1698. int index,
  1699. const char *url,
  1700. int is_output);
  1701. #if FF_API_PARSE_DATE
  1702. /**
  1703. * Parse datestr and return a corresponding number of microseconds.
  1704. *
  1705. * @param datestr String representing a date or a duration.
  1706. * See av_parse_time() for the syntax of the provided string.
  1707. * @deprecated in favor of av_parse_time()
  1708. */
  1709. attribute_deprecated
  1710. int64_t parse_date(const char *datestr, int duration);
  1711. #endif
  1712. /**
  1713. * Get the current time in microseconds.
  1714. */
  1715. int64_t av_gettime(void);
  1716. #if FF_API_FIND_INFO_TAG
  1717. /**
  1718. * @deprecated use av_find_info_tag in libavutil instead.
  1719. */
  1720. attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  1721. #endif
  1722. /**
  1723. * Return in 'buf' the path with '%d' replaced by a number.
  1724. *
  1725. * Also handles the '%0nd' format where 'n' is the total number
  1726. * of digits and '%%'.
  1727. *
  1728. * @param buf destination buffer
  1729. * @param buf_size destination buffer size
  1730. * @param path numbered sequence string
  1731. * @param number frame number
  1732. * @return 0 if OK, -1 on format error
  1733. */
  1734. int av_get_frame_filename(char *buf, int buf_size,
  1735. const char *path, int number);
  1736. /**
  1737. * Check whether filename actually is a numbered sequence generator.
  1738. *
  1739. * @param filename possible numbered sequence string
  1740. * @return 1 if a valid numbered sequence string, 0 otherwise
  1741. */
  1742. int av_filename_number_test(const char *filename);
  1743. /**
  1744. * Generate an SDP for an RTP session.
  1745. *
  1746. * @param ac array of AVFormatContexts describing the RTP streams. If the
  1747. * array is composed by only one context, such context can contain
  1748. * multiple AVStreams (one AVStream per RTP stream). Otherwise,
  1749. * all the contexts in the array (an AVCodecContext per RTP stream)
  1750. * must contain only one AVStream.
  1751. * @param n_files number of AVCodecContexts contained in ac
  1752. * @param buf buffer where the SDP will be stored (must be allocated by
  1753. * the caller)
  1754. * @param size the size of the buffer
  1755. * @return 0 if OK, AVERROR_xxx on error
  1756. */
  1757. int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
  1758. #if FF_API_SDP_CREATE
  1759. attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
  1760. #endif
  1761. /**
  1762. * Return a positive value if the given filename has one of the given
  1763. * extensions, 0 otherwise.
  1764. *
  1765. * @param extensions a comma-separated list of filename extensions
  1766. */
  1767. int av_match_ext(const char *filename, const char *extensions);
  1768. /**
  1769. * Test if the given container can store a codec.
  1770. *
  1771. * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
  1772. *
  1773. * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
  1774. * A negative number if this information is not available.
  1775. */
  1776. int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance);
  1777. /**
  1778. * Get the AVClass for AVFormatContext. It can be used in combination with
  1779. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  1780. *
  1781. * @see av_opt_find().
  1782. */
  1783. const AVClass *avformat_get_class(void);
  1784. /**
  1785. * Do global initialization of network components. This is optional,
  1786. * but recommended, since it avoids the overhead of implicitly
  1787. * doing the setup for each session.
  1788. *
  1789. * Calling this function will become mandatory if using network
  1790. * protocols at some major version bump.
  1791. */
  1792. int avformat_network_init(void);
  1793. /**
  1794. * Undo the initialization done by avformat_network_init.
  1795. */
  1796. int avformat_network_deinit(void);
  1797. #endif /* AVFORMAT_AVFORMAT_H */