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.

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