音視頻流媒體開發(fā)-目錄
iOS知識點-目錄
Android-目錄
Flutter-目錄
數(shù)據(jù)結(jié)構(gòu)與算法-目錄
uni-pp-目錄
edge原理
SRS的Edge主要解決?條流有?量播放請求的場景,?如?個流有上萬?觀看。SRS的Edge 能對接所有的標(biāo)準(zhǔn)RTMP源站服務(wù)器。

備注:Edge一般負載高,SRS支持的并發(fā)足夠跑滿千兆網(wǎng)帶寬了。
Remark: SRS Edge does not support Transcoding, DVR and HLS, which is supported by SRS Origin Server.
Edge的主要應(yīng)用場景:
- CDN/VDN大規(guī)模集群,客戶眾多流眾多需要按需回源。
- 小規(guī)模集群,但是流比較多,需要按需回源。
- 骨干帶寬低,邊緣服務(wù)器強悍,可以使用多層edge,降低上層BGP帶寬。
注意:edge可以從源站拉流,也可以將流轉(zhuǎn)發(fā)給源站。也就是說,播放edge上的流時,edge會 回源拉流;推流到edge上時,edge會直接將流轉(zhuǎn)發(fā)給源站。
注意:若只需要中轉(zhuǎn)流給源站,不必用forward,直接使用edge模式即可??梢灾苯又С滞屏?和拉流的中轉(zhuǎn),簡單快捷。Forward應(yīng)用于目標(biāo)服務(wù)器是多個,譬如將一路流主動送給多路服務(wù) 器;edge雖然配置了多臺服務(wù)器,但是只用了一臺,有故障時才切換。
注意:優(yōu)先使用edge,除非知道必須用forward,才使用forward。
概念
所謂邊緣edge服務(wù)器,就是邊緣直播緩存服務(wù)器,配置時指定為remote模式和origin(指定一個或多個源站IP),這個邊緣edge服務(wù)器就是源站的緩存了。
當(dāng)用戶推流到邊緣服務(wù)器時,邊緣直接將流轉(zhuǎn)發(fā)給源站。譬如源站在北京BGP機房,湖南有個 電信ADSL用戶要推流發(fā)布自己的直播流,要是直接推流到北京BGP可能效果不是很好,可以在 湖南電信機房部署一個邊緣,用戶推流到湖南邊緣,邊緣轉(zhuǎn)發(fā)給北京源站BGP。
當(dāng)用戶播放邊緣服務(wù)器的流時,邊緣服務(wù)器看有沒有緩存,若緩存了就直接將流發(fā)給客戶端。 若沒有緩存,則發(fā)起一路回源鏈接,從源站取數(shù)據(jù)源源不斷放到自己的緩存隊列。也就是說, 多個客戶端連接到邊緣時,只有一路回源。這種結(jié)構(gòu)在CDN是最典型的部署結(jié)構(gòu)。譬如北京源站, 在全國32個省每個省都部署了10臺服務(wù)器,一共就有320臺邊緣,假設(shè)每個省1臺邊緣服務(wù)器都有 2000用戶觀看,那么就有64萬用戶,每秒鐘集群發(fā)送640Gbps數(shù)據(jù);而回源鏈接只有320個, 實現(xiàn)了大規(guī)模分發(fā)。
邊緣edge服務(wù)器,實際上是解決大并發(fā)問題產(chǎn)生的分布式集群結(jié)構(gòu)。SRS的邊緣可以指定多個源站, 在源站出現(xiàn)故障時會自動切換到下一個源站,不影響用戶觀看,具有最佳的容錯性,用戶完全不會覺察。
edge配置
第一步,編寫SRS源站配置文件。詳細參考RTMP分發(fā)和Edge
將以下內(nèi)容保存為文件,譬如 conf/origin.conf ,服務(wù)器啟動時指定該配置文件(srs的conf文件夾有該文件)。
# conf/origin.conf
listen 1935;
max_connections 1000;
pid objs/origin.pid;
srs_log_file ./objs/origin.log;
vhost __defaultVhost__ {
}
第二步,編寫SRS邊緣配置文件。詳細參考RTMP分發(fā)和Edge
將以下內(nèi)容保存為文件,譬如 conf/edge.conf ,服務(wù)器啟動時指定該配置文件(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分發(fā)和Edge
./objs/srs -c conf/origin1.conf
./objs/srs -c conf/edge1.conf
./objs/srs -c conf/edge2.conf
第四步,啟動推流編碼器。詳細參考RTMP分發(fā)和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分發(fā)和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都換成部署的服務(wù)器IP地址。
edge源碼分析
提出問題:
- 當(dāng)像edge服務(wù)器推流時,edge向origin源站做了什么操作,怎么保證集群推流path的唯一性,特別是有2個origin時
- edge作為拉流端,需要從origin拉流時做了什么?
從配置文件入手
vhost __defaultVhost__ {
cluster {
mode remote;
origin 127.0.0.1:1935;
}
}
核心類
SrsEdgeIngester 從源站拉流
SrsPublishEdge 推流到源站,實際是調(diào)用SrsEdgeForwarder來實現(xiàn)
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
推流的時候,對于邊緣節(jié)點在收到數(shù)據(jù)的時候是從SrsPublishRecvThread 發(fā)給了SrsEdgeForwarder 的queue,然后SrsEdgeForwarder在do_cycle里將數(shù)據(jù)讀取出來并推送給源站。
#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
推流的時候并沒有響應(yīng),要來拉流了才響應(yīng)
#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