音視頻流媒體開發(fā)【六十四】RTMP/HLS/HTTP-FLV流媒體服務(wù)器分7-SRS流媒體框架-edge集群

音視頻流媒體開發(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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市遗嗽,隨后出現(xiàn)的幾起案子粘我,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,734評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件征字,死亡現(xiàn)場(chǎng)離奇詭異都弹,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)匙姜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,931評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門畅厢,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人氮昧,你說(shuō)我怎么就攤上這事框杜。” “怎么了袖肥?”我有些...
    開封第一講書人閱讀 164,133評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵咪辱,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我椎组,道長(zhǎng)油狂,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,532評(píng)論 1 293
  • 正文 為了忘掉前任寸癌,我火速辦了婚禮专筷,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘蒸苇。我一直安慰自己磷蛹,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,585評(píng)論 6 392
  • 文/花漫 我一把揭開白布溪烤。 她就那樣靜靜地躺著味咳,像睡著了一般。 火紅的嫁衣襯著肌膚如雪氛什。 梳的紋絲不亂的頭發(fā)上莺葫,一...
    開封第一講書人閱讀 51,462評(píng)論 1 302
  • 那天匪凉,我揣著相機(jī)與錄音枪眉,去河邊找鬼。 笑死再层,一個(gè)胖子當(dāng)著我的面吹牛贸铜,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播聂受,決...
    沈念sama閱讀 40,262評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼蒿秦,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了蛋济?” 一聲冷哼從身側(cè)響起棍鳖,我...
    開封第一講書人閱讀 39,153評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后渡处,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體镜悉,經(jīng)...
    沈念sama閱讀 45,587評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,792評(píng)論 3 336
  • 正文 我和宋清朗相戀三年医瘫,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了侣肄。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,919評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡醇份,死狀恐怖稼锅,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情僚纷,我是刑警寧澤矩距,帶...
    沈念sama閱讀 35,635評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站怖竭,受9級(jí)特大地震影響剩晴,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜侵状,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,237評(píng)論 3 329
  • 文/蒙蒙 一赞弥、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧趣兄,春花似錦绽左、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,855評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至蹋凝,卻和暖如春鲁纠,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背鳍寂。 一陣腳步聲響...
    開封第一講書人閱讀 32,983評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工改含, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人迄汛。 一個(gè)月前我還...
    沈念sama閱讀 48,048評(píng)論 3 370
  • 正文 我出身青樓捍壤,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親鞍爱。 傳聞我的和親對(duì)象是個(gè)殘疾皇子鹃觉,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,864評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容