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.

193 lines
5.2KB

  1. #include "avcodec.h"
  2. #define FFMPEG_VERSION "0.4.5"
  3. #include "avio.h"
  4. /* packet functions */
  5. typedef struct AVPacket {
  6. INT64 pts;
  7. UINT8 *data;
  8. int size;
  9. int stream_index;
  10. int flags;
  11. #define PKT_FLAG_KEY 0x0001
  12. } AVPacket;
  13. int av_new_packet(AVPacket *pkt, int size);
  14. void av_free_packet(AVPacket *pkt);
  15. /*************************************************/
  16. /* output formats */
  17. struct AVFormatContext;
  18. struct AVFormatInputContext;
  19. typedef struct AVFormatParameters {
  20. int frame_rate;
  21. int sample_rate;
  22. int channels;
  23. int width;
  24. int height;
  25. int pix_fmt;
  26. } AVFormatParameters;
  27. typedef struct AVFormat {
  28. const char *name;
  29. const char *long_name;
  30. const char *mime_type;
  31. const char *extensions; /* comma separated extensions */
  32. /* output support */
  33. enum CodecID audio_codec; /* default audio codec */
  34. enum CodecID video_codec; /* default video codec */
  35. int (*write_header)(struct AVFormatContext *);
  36. int (*write_packet)(struct AVFormatContext *,
  37. int stream_index,
  38. unsigned char *buf, int size);
  39. int (*write_trailer)(struct AVFormatContext *);
  40. /* optional input support */
  41. /* read the format header and initialize the AVFormatInputContext
  42. structure. Return 0 if OK. 'ap' if non NULL contains
  43. additionnal paramters. Only used in raw format right now */
  44. int (*read_header)(struct AVFormatContext *,
  45. AVFormatParameters *ap);
  46. /* read one packet and put it in 'pkt'. pts and flags are also set */
  47. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  48. /* close the stream. The AVFormatContext and AVStreams are not
  49. freed by this function */
  50. int (*read_close)(struct AVFormatContext *);
  51. /* seek at or before a given pts (given in microsecond). The pts
  52. origin is defined by the stream */
  53. int (*read_seek)(struct AVFormatContext *, INT64 pts);
  54. int flags;
  55. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  56. struct AVFormat *next;
  57. } AVFormat;
  58. typedef struct AVStream {
  59. int id; /* internal stream id */
  60. AVCodecContext codec; /* codec context */
  61. void *priv_data;
  62. } AVStream;
  63. #define MAX_STREAMS 20
  64. /* format I/O context */
  65. typedef struct AVFormatContext {
  66. struct AVFormat *format;
  67. void *priv_data;
  68. ByteIOContext pb;
  69. int nb_streams;
  70. AVStream *streams[MAX_STREAMS];
  71. char filename[1024]; /* input or output filename */
  72. /* stream info */
  73. char title[512];
  74. char author[512];
  75. char copyright[512];
  76. char comment[512];
  77. /* This buffer is only needed when packets were already buffered but
  78. not decoded, for example to get the codec parameters in mpeg
  79. streams */
  80. struct AVPacketList *packet_buffer;
  81. } AVFormatContext;
  82. typedef struct AVPacketList {
  83. AVPacket pkt;
  84. struct AVPacketList *next;
  85. } AVPacketList;
  86. extern AVFormat *first_format;
  87. /* rv10enc.c */
  88. extern AVFormat rm_format;
  89. /* mpegmux.c */
  90. extern AVFormat mpeg_mux_format;
  91. /* asfenc.c */
  92. extern AVFormat asf_format;
  93. /* avienc.c */
  94. extern AVFormat avi_format;
  95. /* jpegenc.c */
  96. extern AVFormat mpjpeg_format;
  97. extern AVFormat jpeg_format;
  98. /* swfenc.c */
  99. extern AVFormat swf_format;
  100. /* wav.c */
  101. extern AVFormat wav_format;
  102. /* img.c */
  103. extern AVFormat pgm_format;
  104. extern AVFormat pgmyuv_format;
  105. extern AVFormat imgyuv_format;
  106. extern AVFormat pgmpipe_format;
  107. /* raw.c */
  108. extern AVFormat mp2_format;
  109. extern AVFormat ac3_format;
  110. extern AVFormat h263_format;
  111. extern AVFormat mpeg1video_format;
  112. extern AVFormat pcm_format;
  113. extern AVFormat rawvideo_format;
  114. /* ffm.c */
  115. extern AVFormat ffm_format;
  116. /* formats.c */
  117. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  118. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  119. void register_avformat(AVFormat *format);
  120. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  121. int strstart(const char *str, const char *val, const char **ptr);
  122. void nstrcpy(char *buf, int buf_size, const char *str);
  123. int match_ext(const char *filename, const char *extensions);
  124. void register_all(void);
  125. INT64 gettime(void);
  126. typedef struct FifoBuffer {
  127. UINT8 *buffer;
  128. UINT8 *rptr, *wptr, *end;
  129. } FifoBuffer;
  130. int fifo_init(FifoBuffer *f, int size);
  131. void fifo_free(FifoBuffer *f);
  132. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  133. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  134. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  135. AVFormatContext *av_open_input_file(const char *filename, int buf_size);
  136. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  137. void av_close_input_file(AVFormatContext *s);
  138. int av_write_packet(AVFormatContext *s, AVPacket *pkt);
  139. void dump_format(AVFormatContext *ic,
  140. int index,
  141. const char *url,
  142. int is_output);
  143. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  144. INT64 gettime(void);
  145. INT64 parse_date(const char *datestr, int duration);
  146. /* ffm specific for ffserver */
  147. #define FFM_PACKET_SIZE 4096
  148. offset_t ffm_read_write_index(int fd);
  149. void ffm_write_write_index(int fd, offset_t pos);
  150. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  151. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);