ByteIOContext結構封裝了媒體資料流細節,将檔案媒體流,網絡媒體流抽象成一個位元組序列的流,對上層提供了一個統一的接口,下面是對這個結構的詳細的介紹。
typedef struct {
//資料緩沖區,存放位元組序列的流。
unsigned char *buffer;
//資料緩沖區的大小。
int buffer_size;
//buf_ptr緩沖區目前資料指針。
//buf_end緩沖區資料結尾。
unsigned char *buf_ptr, *buf_end;
void *opaque;
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
int64_t (*seek)(void *opaque, int64_t offset, int whence);
//緩沖區中資料的最後一個位元組在整個檔案中的偏移位置。如果是流媒體,
//應該從啟動程式開始算起,如果是靜态檔案,從檔案頭開始算起。
int64_t pos; /**< position in the file of the current buffer */
int must_flush; /**< true if the next seek should flush */
int eof_reached; /**< true if eof reached */
int write_flag; /**< true if open for writing */
int is_streamed;
int max_packet_size;
unsigned long checksum;
unsigned char *checksum_ptr;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
int error; ///< contains the error code or 0 if no error happened
int (*read_pause)(void *opaque, int pause);
int64_t (*read_seek)(void *opaque, int stream_index,
int64_t timestamp, int flags);
} ByteIOContext;
本文來自CSDN部落格,轉載請标明出處:http://blog.csdn.net/niehanzi/archive/2009/08/11/4432967.aspx