音视频流媒体开发【六十四】RTMP/HLS/HTTP-FLV流媒体服务器分7-SRS流媒体框架-edge集群

音视频流媒体开发-目录
iOS知识点-目录
Android-目录
Flutter-目录
数据结构与算法-目录
uni-pp-目录

edge原理

SRS的Edge主要解决⼏条流有⼤量播放请求的场景,⽐如⼀个流有上万⼈观看。SRS的Edge 能对接所有的标准RTMP源站服务器。

备注:Edge一般负载高,SRS支持的并发足够跑满千兆网带宽了。

Remark: SRS Edge does not support Transcoding, DVR and HLS, which is supported by SRS Origin Server.

Edge的主要应用场景:
  • CDN/VDN大规模集群,客户众多流众多需要按需回源。
  • 小规模集群,但是流比较多,需要按需回源。
  • 骨干带宽低,边缘服务器强悍,可以使用多层edge,降低上层BGP带宽。

注意:edge可以从源站拉流,也可以将流转发给源站。也就是说,播放edge上的流时,edge会 回源拉流;推流到edge上时,edge会直接将流转发给源站。

注意:若只需要中转流给源站,不必用forward,直接使用edge模式即可。可以直接支持推流 和拉流的中转,简单快捷。Forward应用于目标服务器是多个,譬如将一路流主动送给多路服务 器;edge虽然配置了多台服务器,但是只用了一台,有故障时才切换。

注意:优先使用edge,除非知道必须用forward,才使用forward。

概念

所谓边缘edge服务器,就是边缘直播缓存服务器,配置时指定为remote模式和origin(指定一个或多个源站IP),这个边缘edge服务器就是源站的缓存了。

当用户推流到边缘服务器时,边缘直接将流转发给源站。譬如源站在北京BGP机房,湖南有个 电信ADSL用户要推流发布自己的直播流,要是直接推流到北京BGP可能效果不是很好,可以在 湖南电信机房部署一个边缘,用户推流到湖南边缘,边缘转发给北京源站BGP。

当用户播放边缘服务器的流时,边缘服务器看有没有缓存,若缓存了就直接将流发给客户端。 若没有缓存,则发起一路回源链接,从源站取数据源源不断放到自己的缓存队列。也就是说, 多个客户端连接到边缘时,只有一路回源。这种结构在CDN是最典型的部署结构。譬如北京源站, 在全国32个省每个省都部署了10台服务器,一共就有320台边缘,假设每个省1台边缘服务器都有 2000用户观看,那么就有64万用户,每秒钟集群发送640Gbps数据;而回源链接只有320个, 实现了大规模分发。

边缘edge服务器,实际上是解决大并发问题产生的分布式集群结构。SRS的边缘可以指定多个源站, 在源站出现故障时会自动切换到下一个源站,不影响用户观看,具有最佳的容错性,用户完全不会觉察。

edge配置

第一步,编写SRS源站配置文件。详细参考RTMP分发和Edge

将以下内容保存为文件,譬如 conf/origin.conf ,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。

# conf/origin.conf
listen 1935;
max_connections 1000;
pid objs/origin.pid;
srs_log_file ./objs/origin.log;
vhost __defaultVhost__ {
}

第二步,编写SRS边缘配置文件。详细参考RTMP分发Edge

将以下内容保存为文件,譬如 conf/edge.conf ,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。

# conf/edge1.conf
listen 19350;
max_connections 1000;
pid objs/edge1.pid;
srs_log_file ./objs/edge1.log;
vhost __defaultVhost__ {
    cluster {
        mode remote;
        origin 127.0.0.1:1935;
    }
}

# conf/edge2.conf
listen 19351;
max_connections 1000;
pid objs/edge2.pid;
srs_log_file ./objs/edge2.log;
vhost __defaultVhost__ {
    cluster {
        mode remote;
        origin 127.0.0.1:1935;
    }
}

第三步,启动SRS。详细参考RTMP分发Edge

./objs/srs -c conf/origin1.conf
./objs/srs -c conf/edge1.conf
./objs/srs -c conf/edge2.conf

第四步,启动推流编码器。详细参考RTMP分发Edge

使用FFMPEG命令推流:

#!/bin/bash
for((;;)); do \
    ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
    -vcodec copy -acodec copy \
    -f flv -y rtmp://111.229.231.225/live/livestream; \
    sleep 1; \
done

第五步,观看RTMP流。详细参考RTMP分发Edge

源站RTMP流地址为:

rtmp://192.168.1.170:19350/live/livestream

,可以使用VLC观看。

或者使用在线SRS播放器播放:srs-player-19350

