FFmpeg数据结构彻底分析——AVIOContext

/**
 * Bytestream IO Context.   字节流的IO上下文
 * New fields can be added to the end with minor version bumps.
 * Removal, reordering and changes to existing fields require a major
 * version bump.
 * sizeof(AVIOContext) must not be used outside libav*.
 *
 * @note None of the function pointers in AVIOContext should be called
 *       directly, they should only be set by the client application
 *       when implementing custom I/O. Normally these are set to the任何一个AVIOContext中的函数指针都不应该被直接调用,他们仅仅应该当实现定制IO时被客户程序设置
 *       function pointers specified in avio_alloc_context()  通常这些被设置为在avio_alloc_context()函数中指定的函数指针
 */
typedef struct AVIOContext {
    /**
     * A class for private options.
     *
     * If this AVIOContext is created by avio_open2(), av_class is set and
     * passes the options down to protocols.
     *
     * If this AVIOContext is manually allocated, then av_class may be set by
     * the caller.
     *
     * warning -- this field can be NULL, be sure to not pass this AVIOContext
     * to any av_opt_* functions in that case.
     */
    const AVClass *av_class;  //如果AVIOContext是用avio_open2()创建的,那么av_class被设置并且传递这些参数给协议;如果是手动分配的,那么av_class由调用者去设置
    unsigned char *buffer;  /**< Start of the buffer. */缓冲区的起始地址
    int buffer_size;        /**< Maximum buffer size */最大的缓冲区大小
    unsigned char *buf_ptr; /**< Current position in the buffer */缓冲区中的当前位置
    unsigned char *buf_end; /**< End of the data, may be less than   //数据的结束地址,如果读函数放回的数据比请求的数据少(例如那些没有更多数据可以接收的流),那么结束地址可能小于buffer+buffer_size这个地址,
                                 buffer+buffer_size if the read function returned
                                 less data than requested, e.g. for streams where
                                 no more data has been received yet. */
    void *opaque;           /**< A private pointer, passed to the read/write/seek/...//一个私有指针,传递给读写定位函数等的
                                 functions. */
     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);//读packet的函数指针
    int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);//写packet的函数指针
    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 */ //如果遇到eof,为真
     int write_flag;         /**< true if open for writing */ //如果写打开,为真
    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 *///包含错误代码,没错误时为0
    /**
     * Pause or resume playback for network streaming protocols - e.g. MMS.
     */
    int (*read_pause)(void *opaque, int pause);//网络流式协议的暂停和继续回放函数
    /**
     * Seek to a given timestamp in stream with the specified stream_index.
     * Needed for some network streaming protocols which don't support seeking
     * to byte position.
     */
     int64_t (*read_seek)(void *opaque, int stream_index,
                         int64_t timestamp, int flags);//用给定的stream_index参数定位到一个流中的给定的时间戳,对于一些不支持定位到字节位置的流式协议非常必需
    /**
     * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
     */
     int seekable;//AVIO_SEEKABLE_标志的组合或者不可以seek时为0

    /**
     * max filesize, used to limit allocations
     * This field is internal to libavformat and access from outside is not allowed.
     */
     int64_t maxsize;//最大的文件大小,用于限制分配,libavformat库内部使用,禁止外部使用

    /**
     * avio_read and avio_write should if possible be satisfied directly
     * instead of going through a buffer, and avio_seek will always
     * call the underlying seek function directly.
     */
     int direct; //avio_read()以及avio_write()直接读取而不是到缓冲区去

    /**
     * Bytes read statistic
     * This field is internal to libavformat and access from outside is not allowed.
     */
    int64_t bytes_read; //统计的读取的字节数,libavformat库内部使用,禁止外部使用

    /**
     * seek statistic
     * This field is internal to libavformat and access from outside is not allowed.
     */
    int seek_count;//统计的定位的计数,libavformat库内部使用,禁止外部使用

    /**
     * writeout statistic
     * This field is internal to libavformat and access from outside is not allowed.
     */
     int writeout_count; //统计的写出数,libavformat库内部使用,禁止外部使用

    /**
     * Original buffer size
     * used internally after probing and ensure seekback to reset the buffer size
     * This field is internal to libavformat and access from outside is not allowed.
     */
    int orig_buffer_size;//原始缓冲区大小,用于在探测之后确保回退以重置缓冲区大小,libavformat库内部使用,禁止外部使用
} AVIOContext;

你可能感兴趣的:(FFmpeg数据结构彻底分析——AVIOContext)