avformat.h 44 KB

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