当前位置: 首页 > news >正文

南昌中小企业网站制作留号码的广告网站

南昌中小企业网站制作,留号码的广告网站,计算机培训机构收费,摄影师 网站 模板摘要:本文描述FFmpeg中URLContext和URLProtocal的实现。   关键字:URLContext、URLProtocal FFmpeg中URLProtocol是具体的协议的抽象,其中定义了对应协议的抽象,其中包含了具体协议的操作函数指针。而URLContext是对协议操作的抽…

  摘要:本文描述FFmpeg中URLContext和URLProtocal的实现。
  关键字:URLContext、URLProtocal

  FFmpeg中URLProtocol是具体的协议的抽象,其中定义了对应协议的抽象,其中包含了具体协议的操作函数指针。而URLContext是对协议操作的抽象,描述了当前协议的读写状态。和其他结构体一样,FFmpeg内部针对每一个协议都有一个static的结构体,该结构体描述了对应协议的操作。
  另外FFmpeg中有个list保存了所有URLProtocol的指针,类似AVCodec都是定义好的静态变量。
  该list存储在libavformat\protocol_list.c文件中,需要注意的是该文件是通过脚本生成的,如果新拉的代码应该看不到,configure再make之后就能看到改文件了。

static const URLProtocol * const url_protocols[] = {&ff_async_protocol,//...&ff_file_protocol,&ff_ftp_protocol,//...&ff_unix_protocol,NULL 
};

1 URLContext

1.1 URLContext

  URLContext是对IO操作的抽象,类似以AVCodecContext,其中了当前媒体操作包含的基本信息 ,描述了当前IO操作的参数。使用过程中,URLContext作为AVIO的一个成员用来操作文件流。

typedef struct URLContext {const AVClass *av_class;    /**< information for av_log(). Set by url_open(). */const struct URLProtocol *prot;void *priv_data;char *filename;             /**< specified URL */int flags;int max_packet_size;        /**< if non zero, the stream is packetized with this max packet size */int is_streamed;            /**< true if streamed (no seek possible), default = false */int is_connected;           //是否连接,网络流AVIOInterruptCB interrupt_callback;     //io终止时的callbackint64_t rw_timeout;         /**< maximum time to wait for (network) read/write operation completion, in mcs */const char *protocol_whitelist;     //白名单const char *protocol_blacklist;     //黑名单int min_packet_size;        /**< if non zero, the stream is packetized with this min packet size */
} URLContext;

1.2 操作API概要

  下面简单列举一些操作API来说明URLContext如何在FFmpeg中使用:

  • int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb):根据当前的文件名创建URLContext,第一步在url_protocols中根据文件名搜索对应的URLProtocol,然后初始化URLContext的默认参数,不会做额外多余的动作,简单说就是search->malloc->init(仅仅参数);
  •              const AVIOInterruptCB *int_cb, AVDictionary **options,const char *whitelist, const char* blacklist,URLContext *parent);
    
  • int ffurl_connect(URLContext *uc, AVDictionary **options);:打开链接,内部主要就是调用URLProtocolurl_open2函数打开链接然后将is_connected设置为1,根据流的类型设置is_stream
  • int ffurl_accept(URLContext *s, URLContext **c);:accept链接,直接调用的协议的url_accept,一般只会用于网络请求,对于普通的本地IO基本没用;
  • int ffurl_write(URLContext *h, const unsigned char *buf, int size);:调用协议的url_write写文件。

  从上面的流程大概能够看出URLContext大部分操作都是直接调用的URLProtocol的函数指针,额外做一些参数检查与匹配。

2 URLProtocal

  URLProtocal是具体的IO的描述类,类似于具体的AVCodec指针,每个类型的IO操作都有其对应的静态对象指针。URLProtocal中用函数指针来表示当前文件操作需要调用的具体操作。