边缘RTMP流地址为:

rtmp://192.168.1.170/live/livestream 

,可以使用VLC观看。或者使用在线SRS播放器播放:srs-player

备注:请将所有实例的IP地址192.168.1.170都换成部署的服务器IP地址。

edge源码分析

提出问题:
  • 当像edge服务器推流时,edge向origin源站做了什么操作,怎么保证集群推流path的唯一性,特别是有2个origin时
  • edge作为拉流端,需要从origin拉流时做了什么?

从配置文件入手

vhost __defaultVhost__ {
    cluster {
        mode remote;
        origin 127.0.0.1:1935;
    }
}

核心类

SrsEdgeIngester 从源站拉流
SrsPublishEdge 推流到源站,实际是调用SrsEdgeForwarder来实现
SrsPlayEdge 从源站拉流

edge

推流

SrsConfig::get_vhost_is_edge
#0 SrsConfig::get_vhost_is_edge (this=0xa0fcf0, vhost="__defaultVhost__")at src/app/srs_app_config.cpp:5063
#1 0x00000000004d4ac8 in SrsRtmpConn::stream_service_cycle (this=0xa2fc50)at src/app/srs_app_rtmp_conn.cpp:472
#2 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#3 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#4 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#5 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#6 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#7 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#8 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>,arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
#0 SrsConfig::get_vhost_is_edge (this=0xa0fcf0, vhost=0xa10b50) at src/app/srs_app_config.cpp:5069
#1 0x0000000000537edc in SrsConfig::get_vhost_is_edge (this=0xa0fcf0, vhost="__defaultVhost__")at src/app/srs_app_config.cpp:5065
#2 0x00000000004d4ac8 in SrsRtmpConn::stream_service_cycle (this=0xa2fc50)at src/app/srs_app_rtmp_conn.cpp:472
#3 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#4 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#5 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#6 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#7 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#8 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#9 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
SrsConfig::get_vhost_edge_origin
#0 SrsConfig::get_vhost_edge_origin (this=0xa0fcf0, vhost="__defaultVhost__")at src/app/srs_app_config.cpp:5091
#1 0x000000000057ab62 in SrsEdgeForwarder::start (this=0xa3b5d0) at src/app/srs_app_edge.cpp:482
#2 0x000000000057c4b2 in SrsPublishEdge::on_client_publish (this=0xa3aa50) at src/app/srs_app_edge.cpp:777
#3 0x00000000004e74a9 in SrsSource::on_edge_start_publish (this=0xa3af10) at src/app/srs_app_source.cpp:2592
#4 0x00000000004d8996 in SrsRtmpConn::acquire_publish (this=0xa2fc50, source=0xa3af10) at src/app/srs_app_rtmp_conn.cpp:936
#5 0x00000000004d7a74 in SrsRtmpConn::publishing (this=0xa2fc50, source=0xa3af10) at src/app/srs_app_rtmp_conn.cpp:822
#6 0x00000000004d5229 in SrsRtmpConn::stream_service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:534 
#7 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#8 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#9 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#10 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#11 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#12 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#13 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001, joinable=1, stk_size=1) at sched.c:616

