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-05-30 10:48:02 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d611bb6b45312e4c92acfea462e1f7206b446d9a
d611bb6b
1 parent
567d84e9
for #209, server cycle to enable the hls to cleanup. do dispose
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
109 行增加
和
3 行删除
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_hls.hpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/conf/full.conf
查看文件 @
d611bb6
...
...
@@ -618,9 +618,14 @@ vhost with-hls.srs.com {
# h264, vn
# default: h264
hls_vcodec
h264
;
# whether cleanup the old ts files.
# whether cleanup the old
expired
ts files.
# default: on
hls_cleanup
on
;
# the timeout in seconds to dispose the hls,
# dispose is to remove all hls files, m3u8 and ts files.
# when timeout or server terminate, dispose hls.
# default: 300
hls_dispose
300
;
# 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.
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
d611bb6
...
...
@@ -1564,7 +1564,8 @@ 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_nb_notify"
&&
m
!=
"hls_wait_keyframe"
&&
m
!=
"hls_m3u8_file"
&&
m
!=
"hls_ts_file"
&&
m
!=
"hls_ts_floor"
&&
m
!=
"hls_cleanup"
&&
m
!=
"hls_nb_notify"
&&
m
!=
"hls_wait_keyframe"
&&
m
!=
"hls_dispose"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost hls directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
...
...
@@ -3561,6 +3562,24 @@ bool SrsConfig::get_hls_cleanup(string vhost)
return
SRS_CONF_PERFER_TRUE
(
conf
->
arg0
());
}
int
SrsConfig
::
get_hls_dispose
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_hls
(
vhost
);
int
DEFAULT
=
300
;
if
(
!
conf
)
{
return
DEFAULT
;
}
conf
=
conf
->
get
(
"hls_dispose"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
DEFAULT
;
}
return
::
atoi
(
conf
->
arg0
().
c_str
());
}
bool
SrsConfig
::
get_hls_wait_keyframe
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
d611bb6
...
...
@@ -985,6 +985,10 @@ public:
*/
virtual
bool
get_hls_cleanup
(
std
::
string
vhost
);
/**
* the timeout to dispose the hls.
*/
virtual
int
get_hls_dispose
(
std
::
string
vhost
);
/**
* whether reap the ts when got keyframe.
*/
virtual
bool
get_hls_wait_keyframe
(
std
::
string
vhost
);
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
d611bb6
...
...
@@ -1109,6 +1109,19 @@ SrsHls::~SrsHls()
srs_freep
(
pprint
);
}
void
SrsHls
::
dispose
()
{
}
int
SrsHls
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
srs_info
(
"hls cycle for source %d"
,
source
->
source_id
());
return
ret
;
}
int
SrsHls
::
initialize
(
SrsSource
*
s
,
ISrsHlsHandler
*
h
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_hls.hpp
查看文件 @
d611bb6
...
...
@@ -403,6 +403,9 @@ public:
SrsHls
();
virtual
~
SrsHls
();
public
:
virtual
void
dispose
();
virtual
int
cycle
();
public
:
/**
* initialize the hls by handler and source.
*/
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
d611bb6
...
...
@@ -562,9 +562,12 @@ void SrsServer::dispose()
#ifdef SRS_AUTO_INGEST
ingester
->
dispose
();
srs_trace
(
"gracefully
cleanup
ingesters"
);
srs_trace
(
"gracefully
dispose
ingesters"
);
#endif
SrsSource
::
dispose_all
();
srs_trace
(
"gracefully dispose sources"
);
srs_trace
(
"terminate server"
);
}
...
...
@@ -962,6 +965,11 @@ int SrsServer::do_cycle()
srs_trace
(
"reload config success."
);
}
// notice the stream sources to cycle.
if
((
ret
=
SrsSource
::
cycle_all
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// update the cache time
if
((
i
%
SRS_SYS_TIME_RESOLUTION_MS_TIMES
)
==
0
)
{
srs_info
(
"update current time cache."
);
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
d611bb6
...
...
@@ -771,6 +771,32 @@ SrsSource* SrsSource::fetch(std::string vhost, std::string app, std::string stre
return
source
;
}
void
SrsSource
::
dispose_all
()
{
std
::
map
<
std
::
string
,
SrsSource
*>::
iterator
it
;
for
(
it
=
pool
.
begin
();
it
!=
pool
.
end
();
++
it
)
{
SrsSource
*
source
=
it
->
second
;
source
->
dispose
();
}
return
;
}
int
SrsSource
::
cycle_all
()
{
int
ret
=
ERROR_SUCCESS
;
// TODO: FIXME: support remove dead source for a long time.
std
::
map
<
std
::
string
,
SrsSource
*>::
iterator
it
;
for
(
it
=
pool
.
begin
();
it
!=
pool
.
end
();
++
it
)
{
SrsSource
*
source
=
it
->
second
;
if
((
ret
=
source
->
cycle
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
}
return
ret
;
}
void
SrsSource
::
destroy
()
{
std
::
map
<
std
::
string
,
SrsSource
*>::
iterator
it
;
...
...
@@ -909,6 +935,26 @@ SrsSource::~SrsSource()
srs_freep
(
_req
);
}
void
SrsSource
::
dispose
()
{
#ifdef SRS_AUTO_HLS
hls
->
dispose
();
#endif
}
int
SrsSource
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HLS
if
((
ret
=
hls
->
cycle
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsSource
::
initialize
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
ISrsHlsHandler
*
hh
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
d611bb6
...
...
@@ -411,6 +411,11 @@ public:
*/
static
SrsSource
*
fetch
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
);
/**
* dispose and cycle all sources.
*/
static
void
dispose_all
();
static
int
cycle_all
();
/**
* when system exit, destroy the sources,
* for gmc to analysis mem leaks.
*/
...
...
@@ -486,6 +491,9 @@ private:
public
:
SrsSource
();
virtual
~
SrsSource
();
public
:
virtual
void
dispose
();
virtual
int
cycle
();
// initialize, get and setter.
public:
/**
...
...
请
注册
或
登录
后发表评论