美文网首页Android音视频学习
Nginx rtmp 拉流播放(play)

Nginx rtmp 拉流播放(play)

作者: mfdalf | 来源:发表于2021-12-07 08:52 被阅读0次

    系列文章
    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);
    }
    

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

    相关文章

      网友评论

        本文标题:Nginx rtmp 拉流播放(play)

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