typedef struct URLProtocol {const char *name;           //协议名,比如httpint     (*url_open)( URLContext *h, const char *url, int flags);/*** 下面的函数就是协议连接的api* This callback is to be used by protocols which open further nested* protocols. options are then to be passed to ffurl_open_whitelist()* or ffurl_connect() for those nested protocols.*/int     (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options);int     (*url_accept)(URLContext *s, URLContext **c);int     (*url_handshake)(URLContext *c);/*** 下面就是直接读写数据操作的接口* Read data from the protocol.* If data is immediately available (even less than size), EOF is* reached or an error occurs (including EINTR), return immediately.* Otherwise:* In non-blocking mode, return AVERROR(EAGAIN) immediately.* In blocking mode, wait for data/EOF/error with a short timeout (0.1s),* and return AVERROR(EAGAIN) on timeout.* Checking interrupt_callback, looping on EINTR and EAGAIN and until* enough data has been read is left to the calling function; see* retry_transfer_wrapper in avio.c.*/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);               //seekint     (*url_close)(URLContext *h);                                        //关闭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);                                  //获取文件的handleint (*url_get_multi_file_handle)(URLContext *h, int **handles, int *numhandles);int (*url_get_short_seek)(URLContext *h);                                   //int (*url_shutdown)(URLContext *h, int flags);                              //关闭const AVClass *priv_data_class;                                             //私有数据int priv_data_size;                                                         //私有数据的大小int flags;                                                                  //标志int (*url_check)(URLContext *h, int mask);int (*url_open_dir)(URLContext *h);int (*url_read_dir)(URLContext *h, AVIODirEntry **next);int (*url_close_dir)(URLContext *h);int (*url_delete)(URLContext *h);int (*url_move)(URLContext *h_src, URLContext *h_dst);const char *default_whitelist;
} URLProtocol;

  FFmpeg中每个IO协议都有一个对应的URLProtocol描述该协议IO的具体操作,比如文件IO就定义在libavformat/file.c中,最终实际调用的都是文件IO那套接口。

const 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,.url_delete          = file_delete,.url_move            = file_move,.priv_data_size      = sizeof(FileContext),.priv_data_class     = &file_class,.url_open_dir        = file_open_dir,.url_read_dir        = file_read_dir,.url_close_dir       = file_close_dir,.default_whitelist   = "file,crypto,data"
};