edge-fwr publish url rtmp://127.0.0.1:1935/live/livestream
SrsEdgeRtmpUpstream::SrsEdgeRtmpUpstream
#0 SrsEdgeRtmpUpstream::SrsEdgeRtmpUpstream (this=0xa3b670,r="\220g\366\367\377\177", '\000' <repeats 11 times>,"\254\243\000\000\000\000\000\324\301\376\366\377\177\000\000\030\000\000\000\0
00\000\000\000\000C\037\370?U\240\260\243\000\000\000\000\000T~S\000\000\000\000\000\360g\366\367\377\177\000\000E\276W\000\000\000\000\000\360g\366\367\377\177\000\000\360\256\243\000\000\000\000\000\360\256\243\000\000\000\000\000T~S\000\000\000\000\000h\366\367\377\177\000\000\275:N\000\000\000\000\000h\366\367\377\177\000\000\020\257\243\000\000\000\000\000\020\257\243\000\000\000\000\000T~S\000\000\000\000\000\020i\366\367\377\177\000\000\353\063N\000\000\000\000\000hi\366\367\377\177\000\000\230\023\241\000\000\000\000\000@\230\243\000\000\000\000\000"...) at src/app/srs_app_edge.cpp:64
#1 0x0000000000578d1b in SrsEdgeIngester::SrsEdgeIngester (this=0xa3b0a0) at src/app/srs_app_edge.cpp:172
#2 0x000000000057be45 in SrsPlayEdge::SrsPlayEdge (this=0xa3aef0) at src/app/srs_app_edge.cpp:656
#3 0x00000000004e3abd in SrsSource::SrsSource (this=0xa3af10) at src/app/srs_app_source.cpp:1830
#4 0x00000000004e33eb in SrsSourceManager::fetch_or_create (this=0xa0ec20, r=0xa39840,h=0xa11398,pps=0x7ffff7f66968) at src/app/srs_app_source.cpp:1718
#5 0x00000000004d4d5a in SrsRtmpConn::stream_service_cycle (this=0xa2fc50)at src/app/srs_app_rtmp_conn.cpp:498
#6 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#7 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#8 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#9 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#10 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#11 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#12 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001, joinable=1, stk_size=1) at sched.c:616
SrsEdgeRtmpUpstream::connect
SrsEdgeIngester::SrsEdgeIngester
#0 SrsEdgeIngester::SrsEdgeIngester (this=0xa3b0a0) at src/app/srs_app_edge.cpp:166
#1 0x000000000057be45 in SrsPlayEdge::SrsPlayEdge (this=0xa3aef0) at src/app/srs_app_edge.cpp:656
#2 0x00000000004e3abd in SrsSource::SrsSource (this=0xa3af10) at src/app/srs_app_source.cpp:1830
#3 0x00000000004e33eb in SrsSourceManager::fetch_or_create (this=0xa0ec20, r=0xa39840, h=0xa11398, pps=0x7ffff7f66968) at src/app/srs_app_source.cpp:1718
#4 0x00000000004d4d5a in SrsRtmpConn::stream_service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:498
#5 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#6 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#7 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#8 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#9 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#10 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#11 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001, joinable=1, stk_size=1) at sched.c:616
SrsEdgeForwarder::proxy

推流的时候,对于边缘节点在收到数据的时候是从SrsPublishRecvThread 发给了SrsEdgeForwarder 的queue,然后SrsEdgeForwarder在do_cycle里将数据读取出来并推送给源站。

#0 SrsEdgeForwarder::proxy (this=0xa3b5b0, msg=0xb10ab0) at src/app/srs_app_edge.cpp:624
#1 0x000000000057c5ee in SrsPublishEdge::on_proxy_publish (this=0xa3aa30, msg=0xb10ab0) at src/app/srs_app_edge.cpp:792
#2 0x00000000004e74e2 in SrsSource::on_edge_proxy_publish (this=0xa3aef0, msg=0xb10ab0) at src/app/srs_app_source.cpp:2598
#3 0x00000000004d8ea9 in SrsRtmpConn::process_publish_message (this=0xa3ba50, source=0xa3aef0, msg=0xb10ab0) at src/app/srs_app_rtmp_conn.cpp:1006
#4 0x00000000004d8dce in SrsRtmpConn::handle_publish_message (this=0xa3ba50, source=0xa3aef0, msg=0xb10ab0) at src/app/srs_app_rtmp_conn.cpp:993
#5 0x00000000005810b6 in SrsPublishRecvThread::consume (this=0x7ffff7f66800, msg=0xb10ab0) at src/app/srs_app_recv_thread.cpp:389
#6 0x000000000057fbd4 in SrsRecvThread::do_cycle (this=0x7ffff7f66808) at src/app/srs_app_recv_thread.cpp:146
#7 0x000000000057fa25 in SrsRecvThread::cycle (this=0x7ffff7f66808) at src/app/srs_app_recv_thread.cpp:115
#8 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa46540) at src/app/srs_app_st.cpp:198
#9 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa46540) at src/app/srs_app_st.cpp:213
#10 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#11 0x00000000005be515 in st_thread_create (start=0xa47720, arg=0x7ffff7f66530, joinable=32767, stk_size=-134847200) at sched.c:616
SrsPublishEdge::SrsPublishEdge
#0 SrsPublishEdge::SrsPublishEdge (this=0xa3aa50) at src/app/srs_app_edge.cpp:726
#1 0x00000000004e3ada in SrsSource::SrsSource (this=0xa3af10) at src/app/srs_app_source.cpp:1831
#2 0x00000000004e33eb in SrsSourceManager::fetch_or_create (this=0xa0ec20, r=0xa39840, h=0xa11398, pps=0x7ffff7f66968) at src/app/srs_app_source.cpp:1718
#3 0x00000000004d4d5a in SrsRtmpConn::stream_service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:498
#4 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#5 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#6 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#7 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#8 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#9 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#10 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>,arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
SrsEdgeForwarder::SrsEdgeForwarder
#0 SrsEdgeForwarder::SrsEdgeForwarder (this=0xa3b5d0) at src/app/srs_app_edge.cpp:438
#1 0x000000000057c223 in SrsPublishEdge::SrsPublishEdge (this=0xa3aa50) at src/app/srs_app_edge.cpp:729
#2 0x00000000004e3ada in SrsSource::SrsSource (this=0xa3af10) at src/app/srs_app_source.cpp:1831
#3 0x00000000004e33eb in SrsSourceManager::fetch_or_create (this=0xa0ec20, r=0xa39840, h=0xa11398, pps=0x7ffff7f66968) at src/app/srs_app_source.cpp:1718
#4 0x00000000004d4d5a in SrsRtmpConn::stream_service_cycle (this=0xa2fc50)at src/app/srs_app_rtmp_conn.cpp:498
#5 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#6 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#7 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#8 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#9 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
SrsPlayEdge::SrsPlayEdge
#0 SrsPlayEdge::SrsPlayEdge (this=0xa3aef0) at src/app/srs_app_edge.cpp:653
#1 0x00000000004e3abd in SrsSource::SrsSource (this=0xa3af10) at src/app/srs_app_source.cpp:1830
#2 0x00000000004e33eb in SrsSourceManager::fetch_or_create (this=0xa0ec20, r=0xa39840, h=0xa11398, pps=0x7ffff7f66968) at src/app/srs_app_source.cpp:1718
#3 0x00000000004d4d5a in SrsRtmpConn::stream_service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:498
#4 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:388
#5 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa2fc50) at src/app/srs_app_rtmp_conn.cpp:209
#6 0x00000000004d10fb in SrsConnection::cycle (this=0xa2fcc8) at src/app/srs_app_conn.cpp:171
#7 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa2ff00) at src/app/srs_app_st.cpp:198
#8 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa2ff00) at src/app/srs_app_st.cpp:213
#9 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#10 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
SrsSource::on_publish

