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.

227 lines
6.3KB

  1. #include "avcodec.h"
  2. #include "avio.h"
  3. /* packet functions */
  4. typedef struct AVPacket {
  5. INT64 pts;
  6. UINT8 *data;
  7. int size;
  8. int stream_index;
  9. int flags;
  10. #define PKT_FLAG_KEY 0x0001
  11. #define PKT_FLAG_DROPPED_FRAME 0x0002
  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. enum PixelFormat 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, int force_pts);
  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. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  57. struct AVFormat *next;
  58. } AVFormat;
  59. typedef struct AVStream {
  60. int id; /* internal stream id */
  61. AVCodecContext codec; /* codec context */
  62. void *priv_data;
  63. } AVStream;
  64. #define MAX_STREAMS 20
  65. /* format I/O context */
  66. typedef struct AVFormatContext {
  67. struct AVFormat *format;
  68. void *priv_data;
  69. ByteIOContext pb;
  70. int nb_streams;
  71. AVStream *streams[MAX_STREAMS];
  72. char filename[1024]; /* input or output filename */
  73. /* stream info */
  74. char title[512];
  75. char author[512];
  76. char copyright[512];
  77. char comment[512];
  78. /* This buffer is only needed when packets were already buffered but
  79. not decoded, for example to get the codec parameters in mpeg
  80. streams */
  81. struct AVPacketList *packet_buffer;
  82. } AVFormatContext;
  83. typedef struct AVPacketList {
  84. AVPacket pkt;
  85. struct AVPacketList *next;
  86. } AVPacketList;
  87. extern AVFormat *first_format;
  88. /* rv10enc.c */
  89. extern AVFormat rm_format;
  90. /* mpegmux.c */
  91. extern AVFormat mpeg_mux_format;
  92. /* asfenc.c */
  93. extern AVFormat asf_format;
  94. /* avienc.c */
  95. extern AVFormat avi_format;
  96. /* mov.c */
  97. extern AVFormat mov_format;
  98. extern AVFormat mp4_format;
  99. /* jpegenc.c */
  100. extern AVFormat mpjpeg_format;
  101. extern AVFormat jpeg_format;
  102. extern AVFormat single_jpeg_format;
  103. /* swfenc.c */
  104. extern AVFormat swf_format;
  105. /* gif.c */
  106. extern AVFormat gif_format;
  107. /* au.c */
  108. extern AVFormat au_format;
  109. /* wav.c */
  110. extern AVFormat wav_format;
  111. /* img.c */
  112. extern AVFormat pgm_format;
  113. extern AVFormat ppm_format;
  114. extern AVFormat pgmyuv_format;
  115. extern AVFormat imgyuv_format;
  116. extern AVFormat pgmpipe_format;
  117. extern AVFormat pgmyuvpipe_format;
  118. extern AVFormat ppmpipe_format;
  119. /* raw.c */
  120. extern AVFormat mp2_format;
  121. extern AVFormat ac3_format;
  122. extern AVFormat h263_format;
  123. extern AVFormat mpeg1video_format;
  124. extern AVFormat mjpeg_format;
  125. extern AVFormat pcm_s16le_format;
  126. extern AVFormat pcm_s16be_format;
  127. extern AVFormat pcm_u16le_format;
  128. extern AVFormat pcm_u16be_format;
  129. extern AVFormat pcm_s8_format;
  130. extern AVFormat pcm_u8_format;
  131. extern AVFormat pcm_mulaw_format;
  132. extern AVFormat pcm_alaw_format;
  133. extern AVFormat rawvideo_format;
  134. /* ffm.c */
  135. extern AVFormat ffm_format;
  136. /* formats.c */
  137. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  138. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  139. void register_avformat(AVFormat *format);
  140. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  141. int strstart(const char *str, const char *val, const char **ptr);
  142. void nstrcpy(char *buf, int buf_size, const char *str);
  143. int match_ext(const char *filename, const char *extensions);
  144. void register_all(void);
  145. INT64 gettime(void);
  146. typedef struct FifoBuffer {
  147. UINT8 *buffer;
  148. UINT8 *rptr, *wptr, *end;
  149. } FifoBuffer;
  150. int fifo_init(FifoBuffer *f, int size);
  151. void fifo_free(FifoBuffer *f);
  152. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  153. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  154. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  155. AVFormatContext *av_open_input_file(const char *filename,
  156. const char *format_name,
  157. int buf_size,
  158. AVFormatParameters *ap);
  159. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  160. void av_close_input_file(AVFormatContext *s);
  161. int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
  162. void dump_format(AVFormatContext *ic,
  163. int index,
  164. const char *url,
  165. int is_output);
  166. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  167. INT64 gettime(void);
  168. INT64 parse_date(const char *datestr, int duration);
  169. /* ffm specific for ffserver */
  170. #define FFM_PACKET_SIZE 4096
  171. offset_t ffm_read_write_index(int fd);
  172. void ffm_write_write_index(int fd, offset_t pos);
  173. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  174. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  175. int get_frame_filename(char *buf, int buf_size,
  176. const char *path, int number);
  177. /* grab/output specific */
  178. extern AVFormat video_grab_device_format;
  179. extern AVFormat audio_device_format;
  180. extern const char *v4l_device;
  181. extern const char *audio_device;