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.

197 lines
5.4KB

  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. struct AVFormat *next;
  56. } AVFormat;
  57. typedef struct AVStream {
  58. int id; /* internal stream id */
  59. AVCodecContext codec; /* codec context */
  60. void *priv_data;
  61. } AVStream;
  62. #define MAX_STREAMS 20
  63. /* format I/O context */
  64. typedef struct AVFormatContext {
  65. struct AVFormat *format;
  66. void *priv_data;
  67. ByteIOContext pb;
  68. int nb_streams;
  69. AVStream *streams[MAX_STREAMS];
  70. char filename[1024]; /* input or output filename */
  71. /* stream info */
  72. char title[512];
  73. char author[512];
  74. char copyright[512];
  75. char comment[512];
  76. /* This buffer is only needed when packets were already buffered but
  77. not decoded, for example to get the codec parameters in mpeg
  78. streams */
  79. struct AVPacketList *packet_buffer;
  80. } AVFormatContext;
  81. typedef struct AVPacketList {
  82. AVPacket pkt;
  83. struct AVPacketList *next;
  84. } AVPacketList;
  85. extern AVFormat *first_format;
  86. /* rv10enc.c */
  87. extern AVFormat rm_format;
  88. /* mpegmux.c */
  89. extern AVFormat mpeg_mux_format;
  90. /* asfenc.c */
  91. extern AVFormat asf_format;
  92. /* avienc.c */
  93. extern AVFormat avi_format;
  94. /* jpegenc.c */
  95. extern AVFormat mpjpeg_format;
  96. extern AVFormat jpeg_format;
  97. extern AVFormat single_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 ppm_format;
  105. extern AVFormat pgmyuv_format;
  106. extern AVFormat imgyuv_format;
  107. extern AVFormat pgmpipe_format;
  108. extern AVFormat pgmyuvpipe_format;
  109. extern AVFormat ppmpipe_format;
  110. /* raw.c */
  111. extern AVFormat mp2_format;
  112. extern AVFormat ac3_format;
  113. extern AVFormat h263_format;
  114. extern AVFormat mpeg1video_format;
  115. extern AVFormat mjpeg_format;
  116. extern AVFormat pcm_format;
  117. extern AVFormat rawvideo_format;
  118. /* ffm.c */
  119. extern AVFormat ffm_format;
  120. /* formats.c */
  121. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  122. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  123. void register_avformat(AVFormat *format);
  124. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  125. int strstart(const char *str, const char *val, const char **ptr);
  126. void nstrcpy(char *buf, int buf_size, const char *str);
  127. int match_ext(const char *filename, const char *extensions);
  128. void register_all(void);
  129. INT64 gettime(void);
  130. typedef struct FifoBuffer {
  131. UINT8 *buffer;
  132. UINT8 *rptr, *wptr, *end;
  133. } FifoBuffer;
  134. int fifo_init(FifoBuffer *f, int size);
  135. void fifo_free(FifoBuffer *f);
  136. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  137. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  138. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  139. AVFormatContext *av_open_input_file(const char *filename, int buf_size);
  140. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  141. void av_close_input_file(AVFormatContext *s);
  142. int av_write_packet(AVFormatContext *s, AVPacket *pkt);
  143. void dump_format(AVFormatContext *ic,
  144. int index,
  145. const char *url,
  146. int is_output);
  147. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  148. INT64 gettime(void);
  149. INT64 parse_date(const char *datestr, int duration);
  150. /* ffm specific for ffserver */
  151. #define FFM_PACKET_SIZE 4096
  152. offset_t ffm_read_write_index(int fd);
  153. void ffm_write_write_index(int fd, offset_t pos);
  154. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  155. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);