推流的时候并没有响应,要来拉流了才响应

#0 SrsSource::on_publish (this=0xa3af10) at src/app/srs_app_source.cpp:2435
#1 0x0000000000578fec in SrsEdgeIngester::start (this=0xa3b0a0) at src/app/srs_app_edge.cpp:199
#2 0x000000000057bfda in SrsPlayEdge::on_client_play (this=0xa3aef0) at src/app/srs_app_edge.cpp:682
#3 0x00000000004e727b in SrsSource::create_consumer (this=0xa3af10, conn=0xa44a18,consumer=@0x7ffff7f87528: 0xadfb90, ds=true, dm=true, dg=true) at src/app/srs_app_source.cpp:2558
#4 0x00000000004d6551 in SrsRtmpConn::playing (this=0xa449a0, source=0xa3af10) at src/app/srs_app_rtmp_conn.cpp:649
#5 0x00000000004d515c in SrsRtmpConn::stream_service_cycle (this=0xa449a0) at src/app/srs_app_rtmp_conn.cpp:524
#6 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa449a0) at src/app/srs_app_rtmp_conn.cpp:388
#7 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa449a0) at src/app/srs_app_rtmp_conn.cpp:209
#8 0x00000000004d10fb in SrsConnection::cycle (this=0xa44a18) at src/app/srs_app_conn.cpp:171
#9 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa44a90) at src/app/srs_app_st.cpp:198
#10 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa44a90) at src/app/srs_app_st.cpp:213
#11 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#12 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>,arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
#0 SrsConfig::get_vhost_edge_origin (this=0xa0fcf0, vhost="__defaultVhost__") at src/app/srs_app_config.cpp:5091
#1 0x00000000005780ca in SrsEdgeRtmpUpstream::connect (this=0xa3b670, r=0xa39e20,lb=0xa3b060) at src/app/srs_app_edge.cpp:83
#2 0x0000000000579636 in SrsEdgeIngester::do_cycle (this=0xa3b0a0) at src/app/srs_app_edge.cpp:271
#3 0x000000000057931d in SrsEdgeIngester::cycle (this=0xa3b0a0) at src/app/srs_app_edge.cpp:243
#4 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xae16d0) at src/app/srs_app_st.cpp:198
#5 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xae16d0) at src/app/srs_app_st.cpp:213
#6 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#7 0x00000000005be515 in st_thread_create (start=0x4dd509 <SrsConsumer::wait(int,long)+195>,arg=0x7ffff7f87370, joinable=0, stk_size=11400208) at sched.c:616
#8 0x0000000000000000 in ?? ()

拉流

