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.

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