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
2014-03-21 17:35:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4f284b20f05df730773456087d93628a7bfcc483
4f284b20
1 parent
57585515
drop ts segment when duration is too small
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
36 行增加
和
15 行删除
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_hls.cpp
查看文件 @
4f284b2
...
...
@@ -47,6 +47,9 @@ using namespace std;
// max PES packets size to flush the video.
#define SRS_HLS_AUDIO_CACHE_SIZE 1024 * 1024
// drop the segment when duration of ts too small.
#define SRS_HLS_SEGMENT_MIN_DURATION_MS 100
// @see: NGX_RTMP_HLS_DELAY,
// 63000: 700ms, ts_tbn=90000
#define SRS_HLS_DELAY 63000
...
...
@@ -680,24 +683,39 @@ int SrsHlsMuxer::segment_close(string log_desc)
it
=
std
::
find
(
segments
.
begin
(),
segments
.
end
(),
current
);
srs_assert
(
it
==
segments
.
end
());
// valid, add to segments.
segments
.
push_back
(
current
);
// valid, add to segments if segment duration is ok
if
(
current
->
duration
*
1000
>=
SRS_HLS_SEGMENT_MIN_DURATION_MS
)
{
segments
.
push_back
(
current
);
srs_trace
(
"%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"
PRId64
""
,
log_desc
.
c_str
(),
current
->
sequence_no
,
current
->
uri
.
c_str
(),
current
->
duration
,
current
->
segment_start_dts
);
srs_trace
(
"%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"
PRId64
""
,
log_desc
.
c_str
(),
current
->
sequence_no
,
current
->
uri
.
c_str
(),
current
->
duration
,
current
->
segment_start_dts
);
// close the muxer of finished segment.
srs_freep
(
current
->
muxer
);
// rename from tmp to real path
std
::
string
tmp_file
=
current
->
full_path
+
".tmp"
;
if
(
rename
(
tmp_file
.
c_str
(),
current
->
full_path
.
c_str
())
<
0
)
{
ret
=
ERROR_HLS_WRITE_FAILED
;
srs_error
(
"rename ts file failed, %s => %s. ret=%d"
,
tmp_file
.
c_str
(),
current
->
full_path
.
c_str
(),
ret
);
return
ret
;
// close the muxer of finished segment.
srs_freep
(
current
->
muxer
);
// rename from tmp to real path
std
::
string
tmp_file
=
current
->
full_path
+
".tmp"
;
if
(
rename
(
tmp_file
.
c_str
(),
current
->
full_path
.
c_str
())
<
0
)
{
ret
=
ERROR_HLS_WRITE_FAILED
;
srs_error
(
"rename ts file failed, %s => %s. ret=%d"
,
tmp_file
.
c_str
(),
current
->
full_path
.
c_str
(),
ret
);
return
ret
;
}
current
=
NULL
;
}
else
{
// reuse current segment index.
file_index
--
;
srs_trace
(
"%s drop ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"
PRId64
""
,
log_desc
.
c_str
(),
current
->
sequence_no
,
current
->
uri
.
c_str
(),
current
->
duration
,
current
->
segment_start_dts
);
// rename from tmp to real path
std
::
string
tmp_file
=
current
->
full_path
+
".tmp"
;
unlink
(
tmp_file
.
c_str
());
srs_freep
(
current
);
}
current
=
NULL
;
// the segments to remove
std
::
vector
<
SrsHlsSegment
*>
segment_to_remove
;
...
...
@@ -941,6 +959,9 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment
// reset video count for new publish session.
video_count
=
0
;
// TODO: FIXME: support load exists m3u8, to continue publish stream.
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
// open muxer
if
((
ret
=
muxer
->
update_config
(
app
,
stream
,
hls_path
,
hls_fragment
,
hls_window
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"m3u8 muxer update config failed. ret=%d"
,
ret
);
...
...
请
注册
或
登录
后发表评论