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 21:27:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c8466c36bd3982d314c7243acb2b8b718126f2b5
c8466c36
1 parent
2cfb7161
for #319, raw api support update the global RTMP chunk_size.
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
68 行增加
和
9 行删除
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_utility.cpp
trunk/src/app/srs_app_utility.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
c8466c3
...
...
@@ -2270,6 +2270,29 @@ int SrsConfig::raw_set_pid(string pid, bool& applied)
return
ret
;
}
int
SrsConfig
::
raw_set_chunk_size
(
string
chunk_size
,
bool
&
applied
)
{
int
ret
=
ERROR_SUCCESS
;
applied
=
false
;
SrsConfDirective
*
conf
=
root
->
get_or_create
(
"chunk_size"
);
if
(
conf
->
arg0
()
==
chunk_size
)
{
return
ret
;
}
conf
->
args
.
clear
();
conf
->
args
.
push_back
(
chunk_size
);
// directly supported reload for chunk_size change.
applied
=
true
;
return
ret
;
}
int
SrsConfig
::
do_reload_listen
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
c8466c3
...
...
@@ -341,6 +341,10 @@ public:
* raw set the global pid.
*/
virtual
int
raw_set_pid
(
std
::
string
pid
,
bool
&
applied
);
/**
* raw set the global chunk size.
*/
virtual
int
raw_set_chunk_size
(
std
::
string
chunk_size
,
bool
&
applied
);
private
:
virtual
int
do_reload_listen
();
virtual
int
do_reload_pid
();
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
c8466c3
...
...
@@ -986,8 +986,9 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// @param value the updated value for scope.
// possible updates:
// @param scope @param value value-description
// global.listen 1935,1936 the port list.
// global.pid ./objs/srs.pid the pid file of srs.
// listen 1935,1936 the port list.
// pid ./objs/srs.pid the pid file of srs.
// chunk_size 60000 the global RTMP chunk_size.
if
(
rpc
==
"update"
)
{
if
(
!
allow_update
)
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_DISABLED
;
...
...
@@ -997,14 +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
!=
"
global.listen"
&&
scope
!=
"global.pid
"
))
{
if
(
scope
.
empty
()
||
(
scope
!=
"
listen"
&&
scope
!=
"pid"
&&
scope
!=
"chunk_size
"
))
{
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
);
}
bool
applied
=
false
;
if
(
scope
==
"
global.
listen"
)
{
if
(
scope
==
"listen"
)
{
vector
<
string
>
eps
=
srs_string_split
(
value
,
","
);
bool
invalid
=
eps
.
empty
();
...
...
@@ -1018,15 +1019,15 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
}
if
(
invalid
)
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_PARAMS
;
srs_error
(
"raw api update check
global.
listen=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
srs_error
(
"raw api update check listen=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
((
ret
=
_srs_config
->
raw_set_listen
(
eps
,
applied
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"raw api update
global.
listen=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
srs_error
(
"raw api update listen=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
if
(
scope
==
"
global.
pid"
)
{
}
else
if
(
scope
==
"pid"
)
{
bool
invalid
=
value
.
empty
();
if
(
!
invalid
)
{
invalid
=
!
srs_string_starts_with
(
value
,
"./"
)
...
...
@@ -1038,12 +1039,24 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
}
if
(
invalid
)
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_PARAMS
;
srs_error
(
"raw api update check
global.
pid=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
srs_error
(
"raw api update check pid=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
((
ret
=
_srs_config
->
raw_set_pid
(
value
,
applied
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"raw api update global.pid=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
srs_error
(
"raw api update pid=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
else
if
(
scope
==
"chunk_size"
)
{
int
csv
=
::
atoi
(
value
.
c_str
());
if
(
csv
<
128
||
csv
>
65535
||
!
srs_is_digit_number
(
value
))
{
ret
=
ERROR_SYSTEM_CONFIG_RAW_PARAMS
;
srs_error
(
"raw api update check chunk_size=%s/%d failed. ret=%d"
,
value
.
c_str
(),
csv
,
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
((
ret
=
_srs_config
->
raw_set_chunk_size
(
value
,
applied
))
!=
ERROR_SUCCESS
)
{
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
);
}
}
...
...
trunk/src/app/srs_app_utility.cpp
查看文件 @
c8466c3
...
...
@@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include <map>
using
namespace
std
;
...
...
@@ -1355,6 +1356,17 @@ string srs_get_peer_ip(int fd)
return
ip
;
}
bool
srs_is_digit_number
(
const
string
&
str
)
{
if
(
str
.
empty
())
{
return
false
;
}
int
v
=
::
atoi
(
str
.
c_str
());
int
powv
=
(
int
)
pow
(
10
,
str
.
length
()
-
1
);
return
v
/
powv
>=
1
&&
v
/
powv
<=
9
;
}
void
srs_api_dump_summaries
(
SrsAmf0Object
*
obj
)
{
SrsRusage
*
r
=
srs_get_system_rusage
();
...
...
trunk/src/app/srs_app_utility.hpp
查看文件 @
c8466c3
...
...
@@ -669,6 +669,13 @@ extern int srs_get_local_port(int fd);
// where peer ip is the client public ip which connected to server.
extern
std
::
string
srs_get_peer_ip
(
int
fd
);
// whether string is digit number
// is_digit("1234567890") === true
// is_digit("0123456789") === false
// is_digit("1234567890a") === false
// is_digit("a1234567890") === false
extern
bool
srs_is_digit_number
(
const
std
::
string
&
str
);
// dump summaries for /api/v1/summaries.
extern
void
srs_api_dump_summaries
(
SrsAmf0Object
*
obj
);
...
...
请
注册
或
登录
后发表评论