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-04-10 14:44:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5d37e47783abcdd3d7aa6d2fb12fd9f059ee03bf
5d37e477
1 parent
0a7cea06
support config the hls_nb_notify.
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
39 行增加
和
6 行删除
trunk/conf/full.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/app/srs_app_http_hooks.hpp
trunk/conf/full.conf
查看文件 @
5d37e47
...
...
@@ -613,6 +613,11 @@ vhost with-hls.srs.com {
# whether cleanup the old ts files.
# default: on
hls_cleanup
on
;
# the max size to notify hls,
# to read max bytes from ts of specified cdn network,
# @remark only used when on_hls_notify is config.
# default: 64
hls_nb_notify
64
;
# on_hls, never config in here, should config in http_hooks.
# for the hls http callback, @see http_hooks.on_hls of vhost hooks.callback.srs.com
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
5d37e47
...
...
@@ -1487,7 +1487,7 @@ int SrsConfig::check_config()
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if
(
m
!=
"enabled"
&&
m
!=
"hls_entry_prefix"
&&
m
!=
"hls_path"
&&
m
!=
"hls_fragment"
&&
m
!=
"hls_window"
&&
m
!=
"hls_on_error"
&&
m
!=
"hls_storage"
&&
m
!=
"hls_mount"
&&
m
!=
"hls_td_ratio"
&&
m
!=
"hls_aof_ratio"
&&
m
!=
"hls_acodec"
&&
m
!=
"hls_vcodec"
&&
m
!=
"hls_m3u8_file"
&&
m
!=
"hls_ts_file"
&&
m
!=
"hls_ts_floor"
&&
m
!=
"hls_cleanup"
&&
m
!=
"hls_m3u8_file"
&&
m
!=
"hls_ts_file"
&&
m
!=
"hls_ts_floor"
&&
m
!=
"hls_cleanup"
&&
m
!=
"hls_nb_notify"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost hls directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
...
...
@@ -2440,6 +2440,22 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost)
return
conf
->
get
(
"on_hls_notify"
);
}
int
SrsConfig
::
get_vhost_hls_nb_notify
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost_http_hooks
(
vhost
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_HLS_NB_NOTIFY
;
}
conf
=
conf
->
get
(
"hls_nb_notify"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
SRS_CONF_DEFAULT_HLS_NB_NOTIFY
;
}
return
::
atoi
(
conf
->
arg0
().
c_str
());
}
bool
SrsConfig
::
get_bw_check_enabled
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
5d37e47
...
...
@@ -63,6 +63,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
...
...
@@ -651,6 +652,11 @@ public:
* @return the on_hls_notify callback directive, the args is the url to callback.
*/
virtual
SrsConfDirective
*
get_vhost_on_hls_notify
(
std
::
string
vhost
);
/**
* get the size of bytes to read from cdn network, for the on_hls_notify callback,
* that is, to read max bytes of the bytes from the callback, or timeout or error.
*/
virtual
int
get_vhost_hls_nb_notify
(
std
::
string
vhost
);
// bwct(bandwidth check tool) section
public:
/**
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
5d37e47
...
...
@@ -240,9 +240,10 @@ int SrsDvrAsyncCallOnHlsNotify::call()
return
ret
;
}
int
nb_notify
=
_srs_config
->
get_vhost_hls_nb_notify
(
req
->
vhost
);
for
(
int
i
=
0
;
i
<
(
int
)
on_hls
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_hls
->
args
.
at
(
i
);
if
((
ret
=
SrsHttpHooks
::
on_hls_notify
(
url
,
req
,
ts_url
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsHttpHooks
::
on_hls_notify
(
url
,
req
,
ts_url
,
nb_notify
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client on_hls_notify failed. url=%s, ts=%s, ret=%d"
,
url
.
c_str
(),
ts_url
.
c_str
(),
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
5d37e47
...
...
@@ -329,7 +329,7 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, doubl
return
ret
;
}
int
SrsHttpHooks
::
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
)
int
SrsHttpHooks
::
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -365,9 +365,13 @@ int SrsHttpHooks::on_hls_notify(std::string url, SrsRequest* req, std::string ts
int
nb_read
=
0
;
ISrsHttpResponseReader
*
br
=
msg
->
body_reader
();
if
(
!
br
->
eof
())
{
while
(
nb_read
<
nb_notify
&&
!
br
->
eof
())
{
char
buf
[
64
];
// only read a little of bytes of ts.
ret
=
br
->
read
(
buf
,
64
,
&
nb_read
);
int
nb_buf
=
64
;
if
((
ret
=
br
->
read
(
buf
,
nb_buf
,
&
nb_buf
))
!=
ERROR_SUCCESS
)
{
break
;
}
nb_read
+=
nb_buf
;
}
int
spenttime
=
(
int
)(
srs_update_system_time_ms
()
-
starttime
);
...
...
trunk/src/app/srs_app_http_hooks.hpp
查看文件 @
5d37e47
...
...
@@ -110,8 +110,9 @@ public:
* @param url the api server url, to process the event.
* ignore if empty.
* @param ts_url the ts uri, used to replace the variable [ts_url] in url.
* @param nb_notify the max bytes to read from notify server.
*/
static
int
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
);
static
int
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
);
private
:
static
int
do_post
(
std
::
string
url
,
std
::
string
req
,
int
&
code
,
std
::
string
&
res
);
};
...
...
请
注册
或
登录
后发表评论