CRtmpserver协议链(protocol)

经过一段研究,对CRtmpserver 中的Protocol一直不知云云。尤其其中的FarProtocol和NearProtocol的概念。

下面是官方的解释:

The I/O is made as follows:

 

+---+    +----+     +----+     +----+                +----+     +----+

| T |<--->| P1 |<--->| P2|<--->| P3 |<--->  **  <--->| Pn |<--->| CS |

*---+    *----+     *----+     *----+                *----+     *----+

 

T  -Transport level. At this level we store the inbound data into a buffer

    or send the data from the output buffer. This layer may or may not

    have a IOHandler attached. This give us the possibility of having

    stateless communication like a chain of protocols in which HTTP is

    the edge protocol with the outside world. Basically, this layer

    will do I/O whenever a carrier is available.

 

P1 to Pn - Protocol levels. At this levelswe do packing/unpacking of the

          data provided either by the transport level or by the previous

          protocol. This way we can stack multiple protocol on top of each

          other. For example we could have RTMP over HTTP, or RTMP over some

          kind of compressing protocol over base64 over HTTP

 

CS - Connection state. At this level we dothe business logic of the connection.

    All the data passed in and out of this level is translated relative tothe

    business logic of the connection. For example in a RTMP connection this

    layer will receive only RTMP messages.

 

Below we have some possible chains ofprotocols:

 

1. TCP <--> HTTP <--> XMLRPC<--> Application Server State

2. TCP <--> RTMP <--> RTMPConnection State

3. TCP <--> HTTP <--> RTMP<--> RTMP Connection State

4. TCP <--> Encription <-->RTMP <--> RTMP Connection State

5. TCP <--> HTTP <-->Encription <--> RTMP <--> RTMP Connection State


以下个人理解:

T  -传输层协议,主要是存储数据或读取数据从缓存中。最接近IO操作的。这一层相于P1来说就是FarProtocol;

P1 to Pn -其实是逻辑处理层,主要处理媒体,加密,http相关的协议。其p1是T的NearProtocol,P2是P1的NearProtocol ,p1是p2的FarProtocol依次类推,越往后的协议,越接近上层逻辑。

CS -也是逻辑层,主要处理连接状态

创建协议链是在ProtocolFactoryManager::CreateProtocolChain里面可以处理的。

配置文件中配的协议去解析协议链的地方是DefaultProtocolFactory::ResolveProtocolChain

看着两个函数的处理,就能理解官方的解释了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值