ByteIOContext结构分析

  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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值