typedef struct URLProtocol
{
const char *name;
//用的统一的模板函数
int(*url_open)(URLContext *h, const char *filename, int flags);
int(*url_read)(URLContext *h, unsigned char *buf, int size);
int(*url_write)(URLContext *h, unsigned char *buf, int size);
offset_t(*url_seek)(URLContext *h, offset_t pos, int whence);
int(*url_close)(URLContext *h);
struct URLProtocol *next;
} URLProtocol;ffurl_connect
file的主要结构的初始化如下:
URLProtocol ff_file_protocol = {
.name = "file",
.url_open = file_open,
.url_read = file_read,
.url_write = file_write,
.url_seek = file_seek,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
.url_check = file_check,
}
说明:
URLProtocol 是类似COM接口的数据结构,表示广义的输入文件,着重于功能函数,一种广义的输入文件对应一个URLProtocol结构,比如file,pipe,tcp等等,定义了对file tcp等方式的通用模板函数。next变量用于把所有支持的广义的输入文件连接成链表,便于遍历查找。