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.

739 lines
23KB

  1. #ifndef AVFORMAT_H
  2. #define AVFORMAT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define LIBAVFORMAT_VERSION_INT ((50<<16)+(4<<8)+0)
  7. #define LIBAVFORMAT_VERSION 50.4.0
  8. #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
  9. #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
  10. #include <time.h>
  11. #include <stdio.h> /* FILE */
  12. #include "avcodec.h"
  13. #include "avio.h"
  14. /* packet functions */
  15. #ifndef MAXINT64
  16. #define MAXINT64 int64_t_C(0x7fffffffffffffff)
  17. #endif
  18. #ifndef MININT64
  19. #define MININT64 int64_t_C(0x8000000000000000)
  20. #endif
  21. typedef struct AVPacket {
  22. int64_t pts; ///< presentation time stamp in time_base units
  23. int64_t dts; ///< decompression time stamp in time_base units
  24. uint8_t *data;
  25. int size;
  26. int stream_index;
  27. int flags;
  28. int duration; ///< presentation duration in time_base units (0 if not available)
  29. void (*destruct)(struct AVPacket *);
  30. void *priv;
  31. int64_t pos; ///< byte position in stream, -1 if unknown
  32. } AVPacket;
  33. #define PKT_FLAG_KEY 0x0001
  34. void av_destruct_packet_nofree(AVPacket *pkt);
  35. void av_destruct_packet(AVPacket *pkt);
  36. /* initialize optional fields of a packet */
  37. static inline void av_init_packet(AVPacket *pkt)
  38. {
  39. pkt->pts = AV_NOPTS_VALUE;
  40. pkt->dts = AV_NOPTS_VALUE;
  41. pkt->pos = -1;
  42. pkt->duration = 0;
  43. pkt->flags = 0;
  44. pkt->stream_index = 0;
  45. pkt->destruct= av_destruct_packet_nofree;
  46. }
  47. int av_new_packet(AVPacket *pkt, int size);
  48. int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
  49. int av_dup_packet(AVPacket *pkt);
  50. /**
  51. * Free a packet
  52. *
  53. * @param pkt packet to free
  54. */
  55. static inline void av_free_packet(AVPacket *pkt)
  56. {
  57. if (pkt && pkt->destruct) {
  58. pkt->destruct(pkt);
  59. }
  60. }
  61. /*************************************************/
  62. /* fractional numbers for exact pts handling */
  63. /* the exact value of the fractional number is: 'val + num / den'. num
  64. is assumed to be such as 0 <= num < den */
  65. typedef struct AVFrac {
  66. int64_t val, num, den;
  67. } AVFrac;
  68. /*************************************************/
  69. /* input/output formats */
  70. struct AVFormatContext;
  71. /* this structure contains the data a format has to probe a file */
  72. typedef struct AVProbeData {
  73. const char *filename;
  74. unsigned char *buf;
  75. int buf_size;
  76. } AVProbeData;
  77. #define AVPROBE_SCORE_MAX 100
  78. typedef struct AVFormatParameters {
  79. AVRational time_base;
  80. int sample_rate;
  81. int channels;
  82. int width;
  83. int height;
  84. enum PixelFormat pix_fmt;
  85. struct AVImageFormat *image_format;
  86. int channel; /* used to select dv channel */
  87. const char *device; /* video, audio or DV device */
  88. const char *standard; /* tv standard, NTSC, PAL, SECAM */
  89. int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
  90. int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
  91. stream packet (only meaningful if
  92. mpeg2ts_raw is TRUE */
  93. int initial_pause:1; /* do not begin to play the stream
  94. immediately (RTSP only) */
  95. enum CodecID video_codec_id;
  96. enum CodecID audio_codec_id;
  97. } AVFormatParameters;
  98. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  99. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  100. #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
  101. #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
  102. raw picture data */
  103. #define AVFMT_GLOBALHEADER 0x0040 /* format wants global header */
  104. typedef struct AVOutputFormat {
  105. const char *name;
  106. const char *long_name;
  107. const char *mime_type;
  108. const char *extensions; /* comma separated extensions */
  109. /* size of private data so that it can be allocated in the wrapper */
  110. int priv_data_size;
  111. /* output support */
  112. enum CodecID audio_codec; /* default audio codec */
  113. enum CodecID video_codec; /* default video codec */
  114. int (*write_header)(struct AVFormatContext *);
  115. int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
  116. int (*write_trailer)(struct AVFormatContext *);
  117. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
  118. int flags;
  119. /* currently only used to set pixel format if not YUV420P */
  120. int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
  121. int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
  122. /* private fields */
  123. struct AVOutputFormat *next;
  124. } AVOutputFormat;
  125. typedef struct AVInputFormat {
  126. const char *name;
  127. const char *long_name;
  128. /* size of private data so that it can be allocated in the wrapper */
  129. int priv_data_size;
  130. /* tell if a given file has a chance of being parsing by this format */
  131. int (*read_probe)(AVProbeData *);
  132. /* read the format header and initialize the AVFormatContext
  133. structure. Return 0 if OK. 'ap' if non NULL contains
  134. additionnal paramters. Only used in raw format right
  135. now. 'av_new_stream' should be called to create new streams. */
  136. int (*read_header)(struct AVFormatContext *,
  137. AVFormatParameters *ap);
  138. /* read one packet and put it in 'pkt'. pts and flags are also
  139. set. 'av_new_stream' can be called only if the flag
  140. AVFMTCTX_NOHEADER is used. */
  141. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  142. /* close the stream. The AVFormatContext and AVStreams are not
  143. freed by this function */
  144. int (*read_close)(struct AVFormatContext *);
  145. /**
  146. * seek to a given timestamp relative to the frames in
  147. * stream component stream_index
  148. * @param stream_index must not be -1
  149. * @param flags selects which direction should be preferred if no exact
  150. * match is available
  151. */
  152. int (*read_seek)(struct AVFormatContext *,
  153. int stream_index, int64_t timestamp, int flags);
  154. /**
  155. * gets the next timestamp in AV_TIME_BASE units.
  156. */
  157. int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
  158. int64_t *pos, int64_t pos_limit);
  159. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
  160. int flags;
  161. /* if extensions are defined, then no probe is done. You should
  162. usually not use extension format guessing because it is not
  163. reliable enough */
  164. const char *extensions;
  165. /* general purpose read only value that the format can use */
  166. int value;
  167. /* start/resume playing - only meaningful if using a network based format
  168. (RTSP) */
  169. int (*read_play)(struct AVFormatContext *);
  170. /* pause playing - only meaningful if using a network based format
  171. (RTSP) */
  172. int (*read_pause)(struct AVFormatContext *);
  173. /* private fields */
  174. struct AVInputFormat *next;
  175. } AVInputFormat;
  176. typedef struct AVIndexEntry {
  177. int64_t pos;
  178. int64_t timestamp;
  179. #define AVINDEX_KEYFRAME 0x0001
  180. int flags:2;
  181. int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
  182. int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
  183. } AVIndexEntry;
  184. typedef struct AVStream {
  185. int index; /* stream index in AVFormatContext */
  186. int id; /* format specific stream id */
  187. AVCodecContext *codec; /* codec context */
  188. /**
  189. * real base frame rate of the stream.
  190. * for example if the timebase is 1/90000 and all frames have either
  191. * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
  192. */
  193. AVRational r_frame_rate;
  194. void *priv_data;
  195. /* internal data used in av_find_stream_info() */
  196. int64_t codec_info_duration;
  197. int codec_info_nb_frames;
  198. /* encoding: PTS generation when outputing stream */
  199. AVFrac pts;
  200. /**
  201. * this is the fundamental unit of time (in seconds) in terms
  202. * of which frame timestamps are represented. for fixed-fps content,
  203. * timebase should be 1/framerate and timestamp increments should be
  204. * identically 1.
  205. */
  206. AVRational time_base;
  207. int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
  208. /* ffmpeg.c private use */
  209. int stream_copy; /* if TRUE, just copy stream */
  210. enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
  211. //FIXME move stuff to a flags field?
  212. /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
  213. * MN:dunno if thats the right place, for it */
  214. float quality;
  215. /* decoding: position of the first frame of the component, in
  216. AV_TIME_BASE fractional seconds. */
  217. int64_t start_time;
  218. /* decoding: duration of the stream, in AV_TIME_BASE fractional
  219. seconds. */
  220. int64_t duration;
  221. char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
  222. /* av_read_frame() support */
  223. int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
  224. struct AVCodecParserContext *parser;
  225. int64_t cur_dts;
  226. int last_IP_duration;
  227. int64_t last_IP_pts;
  228. /* av_seek_frame() support */
  229. AVIndexEntry *index_entries; /* only used if the format does not
  230. support seeking natively */
  231. int nb_index_entries;
  232. int index_entries_allocated_size;
  233. int64_t nb_frames; ///< number of frames in this stream if known or 0
  234. } AVStream;
  235. #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
  236. (streams are added dynamically) */
  237. #define MAX_STREAMS 20
  238. /* format I/O context */
  239. typedef struct AVFormatContext {
  240. const AVClass *av_class; /* set by av_alloc_format_context */
  241. /* can only be iformat or oformat, not both at the same time */
  242. struct AVInputFormat *iformat;
  243. struct AVOutputFormat *oformat;
  244. void *priv_data;
  245. ByteIOContext pb;
  246. int nb_streams;
  247. AVStream *streams[MAX_STREAMS];
  248. char filename[1024]; /* input or output filename */
  249. /* stream info */
  250. int64_t timestamp;
  251. char title[512];
  252. char author[512];
  253. char copyright[512];
  254. char comment[512];
  255. char album[512];
  256. int year; /* ID3 year, 0 if none */
  257. int track; /* track number, 0 if none */
  258. char genre[32]; /* ID3 genre */
  259. int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
  260. /* private data for pts handling (do not modify directly) */
  261. /* This buffer is only needed when packets were already buffered but
  262. not decoded, for example to get the codec parameters in mpeg
  263. streams */
  264. struct AVPacketList *packet_buffer;
  265. /* decoding: position of the first frame of the component, in
  266. AV_TIME_BASE fractional seconds. NEVER set this value directly:
  267. it is deduced from the AVStream values. */
  268. int64_t start_time;
  269. /* decoding: duration of the stream, in AV_TIME_BASE fractional
  270. seconds. NEVER set this value directly: it is deduced from the
  271. AVStream values. */
  272. int64_t duration;
  273. /* decoding: total file size. 0 if unknown */
  274. int64_t file_size;
  275. /* decoding: total stream bitrate in bit/s, 0 if not
  276. available. Never set it directly if the file_size and the
  277. duration are known as ffmpeg can compute it automatically. */
  278. int bit_rate;
  279. /* av_read_frame() support */
  280. AVStream *cur_st;
  281. const uint8_t *cur_ptr;
  282. int cur_len;
  283. AVPacket cur_pkt;
  284. /* av_seek_frame() support */
  285. int64_t data_offset; /* offset of the first packet */
  286. int index_built;
  287. int mux_rate;
  288. int packet_size;
  289. int preload;
  290. int max_delay;
  291. #define AVFMT_NOOUTPUTLOOP -1
  292. #define AVFMT_INFINITEOUTPUTLOOP 0
  293. /* number of times to loop output in formats that support it */
  294. int loop_output;
  295. int flags;
  296. #define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames
  297. } AVFormatContext;
  298. typedef struct AVPacketList {
  299. AVPacket pkt;
  300. struct AVPacketList *next;
  301. } AVPacketList;
  302. extern AVInputFormat *first_iformat;
  303. extern AVOutputFormat *first_oformat;
  304. /* still image support */
  305. struct AVInputImageContext;
  306. typedef struct AVInputImageContext AVInputImageContext;
  307. typedef struct AVImageInfo {
  308. enum PixelFormat pix_fmt; /* requested pixel format */
  309. int width; /* requested width */
  310. int height; /* requested height */
  311. int interleaved; /* image is interleaved (e.g. interleaved GIF) */
  312. AVPicture pict; /* returned allocated image */
  313. } AVImageInfo;
  314. /* AVImageFormat.flags field constants */
  315. #define AVIMAGE_INTERLEAVED 0x0001 /* image format support interleaved output */
  316. typedef struct AVImageFormat {
  317. const char *name;
  318. const char *extensions;
  319. /* tell if a given file has a chance of being parsing by this format */
  320. int (*img_probe)(AVProbeData *);
  321. /* read a whole image. 'alloc_cb' is called when the image size is
  322. known so that the caller can allocate the image. If 'allo_cb'
  323. returns non zero, then the parsing is aborted. Return '0' if
  324. OK. */
  325. int (*img_read)(ByteIOContext *,
  326. int (*alloc_cb)(void *, AVImageInfo *info), void *);
  327. /* write the image */
  328. int supported_pixel_formats; /* mask of supported formats for output */
  329. int (*img_write)(ByteIOContext *, AVImageInfo *);
  330. int flags;
  331. struct AVImageFormat *next;
  332. } AVImageFormat;
  333. void av_register_image_format(AVImageFormat *img_fmt);
  334. AVImageFormat *av_probe_image_format(AVProbeData *pd);
  335. AVImageFormat *guess_image_format(const char *filename);
  336. enum CodecID av_guess_image2_codec(const char *filename);
  337. int av_read_image(ByteIOContext *pb, const char *filename,
  338. AVImageFormat *fmt,
  339. int (*alloc_cb)(void *, AVImageInfo *info), void *opaque);
  340. int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img);
  341. extern AVImageFormat *first_image_format;
  342. #if 0
  343. extern AVImageFormat pnm_image_format;
  344. extern AVImageFormat pbm_image_format;
  345. extern AVImageFormat pgm_image_format;
  346. extern AVImageFormat ppm_image_format;
  347. extern AVImageFormat pam_image_format;
  348. extern AVImageFormat pgmyuv_image_format;
  349. extern AVImageFormat yuv_image_format;
  350. #ifdef CONFIG_ZLIB
  351. extern AVImageFormat png_image_format;
  352. #endif
  353. extern AVImageFormat jpeg_image_format;
  354. #endif
  355. extern AVImageFormat gif_image_format;
  356. //extern AVImageFormat sgi_image_format; //broken in itself
  357. /* XXX: use automatic init with either ELF sections or C file parser */
  358. /* modules */
  359. /* mpeg.c */
  360. extern AVInputFormat mpegps_demux;
  361. int mpegps_init(void);
  362. /* mpegts.c */
  363. extern AVInputFormat mpegts_demux;
  364. int mpegts_init(void);
  365. /* rm.c */
  366. int rm_init(void);
  367. /* crc.c */
  368. int crc_init(void);
  369. /* img.c */
  370. int img_init(void);
  371. /* img2.c */
  372. int img2_init(void);
  373. /* asf.c */
  374. int asf_init(void);
  375. /* avienc.c */
  376. int avienc_init(void);
  377. /* avidec.c */
  378. int avidec_init(void);
  379. /* swf.c */
  380. int swf_init(void);
  381. /* mov.c */
  382. int mov_init(void);
  383. /* movenc.c */
  384. int movenc_init(void);
  385. /* flvenc.c */
  386. int flvenc_init(void);
  387. /* flvdec.c */
  388. int flvdec_init(void);
  389. /* jpeg.c */
  390. int jpeg_init(void);
  391. /* gif.c */
  392. int gif_init(void);
  393. /* au.c */
  394. int au_init(void);
  395. /* amr.c */
  396. int amr_init(void);
  397. /* wav.c */
  398. int ff_wav_init(void);
  399. /* mmf.c */
  400. int ff_mmf_init(void);
  401. /* raw.c */
  402. int pcm_read_seek(AVFormatContext *s,
  403. int stream_index, int64_t timestamp, int flags);
  404. int raw_init(void);
  405. /* mp3.c */
  406. int mp3_init(void);
  407. /* yuv4mpeg.c */
  408. int yuv4mpeg_init(void);
  409. /* ogg2.c */
  410. int ogg_init(void);
  411. /* ogg.c */
  412. int libogg_init(void);
  413. /* dv.c */
  414. int ff_dv_init(void);
  415. /* ffm.c */
  416. int ffm_init(void);
  417. /* rtsp.c */
  418. extern AVInputFormat redir_demux;
  419. int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
  420. /* 4xm.c */
  421. int fourxm_init(void);
  422. /* psxstr.c */
  423. int str_init(void);
  424. /* idroq.c */
  425. int roq_init(void);
  426. /* ipmovie.c */
  427. int ipmovie_init(void);
  428. /* nut.c */
  429. int nut_init(void);
  430. /* wc3movie.c */
  431. int wc3_init(void);
  432. /* westwood.c */
  433. int westwood_init(void);
  434. /* segafilm.c */
  435. int film_init(void);
  436. /* idcin.c */
  437. int idcin_init(void);
  438. /* flic.c */
  439. int flic_init(void);
  440. /* sierravmd.c */
  441. int vmd_init(void);
  442. /* matroska.c */
  443. int matroska_init(void);
  444. /* sol.c */
  445. int sol_init(void);
  446. /* electronicarts.c */
  447. int ea_init(void);
  448. /* nsvdec.c */
  449. int nsvdec_init(void);
  450. /* daud.c */
  451. int daud_init(void);
  452. /* nuv.c */
  453. int nuv_init(void);
  454. /* aiff.c */
  455. int ff_aiff_init(void);
  456. /* voc.c */
  457. int voc_init(void);
  458. /* tta.c */
  459. int tta_init(void);
  460. /* adts.c */
  461. int ff_adts_init(void);
  462. /* mm.c */
  463. int mm_init(void);
  464. /* avs.c */
  465. int avs_init(void);
  466. /* smacker.c */
  467. int smacker_init(void);
  468. #include "rtp.h"
  469. #include "rtsp.h"
  470. /* yuv4mpeg.c */
  471. extern AVOutputFormat yuv4mpegpipe_oformat;
  472. /* utils.c */
  473. void av_register_input_format(AVInputFormat *format);
  474. void av_register_output_format(AVOutputFormat *format);
  475. AVOutputFormat *guess_stream_format(const char *short_name,
  476. const char *filename, const char *mime_type);
  477. AVOutputFormat *guess_format(const char *short_name,
  478. const char *filename, const char *mime_type);
  479. enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
  480. const char *filename, const char *mime_type, enum CodecType type);
  481. void av_hex_dump(FILE *f, uint8_t *buf, int size);
  482. void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  483. void av_register_all(void);
  484. typedef struct FifoBuffer {
  485. uint8_t *buffer;
  486. uint8_t *rptr, *wptr, *end;
  487. } FifoBuffer;
  488. int fifo_init(FifoBuffer *f, int size);
  489. void fifo_free(FifoBuffer *f);
  490. int fifo_size(FifoBuffer *f, uint8_t *rptr);
  491. int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
  492. void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr);
  493. int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr);
  494. void fifo_realloc(FifoBuffer *f, unsigned int size);
  495. /* media file input */
  496. AVInputFormat *av_find_input_format(const char *short_name);
  497. AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
  498. int av_open_input_stream(AVFormatContext **ic_ptr,
  499. ByteIOContext *pb, const char *filename,
  500. AVInputFormat *fmt, AVFormatParameters *ap);
  501. int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  502. AVInputFormat *fmt,
  503. int buf_size,
  504. AVFormatParameters *ap);
  505. /* no av_open for output, so applications will need this: */
  506. AVFormatContext *av_alloc_format_context(void);
  507. #define AVERROR_UNKNOWN (-1) /* unknown error */
  508. #define AVERROR_IO (-2) /* i/o error */
  509. #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
  510. #define AVERROR_INVALIDDATA (-4) /* invalid data found */
  511. #define AVERROR_NOMEM (-5) /* not enough memory */
  512. #define AVERROR_NOFMT (-6) /* unknown format */
  513. #define AVERROR_NOTSUPP (-7) /* operation not supported */
  514. int av_find_stream_info(AVFormatContext *ic);
  515. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  516. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  517. int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
  518. int av_read_play(AVFormatContext *s);
  519. int av_read_pause(AVFormatContext *s);
  520. void av_close_input_file(AVFormatContext *s);
  521. AVStream *av_new_stream(AVFormatContext *s, int id);
  522. void av_set_pts_info(AVStream *s, int pts_wrap_bits,
  523. int pts_num, int pts_den);
  524. #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
  525. #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
  526. #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes
  527. int av_find_default_stream_index(AVFormatContext *s);
  528. int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  529. int av_add_index_entry(AVStream *st,
  530. int64_t pos, int64_t timestamp, int size, int distance, int flags);
  531. int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
  532. /* media file output */
  533. int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
  534. int av_write_header(AVFormatContext *s);
  535. int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  536. int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
  537. int av_write_trailer(AVFormatContext *s);
  538. void dump_format(AVFormatContext *ic,
  539. int index,
  540. const char *url,
  541. int is_output);
  542. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  543. int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
  544. int64_t parse_date(const char *datestr, int duration);
  545. int64_t av_gettime(void);
  546. /* ffm specific for ffserver */
  547. #define FFM_PACKET_SIZE 4096
  548. offset_t ffm_read_write_index(int fd);
  549. void ffm_write_write_index(int fd, offset_t pos);
  550. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  551. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  552. int get_frame_filename(char *buf, int buf_size,
  553. const char *path, int number);
  554. int filename_number_test(const char *filename);
  555. /* grab specific */
  556. int video_grab_init(void);
  557. int audio_init(void);
  558. /* DV1394 */
  559. int dv1394_init(void);
  560. int dc1394_init(void);
  561. #ifdef HAVE_AV_CONFIG_H
  562. #include "os_support.h"
  563. int strstart(const char *str, const char *val, const char **ptr);
  564. int stristart(const char *str, const char *val, const char **ptr);
  565. void pstrcpy(char *buf, int buf_size, const char *str);
  566. char *pstrcat(char *buf, int buf_size, const char *s);
  567. void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
  568. #ifdef __GNUC__
  569. #define dynarray_add(tab, nb_ptr, elem)\
  570. do {\
  571. typeof(tab) _tab = (tab);\
  572. typeof(elem) _elem = (elem);\
  573. (void)sizeof(**_tab == _elem); /* check that types are compatible */\
  574. __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
  575. } while(0)
  576. #else
  577. #define dynarray_add(tab, nb_ptr, elem)\
  578. do {\
  579. __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
  580. } while(0)
  581. #endif
  582. time_t mktimegm(struct tm *tm);
  583. struct tm *brktimegm(time_t secs, struct tm *tm);
  584. const char *small_strptime(const char *p, const char *fmt,
  585. struct tm *dt);
  586. struct in_addr;
  587. int resolve_host(struct in_addr *sin_addr, const char *hostname);
  588. void url_split(char *proto, int proto_size,
  589. char *authorization, int authorization_size,
  590. char *hostname, int hostname_size,
  591. int *port_ptr,
  592. char *path, int path_size,
  593. const char *url);
  594. int match_ext(const char *filename, const char *extensions);
  595. #endif /* HAVE_AV_CONFIG_H */
  596. #ifdef __cplusplus
  597. }
  598. #endif
  599. #endif /* AVFORMAT_H */