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.

1324 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. #define MAX_STREAMS 20
  452. /**
  453. * Format I/O context.
  454. * New fields can be added to the end with minor version bumps.
  455. * Removal, reordering and changes to existing fields require a major
  456. * version bump.
  457. * sizeof(AVFormatContext) must not be used outside libav*.
  458. */
  459. typedef struct AVFormatContext {
  460. const AVClass *av_class; /**< Set by avformat_alloc_context. */
  461. /* Can only be iformat or oformat, not both at the same time. */
  462. struct AVInputFormat *iformat;
  463. struct AVOutputFormat *oformat;
  464. void *priv_data;
  465. ByteIOContext *pb;
  466. unsigned int nb_streams;
  467. AVStream *streams[MAX_STREAMS];
  468. char filename[1024]; /**< input or output filename */
  469. /* stream info */
  470. int64_t timestamp;
  471. #if LIBAVFORMAT_VERSION_INT < (53<<16)
  472. char title[512];
  473. char author[512];
  474. char copyright[512];
  475. char comment[512];
  476. char album[512];
  477. int year; /**< ID3 year, 0 if none */
  478. int track; /**< track number, 0 if none */
  479. char genre[32]; /**< ID3 genre */
  480. #endif
  481. int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
  482. /* private data for pts handling (do not modify directly). */
  483. /** This buffer is only needed when packets were already buffered but
  484. not decoded, for example to get the codec parameters in MPEG
  485. streams. */
  486. struct AVPacketList *packet_buffer;
  487. /** Decoding: position of the first frame of the component, in
  488. AV_TIME_BASE fractional seconds. NEVER set this value directly:
  489. It is deduced from the AVStream values. */
  490. int64_t start_time;
  491. /** Decoding: duration of the stream, in AV_TIME_BASE fractional
  492. seconds. NEVER set this value directly: it is deduced from the
  493. AVStream values. */
  494. int64_t duration;
  495. /** decoding: total file size, 0 if unknown */
  496. int64_t file_size;
  497. /** Decoding: total stream bitrate in bit/s, 0 if not
  498. available. Never set it directly if the file_size and the
  499. duration are known as FFmpeg can compute it automatically. */
  500. int bit_rate;
  501. /* av_read_frame() support */
  502. AVStream *cur_st;
  503. #if LIBAVFORMAT_VERSION_INT < (53<<16)
  504. const uint8_t *cur_ptr_deprecated;
  505. int cur_len_deprecated;
  506. AVPacket cur_pkt_deprecated;
  507. #endif
  508. /* av_seek_frame() support */
  509. int64_t data_offset; /** offset of the first packet */
  510. int index_built;
  511. int mux_rate;
  512. unsigned int packet_size;
  513. int preload;
  514. int max_delay;
  515. #define AVFMT_NOOUTPUTLOOP -1
  516. #define AVFMT_INFINITEOUTPUTLOOP 0
  517. /** number of times to loop output in formats that support it */
  518. int loop_output;
  519. int flags;
  520. #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
  521. #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
  522. #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
  523. int loop_input;
  524. /** decoding: size of data to probe; encoding: unused. */
  525. unsigned int probesize;
  526. /**
  527. * Maximum time (in AV_TIME_BASE units) during which the input should
  528. * be analyzed in av_find_stream_info().
  529. */
  530. int max_analyze_duration;
  531. const uint8_t *key;
  532. int keylen;
  533. unsigned int nb_programs;
  534. AVProgram **programs;
  535. /**
  536. * Forced video codec_id.
  537. * Demuxing: Set by user.
  538. */
  539. enum CodecID video_codec_id;
  540. /**
  541. * Forced audio codec_id.
  542. * Demuxing: Set by user.
  543. */
  544. enum CodecID audio_codec_id;
  545. /**
  546. * Forced subtitle codec_id.
  547. * Demuxing: Set by user.
  548. */
  549. enum CodecID subtitle_codec_id;
  550. /**
  551. * Maximum amount of memory in bytes to use for the index of each stream.
  552. * If the index exceeds this size, entries will be discarded as
  553. * needed to maintain a smaller size. This can lead to slower or less
  554. * accurate seeking (depends on demuxer).
  555. * Demuxers for which a full in-memory index is mandatory will ignore
  556. * this.
  557. * muxing : unused
  558. * demuxing: set by user
  559. */
  560. unsigned int max_index_size;
  561. /**
  562. * Maximum amount of memory in bytes to use for buffering frames
  563. * obtained from realtime capture devices.
  564. */
  565. unsigned int max_picture_buffer;
  566. unsigned int nb_chapters;
  567. AVChapter **chapters;
  568. /**
  569. * Flags to enable debugging.
  570. */
  571. int debug;
  572. #define FF_FDEBUG_TS 0x0001
  573. /**
  574. * Raw packets from the demuxer, prior to parsing and decoding.
  575. * This buffer is used for buffering packets until the codec can
  576. * be identified, as parsing cannot be done without knowing the
  577. * codec.
  578. */
  579. struct AVPacketList *raw_packet_buffer;
  580. struct AVPacketList *raw_packet_buffer_end;
  581. struct AVPacketList *packet_buffer_end;
  582. AVMetadata *metadata;
  583. /**
  584. * Remaining size available for raw_packet_buffer, in bytes.
  585. * NOT PART OF PUBLIC API
  586. */
  587. #define RAW_PACKET_BUFFER_SIZE 2500000
  588. int raw_packet_buffer_remaining_size;
  589. } AVFormatContext;
  590. typedef struct AVPacketList {
  591. AVPacket pkt;
  592. struct AVPacketList *next;
  593. } AVPacketList;
  594. #if LIBAVFORMAT_VERSION_INT < (53<<16)
  595. extern AVInputFormat *first_iformat;
  596. extern AVOutputFormat *first_oformat;
  597. #endif
  598. /**
  599. * If f is NULL, returns the first registered input format,
  600. * if f is non-NULL, returns the next registered input format after f
  601. * or NULL if f is the last one.
  602. */
  603. AVInputFormat *av_iformat_next(AVInputFormat *f);
  604. /**
  605. * If f is NULL, returns the first registered output format,
  606. * if f is non-NULL, returns the next registered output format after f
  607. * or NULL if f is the last one.
  608. */
  609. AVOutputFormat *av_oformat_next(AVOutputFormat *f);
  610. enum CodecID av_guess_image2_codec(const char *filename);
  611. /* XXX: Use automatic init with either ELF sections or C file parser */
  612. /* modules. */
  613. /* utils.c */
  614. void av_register_input_format(AVInputFormat *format);
  615. void av_register_output_format(AVOutputFormat *format);
  616. #if LIBAVFORMAT_VERSION_MAJOR < 53
  617. attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
  618. const char *filename,
  619. const char *mime_type);
  620. /**
  621. * @deprecated Use av_guess_format() instead.
  622. */
  623. attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
  624. const char *filename,
  625. const char *mime_type);
  626. #endif
  627. /**
  628. * Returns the output format in the list of registered output formats
  629. * which best matches the provided parameters, or returns NULL if
  630. * there is no match.
  631. *
  632. * @param short_name if non-NULL checks if short_name matches with the
  633. * names of the registered formats
  634. * @param filename if non-NULL checks if filename terminates with the
  635. * extensions of the registered formats
  636. * @param mime_type if non-NULL checks if mime_type matches with the
  637. * MIME type of the registered formats
  638. */
  639. AVOutputFormat *av_guess_format(const char *short_name,
  640. const char *filename,
  641. const char *mime_type);
  642. /**
  643. * Guesses the codec ID based upon muxer and filename.
  644. */
  645. enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
  646. const char *filename, const char *mime_type,
  647. enum CodecType type);
  648. /**
  649. * Sends a nice hexadecimal dump of a buffer to the specified file stream.
  650. *
  651. * @param f The file stream pointer where the dump should be sent to.
  652. * @param buf buffer
  653. * @param size buffer size
  654. *
  655. * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
  656. */
  657. void av_hex_dump(FILE *f, uint8_t *buf, int size);
  658. /**
  659. * Sends a nice hexadecimal dump of a buffer to the log.
  660. *
  661. * @param avcl A pointer to an arbitrary struct of which the first field is a
  662. * pointer to an AVClass struct.
  663. * @param level The importance level of the message, lower values signifying
  664. * higher importance.
  665. * @param buf buffer
  666. * @param size buffer size
  667. *
  668. * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
  669. */
  670. void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
  671. /**
  672. * Sends a nice dump of a packet to the specified file stream.
  673. *
  674. * @param f The file stream pointer where the dump should be sent to.
  675. * @param pkt packet to dump
  676. * @param dump_payload True if the payload must be displayed, too.
  677. */
  678. void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  679. /**
  680. * Sends a nice dump of a packet to the log.
  681. *
  682. * @param avcl A pointer to an arbitrary struct of which the first field is a
  683. * pointer to an AVClass struct.
  684. * @param level The importance level of the message, lower values signifying
  685. * higher importance.
  686. * @param pkt packet to dump
  687. * @param dump_payload True if the payload must be displayed, too.
  688. */
  689. void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
  690. /**
  691. * Initializes libavformat and registers all the muxers, demuxers and
  692. * protocols. If you do not call this function, then you can select
  693. * exactly which formats you want to support.
  694. *
  695. * @see av_register_input_format()
  696. * @see av_register_output_format()
  697. * @see av_register_protocol()
  698. */
  699. void av_register_all(void);
  700. /** codec tag <-> codec id */
  701. enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
  702. unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
  703. /* media file input */
  704. /**
  705. * Finds AVInputFormat based on the short name of the input format.
  706. */
  707. AVInputFormat *av_find_input_format(const char *short_name);
  708. /**
  709. * Guesses the file format.
  710. *
  711. * @param is_opened Whether the file is already opened; determines whether
  712. * demuxers with or without AVFMT_NOFILE are probed.
  713. */
  714. AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
  715. /**
  716. * Allocates all the structures needed to read an input stream.
  717. * This does not open the needed codecs for decoding the stream[s].
  718. */
  719. int av_open_input_stream(AVFormatContext **ic_ptr,
  720. ByteIOContext *pb, const char *filename,
  721. AVInputFormat *fmt, AVFormatParameters *ap);
  722. /**
  723. * Opens a media file as input. The codecs are not opened. Only the file
  724. * header (if present) is read.
  725. *
  726. * @param ic_ptr The opened media file handle is put here.
  727. * @param filename filename to open
  728. * @param fmt If non-NULL, force the file format to use.
  729. * @param buf_size optional buffer size (zero if default is OK)
  730. * @param ap Additional parameters needed when opening the file
  731. * (NULL if default).
  732. * @return 0 if OK, AVERROR_xxx otherwise
  733. */
  734. int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  735. AVInputFormat *fmt,
  736. int buf_size,
  737. AVFormatParameters *ap);
  738. #if LIBAVFORMAT_VERSION_MAJOR < 53
  739. /**
  740. * @deprecated Use avformat_alloc_context() instead.
  741. */
  742. attribute_deprecated AVFormatContext *av_alloc_format_context(void);
  743. #endif
  744. /**
  745. * Allocates an AVFormatContext.
  746. * Can be freed with av_free() but do not forget to free everything you
  747. * explicitly allocated as well!
  748. */
  749. AVFormatContext *avformat_alloc_context(void);
  750. /**
  751. * Reads packets of a media file to get stream information. This
  752. * is useful for file formats with no headers such as MPEG. This
  753. * function also computes the real framerate in case of MPEG-2 repeat
  754. * frame mode.
  755. * The logical file position is not changed by this function;
  756. * examined packets may be buffered for later processing.
  757. *
  758. * @param ic media file handle
  759. * @return >=0 if OK, AVERROR_xxx on error
  760. * @todo Let the user decide somehow what information is needed so that
  761. * we do not waste time getting stuff the user does not need.
  762. */
  763. int av_find_stream_info(AVFormatContext *ic);
  764. /**
  765. * Reads a transport packet from a media file.
  766. *
  767. * This function is obsolete and should never be used.
  768. * Use av_read_frame() instead.
  769. *
  770. * @param s media file handle
  771. * @param pkt is filled
  772. * @return 0 if OK, AVERROR_xxx on error
  773. */
  774. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  775. /**
  776. * Returns the next frame of a stream.
  777. *
  778. * The returned packet is valid
  779. * until the next av_read_frame() or until av_close_input_file() and
  780. * must be freed with av_free_packet. For video, the packet contains
  781. * exactly one frame. For audio, it contains an integer number of
  782. * frames if each frame has a known fixed size (e.g. PCM or ADPCM
  783. * data). If the audio frames have a variable size (e.g. MPEG audio),
  784. * then it contains one frame.
  785. *
  786. * pkt->pts, pkt->dts and pkt->duration are always set to correct
  787. * values in AVStream.time_base units (and guessed if the format cannot
  788. * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
  789. * has B-frames, so it is better to rely on pkt->dts if you do not
  790. * decompress the payload.
  791. *
  792. * @return 0 if OK, < 0 on error or end of file
  793. */
  794. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  795. /**
  796. * Seeks to the keyframe at timestamp.
  797. * 'timestamp' in 'stream_index'.
  798. * @param stream_index If stream_index is (-1), a default
  799. * stream is selected, and timestamp is automatically converted
  800. * from AV_TIME_BASE units to the stream specific time_base.
  801. * @param timestamp Timestamp in AVStream.time_base units
  802. * or, if no stream is specified, in AV_TIME_BASE units.
  803. * @param flags flags which select direction and seeking mode
  804. * @return >= 0 on success
  805. */
  806. int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
  807. int flags);
  808. /**
  809. * Seeks to timestamp ts.
  810. * Seeking will be done so that the point from which all active streams
  811. * can be presented successfully will be closest to ts and within min/max_ts.
  812. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
  813. *
  814. * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
  815. * are the file position (this may not be supported by all demuxers).
  816. * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
  817. * in the stream with stream_index (this may not be supported by all demuxers).
  818. * Otherwise all timestamps are in units of the stream selected by stream_index
  819. * or if stream_index is -1, in AV_TIME_BASE units.
  820. * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
  821. * keyframes (this may not be supported by all demuxers).
  822. *
  823. * @param stream_index index of the stream which is used as time base reference
  824. * @param min_ts smallest acceptable timestamp
  825. * @param ts target timestamp
  826. * @param max_ts largest acceptable timestamp
  827. * @param flags flags
  828. * @returns >=0 on success, error code otherwise
  829. *
  830. * @NOTE This is part of the new seek API which is still under construction.
  831. * Thus do not use this yet. It may change at any time, do not expect
  832. * ABI compatibility yet!
  833. */
  834. int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
  835. /**
  836. * Starts playing a network-based stream (e.g. RTSP stream) at the
  837. * current position.
  838. */
  839. int av_read_play(AVFormatContext *s);
  840. /**
  841. * Pauses a network-based stream (e.g. RTSP stream).
  842. *
  843. * Use av_read_play() to resume it.
  844. */
  845. int av_read_pause(AVFormatContext *s);
  846. /**
  847. * Frees a AVFormatContext allocated by av_open_input_stream.
  848. * @param s context to free
  849. */
  850. void av_close_input_stream(AVFormatContext *s);
  851. /**
  852. * Closes a media file (but not its codecs).
  853. *
  854. * @param s media file handle
  855. */
  856. void av_close_input_file(AVFormatContext *s);
  857. /**
  858. * Adds a new stream to a media file.
  859. *
  860. * Can only be called in the read_header() function. If the flag
  861. * AVFMTCTX_NOHEADER is in the format context, then new streams
  862. * can be added in read_packet too.
  863. *
  864. * @param s media file handle
  865. * @param id file-format-dependent stream ID
  866. */
  867. AVStream *av_new_stream(AVFormatContext *s, int id);
  868. AVProgram *av_new_program(AVFormatContext *s, int id);
  869. /**
  870. * Adds a new chapter.
  871. * This function is NOT part of the public API
  872. * and should ONLY be used by demuxers.
  873. *
  874. * @param s media file handle
  875. * @param id unique ID for this chapter
  876. * @param start chapter start time in time_base units
  877. * @param end chapter end time in time_base units
  878. * @param title chapter title
  879. *
  880. * @return AVChapter or NULL on error
  881. */
  882. AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
  883. int64_t start, int64_t end, const char *title);
  884. /**
  885. * Sets the pts for a given stream.
  886. *
  887. * @param s stream
  888. * @param pts_wrap_bits number of bits effectively used by the pts
  889. * (used for wrap control, 33 is the value for MPEG)
  890. * @param pts_num numerator to convert to seconds (MPEG: 1)
  891. * @param pts_den denominator to convert to seconds (MPEG: 90000)
  892. */
  893. void av_set_pts_info(AVStream *s, int pts_wrap_bits,
  894. unsigned int pts_num, unsigned int pts_den);
  895. #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
  896. #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
  897. #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
  898. #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
  899. int av_find_default_stream_index(AVFormatContext *s);
  900. /**
  901. * Gets the index for a specific timestamp.
  902. * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
  903. * to the timestamp which is <= the requested one, if backward
  904. * is 0, then it will be >=
  905. * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
  906. * @return < 0 if no such timestamp could be found
  907. */
  908. int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  909. /**
  910. * Ensures the index uses less memory than the maximum specified in
  911. * AVFormatContext.max_index_size by discarding entries if it grows
  912. * too large.
  913. * This function is not part of the public API and should only be called
  914. * by demuxers.
  915. */
  916. void ff_reduce_index(AVFormatContext *s, int stream_index);
  917. /**
  918. * Adds an index entry into a sorted list. Updates the entry if the list
  919. * already contains it.
  920. *
  921. * @param timestamp timestamp in the time base of the given stream
  922. */
  923. int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
  924. int size, int distance, int flags);
  925. /**
  926. * Does a binary search using av_index_search_timestamp() and
  927. * AVCodec.read_timestamp().
  928. * This is not supposed to be called directly by a user application,
  929. * but by demuxers.
  930. * @param target_ts target timestamp in the time base of the given stream
  931. * @param stream_index stream number
  932. */
  933. int av_seek_frame_binary(AVFormatContext *s, int stream_index,
  934. int64_t target_ts, int flags);
  935. /**
  936. * Updates cur_dts of all streams based on the given timestamp and AVStream.
  937. *
  938. * Stream ref_st unchanged, others set cur_dts in their native time base.
  939. * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
  940. * @param timestamp new dts expressed in time_base of param ref_st
  941. * @param ref_st reference stream giving time_base of param timestamp
  942. */
  943. void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
  944. /**
  945. * Does a binary search using read_timestamp().
  946. * This is not supposed to be called directly by a user application,
  947. * but by demuxers.
  948. * @param target_ts target timestamp in the time base of the given stream
  949. * @param stream_index stream number
  950. */
  951. int64_t av_gen_search(AVFormatContext *s, int stream_index,
  952. int64_t target_ts, int64_t pos_min,
  953. int64_t pos_max, int64_t pos_limit,
  954. int64_t ts_min, int64_t ts_max,
  955. int flags, int64_t *ts_ret,
  956. int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
  957. /** media file output */
  958. int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
  959. /**
  960. * Allocates the stream private data and writes the stream header to an
  961. * output media file.
  962. *
  963. * @param s media file handle
  964. * @return 0 if OK, AVERROR_xxx on error
  965. */
  966. int av_write_header(AVFormatContext *s);
  967. /**
  968. * Writes a packet to an output media file.
  969. *
  970. * The packet shall contain one audio or video frame.
  971. * The packet must be correctly interleaved according to the container
  972. * specification, if not then av_interleaved_write_frame must be used.
  973. *
  974. * @param s media file handle
  975. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  976. dts/pts, ...
  977. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  978. */
  979. int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  980. /**
  981. * Writes a packet to an output media file ensuring correct interleaving.
  982. *
  983. * The packet must contain one audio or video frame.
  984. * If the packets are already correctly interleaved, the application should
  985. * call av_write_frame() instead as it is slightly faster. It is also important
  986. * to keep in mind that completely non-interleaved input will need huge amounts
  987. * of memory to interleave with this, so it is preferable to interleave at the
  988. * demuxer level.
  989. *
  990. * @param s media file handle
  991. * @param pkt The packet, which contains the stream_index, buf/buf_size,
  992. dts/pts, ...
  993. * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
  994. */
  995. int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
  996. /**
  997. * Interleaves a packet per dts in an output media file.
  998. *
  999. * Packets with pkt->destruct == av_destruct_packet will be freed inside this
  1000. * function, so they cannot be used after it. Note that calling av_free_packet()
  1001. * on them is still safe.
  1002. *
  1003. * @param s media file handle
  1004. * @param out the interleaved packet will be output here
  1005. * @param in the input packet
  1006. * @param flush 1 if no further packets are available as input and all
  1007. * remaining packets should be output
  1008. * @return 1 if a packet was output, 0 if no packet could be output,
  1009. * < 0 if an error occurred
  1010. */
  1011. int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
  1012. AVPacket *pkt, int flush);
  1013. /**
  1014. * Writes the stream trailer to an output media file and frees the
  1015. * file private data.
  1016. *
  1017. * May only be called after a successful call to av_write_header.
  1018. *
  1019. * @param s media file handle
  1020. * @return 0 if OK, AVERROR_xxx on error
  1021. */
  1022. int av_write_trailer(AVFormatContext *s);
  1023. void dump_format(AVFormatContext *ic,
  1024. int index,
  1025. const char *url,
  1026. int is_output);
  1027. #if LIBAVFORMAT_VERSION_MAJOR < 53
  1028. /**
  1029. * Parses width and height out of string str.
  1030. * @deprecated Use av_parse_video_frame_size instead.
  1031. */
  1032. attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
  1033. const char *str);
  1034. /**
  1035. * Converts framerate from a string to a fraction.
  1036. * @deprecated Use av_parse_video_frame_rate instead.
  1037. */
  1038. attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
  1039. const char *arg);
  1040. #endif
  1041. /**
  1042. * Parses datestr and returns a corresponding number of microseconds.
  1043. * @param datestr String representing a date or a duration.
  1044. * - If a date the syntax is:
  1045. * @code
  1046. * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
  1047. * @endcode
  1048. * Time is local time unless Z is appended, in which case it is
  1049. * interpreted as UTC.
  1050. * If the year-month-day part is not specified it takes the current
  1051. * year-month-day.
  1052. * Returns the number of microseconds since 1st of January, 1970 up to
  1053. * the time of the parsed date or INT64_MIN if datestr cannot be
  1054. * successfully parsed.
  1055. * - If a duration the syntax is:
  1056. * @code
  1057. * [-]HH[:MM[:SS[.m...]]]
  1058. * [-]S+[.m...]
  1059. * @endcode
  1060. * Returns the number of microseconds contained in a time interval
  1061. * with the specified duration or INT64_MIN if datestr cannot be
  1062. * successfully parsed.
  1063. * @param duration Flag which tells how to interpret datestr, if
  1064. * not zero datestr is interpreted as a duration, otherwise as a
  1065. * date.
  1066. */
  1067. int64_t parse_date(const char *datestr, int duration);
  1068. /** Gets the current time in microseconds. */
  1069. int64_t av_gettime(void);
  1070. /* ffm-specific for ffserver */
  1071. #define FFM_PACKET_SIZE 4096
  1072. int64_t ffm_read_write_index(int fd);
  1073. int ffm_write_write_index(int fd, int64_t pos);
  1074. void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
  1075. /**
  1076. * Attempts to find a specific tag in a URL.
  1077. *
  1078. * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
  1079. * Return 1 if found.
  1080. */
  1081. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  1082. /**
  1083. * Returns in 'buf' the path with '%d' replaced by a number.
  1084. *
  1085. * Also handles the '%0nd' format where 'n' is the total number
  1086. * of digits and '%%'.
  1087. *
  1088. * @param buf destination buffer
  1089. * @param buf_size destination buffer size
  1090. * @param path numbered sequence string
  1091. * @param number frame number
  1092. * @return 0 if OK, -1 on format error
  1093. */
  1094. int av_get_frame_filename(char *buf, int buf_size,
  1095. const char *path, int number);
  1096. /**
  1097. * Checks whether filename actually is a numbered sequence generator.
  1098. *
  1099. * @param filename possible numbered sequence string
  1100. * @return 1 if a valid numbered sequence string, 0 otherwise
  1101. */
  1102. int av_filename_number_test(const char *filename);
  1103. /**
  1104. * Generates an SDP for an RTP session.
  1105. *
  1106. * @param ac array of AVFormatContexts describing the RTP streams. If the
  1107. * array is composed by only one context, such context can contain
  1108. * multiple AVStreams (one AVStream per RTP stream). Otherwise,
  1109. * all the contexts in the array (an AVCodecContext per RTP stream)
  1110. * must contain only one AVStream.
  1111. * @param n_files number of AVCodecContexts contained in ac
  1112. * @param buff buffer where the SDP will be stored (must be allocated by
  1113. * the caller)
  1114. * @param size the size of the buffer
  1115. * @return 0 if OK, AVERROR_xxx on error
  1116. */
  1117. int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
  1118. #ifdef HAVE_AV_CONFIG_H
  1119. void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
  1120. #ifdef __GNUC__
  1121. #define dynarray_add(tab, nb_ptr, elem)\
  1122. do {\
  1123. __typeof__(tab) _tab = (tab);\
  1124. __typeof__(elem) _elem = (elem);\
  1125. (void)sizeof(**_tab == _elem); /* check that types are compatible */\
  1126. ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
  1127. } while(0)
  1128. #else
  1129. #define dynarray_add(tab, nb_ptr, elem)\
  1130. do {\
  1131. ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
  1132. } while(0)
  1133. #endif
  1134. time_t mktimegm(struct tm *tm);
  1135. struct tm *brktimegm(time_t secs, struct tm *tm);
  1136. const char *small_strptime(const char *p, const char *fmt,
  1137. struct tm *dt);
  1138. struct in_addr;
  1139. /* Deprecated, use getaddrinfo instead. */
  1140. attribute_deprecated int resolve_host(struct in_addr *sin_addr, const char *hostname);
  1141. void url_split(char *proto, int proto_size,
  1142. char *authorization, int authorization_size,
  1143. char *hostname, int hostname_size,
  1144. int *port_ptr,
  1145. char *path, int path_size,
  1146. const char *url);
  1147. #if LIBAVFORMAT_VERSION_MAJOR < 53
  1148. /**
  1149. * @deprecated Use av_match_ext() instead.
  1150. */
  1151. attribute_deprecated int match_ext(const char *filename, const char *extensions);
  1152. #endif
  1153. /**
  1154. * Returns a positive value if the given filename has one of the given
  1155. * extensions, 0 otherwise.
  1156. *
  1157. * @param extensions a comma-separated list of filename extensions
  1158. */
  1159. int av_match_ext(const char *filename, const char *extensions);
  1160. #endif /* HAVE_AV_CONFIG_H */
  1161. #endif /* AVFORMAT_AVFORMAT_H */