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
winlin
2015-09-01 13:33:49 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
310b5a14cb7896af1525977b36a3c0815e363cc1
310b5a14
1 parent
06c7ae62
for #319, support minimal query api
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
33 行增加
和
1 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_config.cpp
查看文件 @
310b5a1
...
...
@@ -1468,6 +1468,24 @@ int SrsConfig::persistence()
return
ret
;
}
int
SrsConfig
::
minimal_to_json
(
SrsAmf0Object
*
obj
)
{
int
ret
=
ERROR_SUCCESS
;
for
(
int
i
=
0
;
i
<
(
int
)
root
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
dir
=
root
->
directives
.
at
(
i
);
if
(
dir
->
is_vhost
())
{
continue
;
}
if
(
dir
->
name
==
"listen"
)
{
obj
->
set
(
dir
->
name
,
dir
->
dumps_args
());
}
}
return
ret
;
}
int
SrsConfig
::
global_to_json
(
SrsAmf0Object
*
obj
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
310b5a1
...
...
@@ -322,6 +322,10 @@ public:
*/
virtual
int
global_to_json
(
SrsAmf0Object
*
obj
);
/**
* dumps the minimal sections to json.
*/
virtual
int
minimal_to_json
(
SrsAmf0Object
*
obj
);
/**
* dumps the vhost section to json.
*/
virtual
int
vhost_to_json
(
SrsConfDirective
*
vhost
,
SrsAmf0Object
*
obj
);
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
310b5a1
...
...
@@ -917,6 +917,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// for rpc=query, to get the configs of server.
// @param scope the scope to query for config, it can be:
// global, the configs belongs to the root, donot includes any sub directives.
// minimal, the minimal summary of server, for preview stream to got the port serving.
// vhost, the configs for specified vhost by @param vhost.
// @param vhost the vhost name for @param scope is vhost to query config.
// for the default vhost, must be __defaultVhost__
...
...
@@ -929,7 +930,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
std
::
string
scope
=
r
->
query_get
(
"scope"
);
std
::
string
vhost
=
r
->
query_get
(
"vhost"
);
if
(
scope
.
empty
()
||
(
scope
!=
"global"
&&
scope
!=
"vhost"
))
{
if
(
scope
.
empty
()
||
(
scope
!=
"global"
&&
scope
!=
"vhost"
&&
scope
!=
"minimal"
))
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED
;
srs_error
(
"raw api query invalid scope=%s. ret=%d"
,
scope
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
...
...
@@ -957,6 +958,15 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_error
(
"raw api query vhost failed. ret=%d"
,
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
if
(
scope
==
"minimal"
)
{
SrsAmf0Object
*
data
=
SrsAmf0Any
::
object
();
obj
->
set
(
"minimal"
,
data
);
// query minimal scope.
if
((
ret
=
_srs_config
->
minimal_to_json
(
data
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"raw api query global failed. ret=%d"
,
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
{
SrsAmf0Object
*
data
=
SrsAmf0Any
::
object
();
obj
->
set
(
"global"
,
data
);
...
...
请
注册
或
登录
后发表评论