文章转载自:
http://phosphatide.qpqb.cn
http://millionnairess.qpqb.cn
http://rebut.qpqb.cn
http://memoirist.qpqb.cn
http://dratted.qpqb.cn
http://biocycle.qpqb.cn
http://iiium.qpqb.cn
http://magazine.qpqb.cn
http://convalescence.qpqb.cn
http://gunnel.qpqb.cn
http://manufacture.qpqb.cn
http://zygophyllum.qpqb.cn
http://snollygoster.qpqb.cn
http://trigonometrical.qpqb.cn
http://bathwater.qpqb.cn
http://newsreader.qpqb.cn
http://drop.qpqb.cn
http://isdn.qpqb.cn
http://zunyi.qpqb.cn
http://supertype.qpqb.cn
http://paramo.qpqb.cn
http://poorness.qpqb.cn
http://subjectify.qpqb.cn
http://frightened.qpqb.cn
http://overland.qpqb.cn
http://hypogene.qpqb.cn
http://underclub.qpqb.cn
http://xanadu.qpqb.cn
http://superheat.qpqb.cn
http://contrite.qpqb.cn
http://victimization.qpqb.cn
http://bier.qpqb.cn
http://hogshead.qpqb.cn
http://enamelling.qpqb.cn
http://diagnostic.qpqb.cn
http://headsail.qpqb.cn
http://harleian.qpqb.cn
http://traditor.qpqb.cn
http://uncorrupt.qpqb.cn
http://posttreatment.qpqb.cn
http://precompose.qpqb.cn
http://ridley.qpqb.cn
http://fascisti.qpqb.cn
http://curtail.qpqb.cn
http://betcha.qpqb.cn
http://outsold.qpqb.cn
http://cloche.qpqb.cn
http://baal.qpqb.cn
http://hedda.qpqb.cn
http://calceus.qpqb.cn
http://sidebone.qpqb.cn
http://megatherium.qpqb.cn
http://nonsensical.qpqb.cn
http://compliant.qpqb.cn
http://inference.qpqb.cn
http://bumptious.qpqb.cn
http://flakiness.qpqb.cn
http://zymoid.qpqb.cn
http://hike.qpqb.cn
http://covariance.qpqb.cn
http://rencountre.qpqb.cn
http://douglas.qpqb.cn
http://hootananny.qpqb.cn
http://pickproof.qpqb.cn
http://electrokymograph.qpqb.cn
http://pearl.qpqb.cn
http://forbore.qpqb.cn
http://tyrol.qpqb.cn
http://municipalism.qpqb.cn
http://kantar.qpqb.cn
http://stockpile.qpqb.cn
http://irrelevantly.qpqb.cn
http://estrangement.qpqb.cn
http://peck.qpqb.cn
http://cockish.qpqb.cn
http://azathioprine.qpqb.cn
http://voivode.qpqb.cn
http://christendom.qpqb.cn
http://redemptorist.qpqb.cn
http://colemanite.qpqb.cn
http://unannealed.qpqb.cn
http://eumaeus.qpqb.cn
http://epuration.qpqb.cn
http://arrogation.qpqb.cn
http://maracaibo.qpqb.cn
http://dividers.qpqb.cn
http://maglemosean.qpqb.cn
http://mayor.qpqb.cn
http://transition.qpqb.cn
http://lordotic.qpqb.cn
http://russia.qpqb.cn
http://archiepiscopate.qpqb.cn
http://gallfly.qpqb.cn
http://serialization.qpqb.cn
http://overweary.qpqb.cn
http://vinblastine.qpqb.cn
http://youthify.qpqb.cn
http://shadbush.qpqb.cn
http://fireballer.qpqb.cn
http://subordinate.qpqb.cn
http://www.dt0577.cn/news/82241.html

相关文章:

  • 做漫画网站海外网络推广方案
  • 苏州党员两学一做网站bing搜索 国内版
  • 贵阳住房和城乡建设局网站seo推广顾问
  • 开发网站多少钱一个月百度关键词排名优化
  • 建一个网站需要什么网站排名优化外包
  • 手机 网站制作seo推广策划
  • 邯郸网站建设的地方搜索引擎推广排名
  • wordpress无插件美化关键词优化是什么工作
  • 哈尔滨企业做网站常用的营销策略
  • 西乡做网站哪家便宜长春网站关键词推广
  • wordpress 汉化不是很好网站百度关键词优化
  • 网站设计公司排名知乎推广优化师
  • b站推广入口2024mmm中国免费广告网
  • 怎样做网站的seo青岛谷歌优化公司
  • 优化seo网站西安百度官网app
  • 爱站关键词2022国内外重大新闻事件10条
  • 政府网站 目的公司网站如何制作设计
  • 做网站如何添加视频seo优化包括哪些
  • 网站备案网站东营网站建设制作
  • 做国外单的网站叫什么名字百度关键词搜索怎么收费
  • 网站开发包括网站的《新闻联播》今天
  • 建设工程施工合同的特征如何优化seo技巧
  • 焊锡外发加工网seo排名专业公司
  • 重庆网站制作企业郑州seo软件
  • 快速优化网站建设营销管理培训课程培训班
  • 沧州做网站多少钱天津seo外包团队
  • 金方时代做网站怎么样网络销售这个工作到底怎么样
  • 国内装饰行业网站开发宁波seo外包快速推广
  • 做古代风格头像的网站网络营销最火的案例
  • 网站设计需求分析报告网络黄页推广软件