Nginx rtmp 拉流播放(play)

系列文章
Nginx rtmp 推流(publish) 解析_fdsafwagdagadg6576的专栏-CSDN博客
Nginx rtmp 拉流播放(play)_fdsafwagdagadg6576的专栏-CSDN博客
Nginx rtmp 拉流(转发pull)_fdsafwagdagadg6576的专栏-CSDN博客
Nginx rtmp 转推_fdsafwagdagadg6576的专栏-CSDN博客
Nginx rtmp 点播流程_fdsafwagdagadg6576的专栏-CSDN博客

终端play拉流分成两种场景

Nginx rtmp server有流场景和没流场景.

  • 有流场景:终端play在nginx rtmp server上注册作为subscribe,也就是在subscribes数组中添加一项。这就是拉流的原理,即注册成为subscribe,这样就可以接收流了
  • 没流:先拉流,然后注册成为subscribe,接收流. 拉流部分参见relay 拉流(pull)篇

整体结构图

image.png

image.png

流程图:

image

流程步骤

  1. handshake,connect,createstream和publish场景一样.ngx_rtmp_recv消息接收也一样.
  2. 发送play消息
  3. ngx_rtmp_live_join 注册作为subscribe接收,本地liveav发的流
  4. 流媒体ngx_rtmp_live_av转流
    绿色模块参见relay 拉流(pull)篇

源码分析

static ngx_int_t
ngx_rtmp_live_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
{
    ....
    /* join stream as subscriber */
//把上游rtmp服务器的session加入到这个流的订阅者中去
//参数3决定0 is subscriber
    ngx_rtmp_live_join(s, v->name, 0);
    ....
next:
    return next_play(s, v);
}

如果对您有所帮助,请随手点赞,谢谢

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容