美文网首页
RTMP的Play协议

RTMP的Play协议

作者: Alfie20 | 来源:发表于2017-08-15 16:33 被阅读182次

作者原创,转载请联系作者
publisher通过Publish进行推送流之后,客户端可以发起Play操作,本文描述客户端经过handshake、connection协议后的Play协议。Play协议与Publish协议非常类似,细节不同而已,本文主要讲解不同之处。

涉及模块

针对推流操作,NGX-RTMP处理比较复杂,涉及的模块也比较多,先罗列如下。至于回调如何注册、如何调用请参考前文。

  • 模块名:ngx_rtmp_access_module
    回 调:ngx_rtmp_access_play
  • 模块名:ngx_rtmp_cfms_module
    回 调:ngx_rtmp_cfms_play
  • 模块名:ngx_rtmp_cmd_module
    回 调:ngx_rtmp_cmd_play
  • 模块名:ngx_rtmp_exec_module
    回 调:ngx_rtmp_exec_play
  • 模块名:ngx_rtmp_live_module
    回 调:ngx_rtmp_live_play
  • 模块名:ngx_rtmp_log_module
    回 调:ngx_rtmp_log_play
  • 模块名:ngx_rtmp_notify_module
    回 调:ngx_rtmp_notify_play
  • 模块名:ngx_rtmp_play_module
    回 调:ngx_rtmp_play_play
  • 模块名:ngx_rtmp_log_module
    回 调:ngx_rtmp_log_play
  • 模块名:ngx_rtmp_relay_module
    回 调:ngx_rtmp_relay_play

具体处理

  • 上述那些模块如何顺序调用?
    在注册回调时,将原回调ngx_rtmp_publish保存起来为next_publish。在ngx_rtmp_live_publish回调处理完毕后调用next_publish,从而下一个模块继续调用。见代码:
   next_publish = ngx_rtmp_publish;
   ngx_rtmp_publish = ngx_rtmp_live_publish;
  • 上述那些模块调用顺序如何?
    这个问题较简单,查看我的前文《RTMP添加到NGINX》中描述,主要根据编译时生成的 ngx_module_t *ngx_modules[] 变量在启动的时候一次执行
  • 做什么什么工作?
    因为模块比较多,在此挑选ngx_rtmp_live_module进行叙述,其他模块处理细节请各位看官阅读代码,如有问题可以消息我,如有必要可以再撰文描述
    • 合法性校验主要有:
NetStream.Play.StreamNotFound
NetStream.Publish.BadName
  • 设置ctx
```

ctx->stream = stream;
ctx->publishing = 0;
ctx->next = (
stream)->ctx;
ctx->cs[0].csid = NGX_RTMP_CSID_VIDEO;
ctx->cs[1].csid = NGX_RTMP_CSID_AUDIO;

 - 给pulbisher回复消息NetStream.Play.Start

相关文章

网友评论

      本文标题:RTMP的Play协议

      本文链接:https://www.haomeiwen.com/subject/epkifxtx.html