ffmpeg AVIOContext结构体主要变量

AVIOContext是FFMPEG管理输入输出数据的结构体。
参考结构体理解:http://www.jianshu.com/p/d109e7ef9749

unsigned char *buffer

:缓存开始位置
在解码的情况下,buffer用于存储ffmpeg读入的数据。例如打开一个视频文件的时候,先把数据从硬盘读入buffer,然后在送给解码器用于解码。

int buffer_size

:缓存大小(默认32768)

unsigned char *buf_ptr

:当前指针读取到的位置

unsigned char *buf_end

:缓存结束的位置

void *opaque :URLContext结构体
typedef struct URLContext {  
    const AVClass *av_class; ///< information for av_log(). Set by url_open().  
    struct URLProtocol *prot;  
    int flags;  
    int is_streamed;  /**< true if streamed (no seek possible), default = false */  
    int max_packet_size;  /**< if non zero, the stream is packetized with this max packet size */  
    void *priv_data;  
    char *filename; /**< specified URL */  
    int is_connected;  
    AVIOInterruptCB interrupt_callback;  
} URLContext;

URLContext结构体中还有一个结构体URLProtocol。注:每种协议(rtp,rtmp,file等)对应一个URLProtocol。这个结构体也不在FFMPEG提供的头文件中。从FFMPEG源代码中翻出其的定义:
typedef struct URLProtocol {  
    const char *name;  
    int (*url_open)(URLContext *h, const char *url, int flags);  
    int (*url_read)(URLContext *h, unsigned char *buf, int size);  
    int (*url_write)(URLContext *h, const unsigned char *buf, int size);  
    int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);  
    int (*url_close)(URLContext *h);  
    struct URLProtocol *next;  
    int (*url_read_pause)(URLContext *h, int pause);  
    int64_t (*url_read_seek)(URLContext *h, int stream_index,  
        int64_t timestamp, int flags);  
    int (*url_get_file_handle)(URLContext *h);  
    int priv_data_size;  
    const AVClass *priv_data_class;  
    int flags;  
    int (*url_check)(URLContext *h, int mask);  
} URLProtocol;

在这个结构体中,除了一些回调函数接口之外,有一个变量const char *name,该变量存储了协议的名称。每一种输入协议都对应这样一个结构体。

URLProtocol ff_rtmp_protocol = {  
    .name                = "rtmp",  
    .url_open            = rtmp_open,  
    .url_read            = rtmp_read,  
    .url_write           = rtmp_write,  
    .url_close           = rtmp_close,  
    .url_read_pause      = rtmp_read_pause,  
    .url_read_seek       = rtmp_read_seek,  
    .url_get_file_handle = rtmp_get_file_handle,  
    .priv_data_size      = sizeof(RTMP),  
    .flags               = URL_PROTOCOL_FLAG_NETWORK,  
};  

你可能感兴趣的:(ffmpeg AVIOContext结构体主要变量)