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.

217 lines
6.1KB

  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. } AVPacket;
  12. int av_new_packet(AVPacket *pkt, int size);
  13. void av_free_packet(AVPacket *pkt);
  14. /*************************************************/
  15. /* output formats */
  16. struct AVFormatContext;
  17. struct AVFormatInputContext;
  18. typedef struct AVFormatParameters {
  19. int frame_rate;
  20. int sample_rate;
  21. int channels;
  22. int width;
  23. int height;
  24. int pix_fmt;
  25. } AVFormatParameters;
  26. typedef struct AVFormat {
  27. const char *name;
  28. const char *long_name;
  29. const char *mime_type;
  30. const char *extensions; /* comma separated extensions */
  31. /* output support */
  32. enum CodecID audio_codec; /* default audio codec */
  33. enum CodecID video_codec; /* default video codec */
  34. int (*write_header)(struct AVFormatContext *);
  35. int (*write_packet)(struct AVFormatContext *,
  36. int stream_index,
  37. unsigned char *buf, int size);
  38. int (*write_trailer)(struct AVFormatContext *);
  39. /* optional input support */
  40. /* read the format header and initialize the AVFormatInputContext
  41. structure. Return 0 if OK. 'ap' if non NULL contains
  42. additionnal paramters. Only used in raw format right now */
  43. int (*read_header)(struct AVFormatContext *,
  44. AVFormatParameters *ap);
  45. /* read one packet and put it in 'pkt'. pts and flags are also set */
  46. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  47. /* close the stream. The AVFormatContext and AVStreams are not
  48. freed by this function */
  49. int (*read_close)(struct AVFormatContext *);
  50. /* seek at or before a given pts (given in microsecond). The pts
  51. origin is defined by the stream */
  52. int (*read_seek)(struct AVFormatContext *, INT64 pts);
  53. int flags;
  54. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  55. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  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. extern AVFormat single_jpeg_format;
  99. /* swfenc.c */
  100. extern AVFormat swf_format;
  101. /* wav.c */
  102. extern AVFormat wav_format;
  103. /* img.c */
  104. extern AVFormat pgm_format;
  105. extern AVFormat ppm_format;
  106. extern AVFormat pgmyuv_format;
  107. extern AVFormat imgyuv_format;
  108. extern AVFormat pgmpipe_format;
  109. extern AVFormat pgmyuvpipe_format;
  110. extern AVFormat ppmpipe_format;
  111. /* raw.c */
  112. extern AVFormat mp2_format;
  113. extern AVFormat ac3_format;
  114. extern AVFormat h263_format;
  115. extern AVFormat mpeg1video_format;
  116. extern AVFormat mjpeg_format;
  117. extern AVFormat pcm_s16le_format;
  118. extern AVFormat pcm_s16be_format;
  119. extern AVFormat pcm_u16le_format;
  120. extern AVFormat pcm_u16be_format;
  121. extern AVFormat pcm_s8_format;
  122. extern AVFormat pcm_u8_format;
  123. extern AVFormat pcm_mulaw_format;
  124. extern AVFormat pcm_alaw_format;
  125. extern AVFormat rawvideo_format;
  126. /* ffm.c */
  127. extern AVFormat ffm_format;
  128. /* formats.c */
  129. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  130. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  131. void register_avformat(AVFormat *format);
  132. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  133. int strstart(const char *str, const char *val, const char **ptr);
  134. void nstrcpy(char *buf, int buf_size, const char *str);
  135. int match_ext(const char *filename, const char *extensions);
  136. void register_all(void);
  137. INT64 gettime(void);
  138. typedef struct FifoBuffer {
  139. UINT8 *buffer;
  140. UINT8 *rptr, *wptr, *end;
  141. } FifoBuffer;
  142. int fifo_init(FifoBuffer *f, int size);
  143. void fifo_free(FifoBuffer *f);
  144. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  145. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  146. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  147. AVFormatContext *av_open_input_file(const char *filename,
  148. const char *format_name,
  149. int buf_size,
  150. AVFormatParameters *ap);
  151. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  152. void av_close_input_file(AVFormatContext *s);
  153. int av_write_packet(AVFormatContext *s, AVPacket *pkt);
  154. void dump_format(AVFormatContext *ic,
  155. int index,
  156. const char *url,
  157. int is_output);
  158. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  159. INT64 gettime(void);
  160. INT64 parse_date(const char *datestr, int duration);
  161. /* ffm specific for ffserver */
  162. #define FFM_PACKET_SIZE 4096
  163. offset_t ffm_read_write_index(int fd);
  164. void ffm_write_write_index(int fd, offset_t pos);
  165. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  166. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  167. int get_frame_filename(char *buf, int buf_size,
  168. const char *path, int number);
  169. /* grab/output specific */
  170. extern AVFormat video_grab_device_format;
  171. extern AVFormat audio_device_format;
  172. extern const char *v4l_device;
  173. extern const char *audio_device;