Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
胡斌
2017-05-13 08:38:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
155f68f3caa1bff863878c43a574327cc44f6c08
155f68f3
1 parent
44530717
add config directive forward_in_turn to support forward streams to one of the server
in forward_in_turn list in turn
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
56 行增加
和
1 行删除
trunk/conf/forward.master.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_source.cpp
trunk/conf/forward.master.conf
查看文件 @
155f68f
...
...
@@ -9,6 +9,8 @@ daemon off;
srs_log_tank
console
;
vhost
__
defaultVhost__
{
forward
127
.
0
.
0
.
1
:
19350
;
#select on of the listed servers in turn to forward,not all of them
forward_in_turn
127
.
0
.
0
.
1
:
19351
127
.
0
.
0
.
1
:
19352
;
#the forward destination server type,default true. if the server is not srs server,connect app maybe fail,try config as false
forward_server_srs
true
;
}
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
155f68f
...
...
@@ -1823,7 +1823,7 @@ int SrsConfig::check_config()
&&
n
!=
"dvr"
&&
n
!=
"ingest"
&&
n
!=
"hls"
&&
n
!=
"http_hooks"
&&
n
!=
"gop_cache"
&&
n
!=
"queue_length"
&&
n
!=
"refer"
&&
n
!=
"refer_publish"
&&
n
!=
"refer_play"
&&
n
!=
"forward"
&&
n
!=
"forward_server_srs"
&&
n
!=
"transcode"
&&
n
!=
"bandcheck"
&&
n
!=
"forward"
&&
n
!=
"forward_server_srs"
&&
n
!=
"
forward_in_turn"
&&
n
!=
"
transcode"
&&
n
!=
"bandcheck"
&&
n
!=
"time_jitter"
&&
n
!=
"mix_correct"
&&
n
!=
"atc"
&&
n
!=
"atc_auto"
&&
n
!=
"debug_srs_upnode"
...
...
@@ -2772,6 +2772,17 @@ bool SrsConfig::get_forward_server_srs(string vhost)
return
conf
->
arg0
()
==
"true"
;
}
SrsConfDirective
*
SrsConfig
::
get_forward_in_turn
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
NULL
;
}
return
conf
->
get
(
"forward_in_turn"
);
}
SrsConfDirective
*
SrsConfig
::
get_vhost_http_hooks
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
155f68f
...
...
@@ -573,6 +573,10 @@ public:
* get the forward server type of vhost,if srs return true,else false.
*/
virtual
bool
get_forward_server_srs
(
std
::
string
vhost
);
/**
* get the forward_in_turn directive of vhost.
*/
virtual
SrsConfDirective
*
get_forward_in_turn
(
std
::
string
vhost
);
// http_hooks section
private:
/**
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
155f68f
...
...
@@ -2448,6 +2448,44 @@ int SrsSource::create_forwarders()
}
}
//forward a server in forward_in_turn
static
int
server_index
=
0
;
conf
=
_srs_config
->
get_forward_in_turn
(
_req
->
vhost
);
if
(
!
conf
){
return
ret
;
}
int
servers_size
=
(
int
)
conf
->
args
.
size
();
if
(
servers_size
<=
0
){
return
ret
;
}
if
(
server_index
>=
servers_size
){
server_index
=
0
;
}
std
::
string
forward_server
=
conf
->
args
.
at
(
server_index
);
server_index
++
;
SrsForwarder
*
forwarder
=
new
SrsForwarder
(
this
);
forwarders
.
push_back
(
forwarder
);
// initialize the forwarder with request.
if
((
ret
=
forwarder
->
initialize
(
_req
,
forward_server
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
double
queue_size
=
_srs_config
->
get_queue_length
(
_req
->
vhost
);
forwarder
->
set_queue_size
(
queue_size
);
if
((
ret
=
forwarder
->
on_publish
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"start forwarder failed. "
"vhost=%s, app=%s, stream=%s, forward-to=%s"
,
_req
->
vhost
.
c_str
(),
_req
->
app
.
c_str
(),
_req
->
stream
.
c_str
(),
forward_server
.
c_str
());
return
ret
;
}
return
ret
;
}
...
...
请
注册
或
登录
后发表评论