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.

1318 lines
46KB

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