#0 SrsConfig::get_vhost_is_edge (this=0xa0fcf0, vhost=0xa10b50) at src/app/srs_app_config.cpp:5069
#1 0x0000000000537edc in SrsConfig::get_vhost_is_edge (this=0xa0fcf0,vhost="__defaultVhost__") at src/app/srs_app_config.cpp:5065
#2 0x00000000004e724a in SrsSource::create_consumer (this=0xa3af10, conn=0xa46758, consumer=@0x7ffff7eee528: 0xa55d30, ds=true, dm=true, dg=true) at src/app/srs_app_source.cpp:2556
#3 0x00000000004d6551 in SrsRtmpConn::playing (this=0xa466e0, source=0xa3af10) at src/app/srs_app_rtmp_conn.cpp:649
#4 0x00000000004d515c in SrsRtmpConn::stream_service_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:524
#5 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:388
#6 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:209
#7 0x00000000004d10fb in SrsConnection::cycle (this=0xa46758) at src/app/srs_app_conn.cpp:171
#8 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa48660) at src/app/srs_app_st.cpp:198
#9 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa48660) at src/app/srs_app_st.cpp:213
#10 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#11 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>, arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
SrsSource::on_publish
#0 SrsSource::on_publish (this=0xa3af10) at src/app/srs_app_source.cpp:2435
#1 0x0000000000578fec in SrsEdgeIngester::start (this=0xa3b0a0) at src/app/srs_app_edge.cpp:199
#2 0x000000000057bfda in SrsPlayEdge::on_client_play (this=0xa3aef0) at src/app/srs_app_edge.cpp:682
#3 0x00000000004e727b in SrsSource::create_consumer (this=0xa3af10, conn=0xa46758, consumer=@0x7ffff7eee528: 0xa55d30, ds=true, dm=true, dg=true) at src/app/srs_app_source.cpp:2558
#4 0x00000000004d6551 in SrsRtmpConn::playing (this=0xa466e0, source=0xa3af10) at src/app/srs_app_rtmp_conn.cpp:649
#5 0x00000000004d515c in SrsRtmpConn::stream_service_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:524
#6 0x00000000004d4141 in SrsRtmpConn::service_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:388
#7 0x00000000004d2f09 in SrsRtmpConn::do_cycle (this=0xa466e0) at src/app/srs_app_rtmp_conn.cpp:209
#8 0x00000000004d10fb in SrsConnection::cycle (this=0xa46758) at src/app/srs_app_conn.cpp:171
#9 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xa48660) at src/app/srs_app_st.cpp:198
#10 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xa48660) at src/app/srs_app_st.cpp:213
#11 0x00000000005bdd9d in _st_thread_main () at sched.c:337
#12 0x00000000005be515 in st_thread_create (start=0x5bd719 <_st_vp_schedule+170>,arg=0x700000001,joinable=1, stk_size=1) at sched.c:616
SrsSource::on_audio
#0 SrsSource::on_audio (this=0xa3aef0, shared_audio=0xa39930) at src/app/srs_app_source.cpp:2120
#1 0x0000000000579d90 in SrsEdgeIngester::process_publish_message (this=0xa3b080, msg=0xa39930,redirect="") at src/app/srs_app_edge.cpp:353
#2 0x0000000000579c4c in SrsEdgeIngester::ingest (this=0xa3b080, redirect="")at src/app/srs_app_edge.cpp:339
#3 0x0000000000579742 in SrsEdgeIngester::do_cycle (this=0xa3b080) at src/app/srs_app_edge.cpp:282
#4 0x000000000057931d in SrsEdgeIngester::cycle (this=0xa3b080) at src/app/srs_app_edge.cpp:243
#5 0x0000000000509c88 in SrsSTCoroutine::cycle (this=0xab72f0) at src/app/srs_app_st.cpp:198
#6 0x0000000000509cfd in SrsSTCoroutine::pfn (arg=0xab72f0) at src/app/srs_app_st.cpp:213
#7 0x00000000005bdd9d in _st_thread_main () at sched.c:337

问题

如何保证源的唯一性,比如有2个origin,2个edge的时候。

对于SRS而言,有2个origin源站时,如果同一个url但是由不同的edge接入,进入不同的origin,此时并不能保证源的唯一性。

源站集群

https://github.com/ossrs/srs/wiki/v3_CN_OriginCluster
https://github.com/ossrs/srs/issues/464
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,716评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,558评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,431评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,127评论 0 209
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,511评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,692评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,915评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,664评论 0 202
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,412评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,616评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,105评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,424评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,098评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,096评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,869评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,748评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,641评论 2 271

推荐阅读更多精彩内容