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-09 21:46:29 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8107e5f9a6b0bd0fd72881c1e273e12e825b809d
8107e5f9
1 parent
c8466c36
for #319, raw api support set the ff_log_dir
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
65 行增加
和
11 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/kernel/srs_kernel_utility.cpp
trunk/src/kernel/srs_kernel_utility.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
8107e5f
...
...
@@ -2293,6 +2293,29 @@ int SrsConfig::raw_set_chunk_size(string chunk_size, bool& applied)
return
ret
;
}
int
SrsConfig
::
raw_set_ff_log_dir
(
string
ff_log_dir
,
bool
&
applied
)
{
int
ret
=
ERROR_SUCCESS
;
applied
=
false
;
SrsConfDirective
*
conf
=
root
->
get_or_create
(
"ff_log_dir"
);
if
(
conf
->
arg0
()
==
ff_log_dir
)
{
return
ret
;
}
conf
->
args
.
clear
();
conf
->
args
.
push_back
(
ff_log_dir
);
// directly supported reload for ff_log_dir change.
applied
=
true
;
return
ret
;
}
int
SrsConfig
::
do_reload_listen
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
8107e5f
...
...
@@ -345,6 +345,10 @@ public:
* raw set the global chunk size.
*/
virtual
int
raw_set_chunk_size
(
std
::
string
chunk_size
,
bool
&
applied
);
/**
* raw set the global ffmpeg log dir.
*/
virtual
int
raw_set_ff_log_dir
(
std
::
string
ff_log_dir
,
bool
&
applied
);
private
:
virtual
int
do_reload_listen
();
virtual
int
do_reload_pid
();
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
8107e5f
...
...
@@ -998,7 +998,14 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
std
::
string
scope
=
r
->
query_get
(
"scope"
);
std
::
string
value
=
r
->
query_get
(
"value"
);
if
(
scope
.
empty
()
||
(
scope
!=
"listen"
&&
scope
!=
"pid"
&&
scope
!=
"chunk_size"
))
{
if
(
scope
.
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED
;
srs_error
(
"raw api query invalid empty scope. ret=%d"
,
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
(
scope
!=
"listen"
&&
scope
!=
"pid"
&&
scope
!=
"chunk_size"
&&
scope
!=
"ff_log_dir"
)
{
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
);
...
...
@@ -1028,16 +1035,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
if
(
scope
==
"pid"
)
{
bool
invalid
=
value
.
empty
();
if
(
!
invalid
)
{
invalid
=
!
srs_string_starts_with
(
value
,
"./"
)
&&
!
srs_string_starts_with
(
value
,
"/tmp"
)
&&
!
srs_string_starts_with
(
value
,
"/var"
);
}
if
(
!
invalid
)
{
invalid
=
!
srs_string_ends_with
(
value
,
".pid"
);
}
if
(
invalid
)
{
if
(
value
.
empty
()
||
!
srs_string_starts_with
(
value
,
"./"
,
"/tmp/"
,
"/var/"
)
||
!
srs_string_ends_with
(
value
,
".pid"
))
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_PARAMS
;
srs_error
(
"raw api update check pid=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
...
...
@@ -1059,6 +1057,17 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_error
(
"raw api update chunk_size=%s/%d failed. ret=%d"
,
value
.
c_str
(),
csv
,
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
if
(
scope
==
"ff_log_dir"
)
{
if
(
value
.
empty
()
||
(
value
!=
"/dev/null"
&&
!
srs_string_starts_with
(
value
,
"./"
,
"/tmp/"
,
"/var/"
)))
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_PARAMS
;
srs_error
(
"raw api update check ff_log_dir=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
((
ret
=
_srs_config
->
raw_set_ff_log_dir
(
value
,
applied
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"raw api update ff_log_dir=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
// whether the config applied.
...
...
trunk/src/kernel/srs_kernel_utility.cpp
查看文件 @
8107e5f
...
...
@@ -280,6 +280,21 @@ bool srs_string_starts_with(string str, string flag)
return
str
.
find
(
flag
)
==
0
;
}
bool
srs_string_starts_with
(
string
str
,
string
flag0
,
string
flag1
)
{
return
srs_string_starts_with
(
str
,
flag0
)
||
srs_string_starts_with
(
str
,
flag1
);
}
bool
srs_string_starts_with
(
string
str
,
string
flag0
,
string
flag1
,
string
flag2
)
{
return
srs_string_starts_with
(
str
,
flag0
,
flag1
)
||
srs_string_starts_with
(
str
,
flag2
);
}
bool
srs_string_starts_with
(
string
str
,
string
flag0
,
string
flag1
,
string
flag2
,
string
flag3
)
{
return
srs_string_starts_with
(
str
,
flag0
,
flag1
,
flag2
)
||
srs_string_starts_with
(
str
,
flag3
);
}
bool
srs_string_contains
(
string
str
,
string
flag
)
{
return
str
.
find
(
flag
)
!=
string
::
npos
;
...
...
trunk/src/kernel/srs_kernel_utility.hpp
查看文件 @
8107e5f
...
...
@@ -68,6 +68,9 @@ extern std::string srs_string_remove(std::string str, std::string remove_chars);
extern
bool
srs_string_ends_with
(
std
::
string
str
,
std
::
string
flag
);
// whether string starts with
extern
bool
srs_string_starts_with
(
std
::
string
str
,
std
::
string
flag
);
extern
bool
srs_string_starts_with
(
std
::
string
str
,
std
::
string
flag0
,
std
::
string
flag1
);
extern
bool
srs_string_starts_with
(
std
::
string
str
,
std
::
string
flag0
,
std
::
string
flag1
,
std
::
string
flag2
);
extern
bool
srs_string_starts_with
(
std
::
string
str
,
std
::
string
flag0
,
std
::
string
flag1
,
std
::
string
flag2
,
std
::
string
flag3
);
// whether string contains with
extern
bool
srs_string_contains
(
std
::
string
str
,
std
::
string
flag
);
// split the string by flag to array.
...
...
请
注册
或
登录
后发表评论