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 14:41:09 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
223ae194b198e05b17342ca15d10c4b105e3c10c
223ae194
1 parent
4a80a5a7
fix #209, cleanup hls when stop and timeout. 2.0.173.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
71 行增加
和
29 行删除
README.md
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_hls.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
223ae19
...
...
@@ -343,6 +343,8 @@ Remark:
## History
### SRS 2.0 history
*
v2.0, 2015-05-30, fix
[
#209
](
https://github.com/simple-rtmp-server/srs/issues/209
)
cleanup hls when stop and timeout. 2.0.173.
*
v2.0, 2015-05-29, fix
[
#409
](
https://github.com/simple-rtmp-server/srs/issues/409
)
support pure video hls. 2.0.172.
*
v2.0, 2015-05-28, support
[
srs-dolphin
][
srs-dolphin
]
, the multiple-process SRS.
*
v2.0, 2015-05-24, fix
[
#404
](
https://github.com/simple-rtmp-server/srs/issues/404
)
register handler then start http thread. 2.0.167.
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
223ae19
...
...
@@ -292,7 +292,6 @@ SrsHlsMuxer::SrsHlsMuxer()
SrsHlsMuxer
::~
SrsHlsMuxer
()
{
std
::
vector
<
SrsHlsSegment
*>::
iterator
it
;
for
(
it
=
segments
.
begin
();
it
!=
segments
.
end
();
++
it
)
{
SrsHlsSegment
*
segment
=
*
it
;
...
...
@@ -308,38 +307,35 @@ SrsHlsMuxer::~SrsHlsMuxer()
void
SrsHlsMuxer
::
dispose
()
{
if
(
!
should_write_file
)
{
return
;
}
std
::
vector
<
SrsHlsSegment
*>::
iterator
it
;
for
(
it
=
segments
.
begin
();
it
!=
segments
.
end
();
++
it
)
{
SrsHlsSegment
*
segment
=
*
it
;
if
(
unlink
(
segment
->
full_path
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed, file=%s."
,
segment
->
full_path
.
c_str
());
if
(
should_write_file
)
{
std
::
vector
<
SrsHlsSegment
*>::
iterator
it
;
for
(
it
=
segments
.
begin
();
it
!=
segments
.
end
();
++
it
)
{
SrsHlsSegment
*
segment
=
*
it
;
if
(
unlink
(
segment
->
full_path
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed, file=%s."
,
segment
->
full_path
.
c_str
());
}
srs_freep
(
segment
);
}
}
if
(
current
)
{
std
::
string
path
=
current
->
full_path
+
".tmp"
;
if
(
unlink
(
path
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed, file=%s"
,
path
.
c_str
());
segments
.
clear
();
if
(
current
)
{
std
::
string
path
=
current
->
full_path
+
".tmp"
;
if
(
unlink
(
path
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed, file=%s"
,
path
.
c_str
());
}
srs_freep
(
current
);
}
if
(
unlink
(
m3u8
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed. file=%s"
,
m3u8
.
c_str
());
}
}
if
(
unlink
(
m3u8
.
c_str
())
<
0
)
{
srs_warn
(
"dispose unlink path failed. file=%s"
,
m3u8
.
c_str
());
}
// TODO: FIXME: support hls dispose in HTTP cache.
srs_trace
(
"gracefully dispose hls %s"
,
req
?
req
->
get_stream_url
().
c_str
()
:
""
);
}
int
SrsHlsMuxer
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
// TODO: FIXME: implements it.
return
ret
;
}
int
SrsHlsMuxer
::
sequence_no
()
{
return
_sequence_no
;
...
...
@@ -1125,6 +1121,8 @@ SrsHls::SrsHls()
handler
=
NULL
;
hls_enabled
=
false
;
hls_can_dispose
=
false
;
last_update_time
=
0
;
codec
=
new
SrsAvcAacCodec
();
sample
=
new
SrsCodecSample
();
...
...
@@ -1160,8 +1158,33 @@ void SrsHls::dispose()
int
SrsHls
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
srs_info
(
"hls cycle for source %d"
,
source
->
source_id
());
return
muxer
->
cycle
();
if
(
last_update_time
<=
0
)
{
last_update_time
=
srs_get_system_time_ms
();
}
if
(
!
_req
)
{
return
ret
;
}
int
hls_dispose
=
_srs_config
->
get_hls_dispose
(
_req
->
vhost
)
*
1000
;
if
(
srs_get_system_time_ms
()
-
last_update_time
<=
hls_dispose
)
{
return
ret
;
}
last_update_time
=
srs_get_system_time_ms
();
if
(
!
hls_can_dispose
)
{
return
ret
;
}
hls_can_dispose
=
false
;
srs_trace
(
"hls cycle to dispose hls %s, timeout=%dms"
,
_req
->
get_stream_url
().
c_str
(),
hls_dispose
);
dispose
();
return
ret
;
}
int
SrsHls
::
initialize
(
SrsSource
*
s
,
ISrsHlsHandler
*
h
)
...
...
@@ -1182,6 +1205,11 @@ int SrsHls::on_publish(SrsRequest* req)
{
int
ret
=
ERROR_SUCCESS
;
_req
=
req
;
// update the hls time, for hls_dispose.
last_update_time
=
srs_get_system_time_ms
();
// support multiple publish.
if
(
hls_enabled
)
{
return
ret
;
...
...
@@ -1199,6 +1227,9 @@ int SrsHls::on_publish(SrsRequest* req)
// if enabled, open the muxer.
hls_enabled
=
true
;
// ok, the hls can be dispose, or need to be dispose.
hls_can_dispose
=
true
;
// notice the source to get the cached sequence header.
// when reload to start hls, hls will never get the sequence header in stream,
// use the SrsSource.on_hls_start to push the sequence header to HLS.
...
...
@@ -1250,6 +1281,9 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio)
if
(
!
hls_enabled
)
{
return
ret
;
}
// update the hls time, for hls_dispose.
last_update_time
=
srs_get_system_time_ms
();
SrsSharedPtrMessage
*
audio
=
shared_audio
->
copy
();
SrsAutoFree
(
SrsSharedPtrMessage
,
audio
);
...
...
@@ -1311,6 +1345,9 @@ int SrsHls::on_video(SrsSharedPtrMessage* shared_video)
if
(
!
hls_enabled
)
{
return
ret
;
}
// update the hls time, for hls_dispose.
last_update_time
=
srs_get_system_time_ms
();
SrsSharedPtrMessage
*
video
=
shared_video
->
copy
();
SrsAutoFree
(
SrsSharedPtrMessage
,
video
);
...
...
trunk/src/app/srs_app_hls.hpp
查看文件 @
223ae19
...
...
@@ -261,7 +261,6 @@ public:
virtual
~
SrsHlsMuxer
();
public
:
virtual
void
dispose
();
virtual
int
cycle
();
public
:
virtual
int
sequence_no
();
virtual
std
::
string
ts_url
();
...
...
@@ -382,7 +381,11 @@ private:
SrsHlsCache
*
hls_cache
;
ISrsHlsHandler
*
handler
;
private
:
SrsRequest
*
_req
;
bool
hls_enabled
;
bool
hls_can_dispose
;
int64_t
last_update_time
;
private
:
SrsSource
*
source
;
SrsAvcAacCodec
*
codec
;
SrsCodecSample
*
sample
;
...
...
trunk/src/core/srs_core.hpp
查看文件 @
223ae19
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 17
2
#define VERSION_REVISION 17
3
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论