音視頻流媒體開發(fā)-目錄
iOS知識(shí)點(diǎn)-目錄
Android-目錄
Flutter-目錄
數(shù)據(jù)結(jié)構(gòu)與算法-目錄
uni-pp-目錄
edge原理
SRS的Edge主要解決?條流有?量播放請(qǐng)求的場(chǎng)景,?如?個(gè)流有上萬(wàn)?觀看恬砂。SRS的Edge 能對(duì)接所有的標(biāo)準(zhǔn)RTMP源站服務(wù)器。
備注:Edge一般負(fù)載高,SRS支持的并發(fā)足夠跑滿千兆網(wǎng)帶寬了。
Remark: SRS Edge does not support Transcoding, DVR and HLS, which is supported by SRS Origin Server.
Edge的主要應(yīng)用場(chǎng)景:
- CDN/VDN大規(guī)模集群蝗敢,客戶眾多流眾多需要按需回源砸西。
- 小規(guī)模集群,但是流比較多刽漂,需要按需回源。
- 骨干帶寬低弟孟,邊緣服務(wù)器強(qiáng)悍贝咙,可以使用多層edge,降低上層BGP帶寬拂募。
注意:edge可以從源站拉流庭猩,也可以將流轉(zhuǎn)發(fā)給源站。也就是說(shuō)陈症,播放edge上的流時(shí)蔼水,edge會(huì) 回源拉流;推流到edge上時(shí)录肯,edge會(huì)直接將流轉(zhuǎn)發(fā)給源站趴腋。
注意:若只需要中轉(zhuǎn)流給源站,不必用forward论咏,直接使用edge模式即可优炬。可以直接支持推流 和拉流的中轉(zhuǎn)厅贪,簡(jiǎn)單快捷穿剖。Forward應(yīng)用于目標(biāo)服務(wù)器是多個(gè),譬如將一路流主動(dòng)送給多路服務(wù) 器卦溢;edge雖然配置了多臺(tái)服務(wù)器糊余,但是只用了一臺(tái),有故障時(shí)才切換单寂。
注意:優(yōu)先使用edge贬芥,除非知道必須用forward,才使用forward宣决。
概念
所謂邊緣edge服務(wù)器蘸劈,就是邊緣直播緩存服務(wù)器,配置時(shí)指定為remote模式和origin(指定一個(gè)或多個(gè)源站IP)尊沸,這個(gè)邊緣edge服務(wù)器就是源站的緩存了威沫。
當(dāng)用戶推流到邊緣服務(wù)器時(shí)贤惯,邊緣直接將流轉(zhuǎn)發(fā)給源站。譬如源站在北京BGP機(jī)房棒掠,湖南有個(gè) 電信ADSL用戶要推流發(fā)布自己的直播流孵构,要是直接推流到北京BGP可能效果不是很好,可以在 湖南電信機(jī)房部署一個(gè)邊緣烟很,用戶推流到湖南邊緣颈墅,邊緣轉(zhuǎn)發(fā)給北京源站BGP堕汞。
當(dāng)用戶播放邊緣服務(wù)器的流時(shí)壹罚,邊緣服務(wù)器看有沒(méi)有緩存,若緩存了就直接將流發(fā)給客戶端饶氏。 若沒(méi)有緩存芹橡,則發(fā)起一路回源鏈接毒坛,從源站取數(shù)據(jù)源源不斷放到自己的緩存隊(duì)列。也就是說(shuō)林说, 多個(gè)客戶端連接到邊緣時(shí)煎殷,只有一路回源。這種結(jié)構(gòu)在CDN是最典型的部署結(jié)構(gòu)述么。譬如北京源站蝌数, 在全國(guó)32個(gè)省每個(gè)省都部署了10臺(tái)服務(wù)器愕掏,一共就有320臺(tái)邊緣度秘,假設(shè)每個(gè)省1臺(tái)邊緣服務(wù)器都有 2000用戶觀看,那么就有64萬(wàn)用戶饵撑,每秒鐘集群發(fā)送640Gbps數(shù)據(jù)剑梳;而回源鏈接只有320個(gè), 實(shí)現(xiàn)了大規(guī)模分發(fā)滑潘。
邊緣edge服務(wù)器垢乙,實(shí)際上是解決大并發(fā)問(wèn)題產(chǎn)生的分布式集群結(jié)構(gòu)。SRS的邊緣可以指定多個(gè)源站语卤, 在源站出現(xiàn)故障時(shí)會(huì)自動(dòng)切換到下一個(gè)源站追逮,不影響用戶觀看,具有最佳的容錯(cuò)性粹舵,用戶完全不會(huì)覺察钮孵。
edge配置
第一步,編寫SRS源站配置文件眼滤。詳細(xì)參考RTMP分發(fā)和Edge
將以下內(nèi)容保存為文件巴席,譬如 conf/origin.conf ,服務(wù)器啟動(dòng)時(shí)指定該配置文件(srs的conf文件夾有該文件)诅需。
# conf/origin.conf
listen 1935;
max_connections 1000;
pid objs/origin.pid;
srs_log_file ./objs/origin.log;
vhost __defaultVhost__ {
}
第二步漾唉,編寫SRS邊緣配置文件荧库。詳細(xì)參考RTMP分發(fā)和Edge
將以下內(nèi)容保存為文件,譬如 conf/edge.conf 赵刑,服務(wù)器啟動(dòng)時(shí)指定該配置文件(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;
}
}
第三步,啟動(dòng)SRS料睛。詳細(xì)參考RTMP分發(fā)和Edge
./objs/srs -c conf/origin1.conf
./objs/srs -c conf/edge1.conf
./objs/srs -c conf/edge2.conf
第四步丐箩,啟動(dòng)推流編碼器。詳細(xì)參考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流屎勘。詳細(xì)參考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
備注:請(qǐng)將所有實(shí)例的IP地址192.168.1.170都換成部署的服務(wù)器IP地址瓤摧。
edge源碼分析
提出問(wèn)題:
- 當(dāng)像edge服務(wù)器推流時(shí),edge向origin源站做了什么操作玉吁,怎么保證集群推流path的唯一性照弥,特別是有2個(gè)origin時(shí)
- edge作為拉流端,需要從origin拉流時(shí)做了什么进副?
從配置文件入手
vhost __defaultVhost__ {
cluster {
mode remote;
origin 127.0.0.1:1935;
}
}
核心類
SrsEdgeIngester 從源站拉流
SrsPublishEdge 推流到源站这揣,實(shí)際是調(diào)用SrsEdgeForwarder來(lái)實(shí)現(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
推流的時(shí)候,對(duì)于邊緣節(jié)點(diǎn)在收到數(shù)據(jù)的時(shí)候是從SrsPublishRecvThread 發(fā)給了SrsEdgeForwarder 的queue影斑,然后SrsEdgeForwarder在do_cycle里將數(shù)據(jù)讀取出來(lái)并推送給源站给赞。
#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
推流的時(shí)候并沒(méi)有響應(yīng),要來(lái)拉流了才響應(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
問(wèn)題
如何保證源的唯一性矫户,比如有2個(gè)origin片迅,2個(gè)edge的時(shí)候。
對(duì)于SRS而言皆辽,有2個(gè)origin源站時(shí)柑蛇,如果同一個(gè)url但是由不同的edge接入,進(jìn)入不同的origin驱闷,此時(shí)并不能保證源的唯一性耻台。
源站集群
https://github.com/ossrs/srs/wiki/v3_CN_OriginCluster
https://github.com/ossrs/srs/issues/464