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
2013-12-06 09:44:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8c5661b9ffe0260a44241a04b10b707611984d34
8c5661b9
1 parent
6207a2f1
fix bug of hls muxer, support close/open/flush even muxer is closed.
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
21 行增加
和
17 行删除
trunk/src/core/srs_core_hls.cpp
trunk/src/core/srs_core_hls.hpp
trunk/src/core/srs_core_hls.cpp
查看文件 @
8c5661b
...
...
@@ -503,7 +503,6 @@ SrsM3u8Muxer::SrsM3u8Muxer()
video_stream_dts
=
0
;
file_index
=
0
;
current
=
NULL
;
_is_open
=
false
;
}
SrsM3u8Muxer
::~
SrsM3u8Muxer
()
...
...
@@ -518,11 +517,6 @@ SrsM3u8Muxer::~SrsM3u8Muxer()
srs_freep
(
current
);
}
bool
SrsM3u8Muxer
::
is_open
()
{
return
_is_open
;
}
int
SrsM3u8Muxer
::
update_config
(
std
::
string
_app
,
std
::
string
_stream
,
std
::
string
path
,
int
fragment
,
int
window
...
...
@@ -542,6 +536,11 @@ int SrsM3u8Muxer::segment_open()
{
int
ret
=
ERROR_SUCCESS
;
if
(
current
)
{
srs_warn
(
"ignore the segment open, for segment is already open."
);
return
ret
;
}
// TODO: create all parents dirs.
// create dir for app.
if
((
ret
=
create_dir
())
!=
ERROR_SUCCESS
)
{
...
...
@@ -578,8 +577,6 @@ int SrsM3u8Muxer::segment_open()
srs_info
(
"open HLS muxer success. vhost=%s, path=%s"
,
vhost
.
c_str
(),
current
->
full_path
.
c_str
());
_is_open
=
true
;
return
ret
;
}
...
...
@@ -587,7 +584,11 @@ int SrsM3u8Muxer::flush_audio(SrsMpegtsFrame* af, SrsCodecBuffer* ab)
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
current
);
// if current is NULL, segment is not open, ignore the flush event.
if
(
!
current
)
{
srs_warn
(
"flush audio ignored, for segment is not open."
);
return
ret
;
}
if
(
ab
->
size
<=
0
)
{
return
ret
;
...
...
@@ -609,10 +610,15 @@ int SrsM3u8Muxer::flush_video(
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
current
);
// if current is NULL, segment is not open, ignore the flush event.
if
(
!
current
)
{
srs_warn
(
"flush video ignored, for segment is not open."
);
return
ret
;
}
video_stream_dts
=
vf
->
dts
;
srs_assert
(
current
);
// reopen the muxer for a gop
if
(
vf
->
key
&&
current
->
duration
>=
hls_fragment
)
{
// TODO: flush audio before or after segment?
...
...
@@ -643,7 +649,6 @@ int SrsM3u8Muxer::flush_video(
}
}
srs_assert
(
current
);
// update the duration of segment.
current
->
update_duration
(
video_stream_dts
);
...
...
@@ -661,6 +666,11 @@ int SrsM3u8Muxer::segment_close()
{
int
ret
=
ERROR_SUCCESS
;
if
(
!
current
)
{
srs_warn
(
"ignore the segment close, for segment is not open."
);
return
ret
;
}
// when close current segment, the current segment must not be NULL.
srs_assert
(
current
);
...
...
@@ -718,8 +728,6 @@ int SrsM3u8Muxer::segment_close()
return
ret
;
}
_is_open
=
false
;
return
ret
;
}
...
...
@@ -1186,7 +1194,6 @@ void SrsHls::on_unpublish()
{
int
ret
=
ERROR_SUCCESS
;
if
(
muxer
->
is_open
())
{
// close muxer when unpublish.
ret
=
ts_cache
->
flush_audio
(
muxer
);
ret
+=
muxer
->
segment_close
();
...
...
@@ -1194,7 +1201,6 @@ void SrsHls::on_unpublish()
if
(
ret
!=
ERROR_SUCCESS
)
{
srs_error
(
"ignore m3u8 muxer flush/close audio failed. ret=%d"
,
ret
);
}
}
hls_enabled
=
false
;
}
...
...
trunk/src/core/srs_core_hls.hpp
查看文件 @
8c5661b
...
...
@@ -132,7 +132,6 @@ private:
int
hls_fragment
;
int
hls_window
;
private
:
bool
_is_open
;
int
file_index
;
std
::
string
m3u8
;
private
:
...
...
@@ -150,7 +149,6 @@ public:
SrsM3u8Muxer
();
virtual
~
SrsM3u8Muxer
();
public
:
virtual
bool
is_open
();
virtual
int
update_config
(
std
::
string
_app
,
std
::
string
_stream
,
std
::
string
path
,
int
fragment
,
int
window
);
virtual
int
segment_open
();
virtual
int
flush_audio
(
SrsMpegtsFrame
*
af
,
SrsCodecBuffer
*
ab
);
...
...
请
注册
或
登录
后发表评论