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.

1363 lines
49KB

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