mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
hls 录像支持直播时移 (#1275)
* hls live record support seek * 调整代码风格 Co-authored-by: 夏楚 <771730766@qq.com>
This commit is contained in:
parent
254bc6889e
commit
5bffc98541
@ -35,6 +35,17 @@ void HlsMaker::makeIndexFile(bool eof) {
|
|||||||
auto sequence = _seg_number ? (_file_index > _seg_number ? _file_index - _seg_number : 0LL) : 0LL;
|
auto sequence = _seg_number ? (_file_index > _seg_number ? _file_index - _seg_number : 0LL) : 0LL;
|
||||||
|
|
||||||
string m3u8;
|
string m3u8;
|
||||||
|
if (_seg_number == 0) {
|
||||||
|
// 录像点播支持时移
|
||||||
|
snprintf(file_content, sizeof(file_content),
|
||||||
|
"#EXTM3U\n"
|
||||||
|
"#EXT-X-PLAYLIST-TYPE:EVENT\n"
|
||||||
|
"#EXT-X-VERSION:4\n"
|
||||||
|
"#EXT-X-TARGETDURATION:%u\n"
|
||||||
|
"#EXT-X-MEDIA-SEQUENCE:%llu\n",
|
||||||
|
(maxSegmentDuration + 999) / 1000,
|
||||||
|
sequence);
|
||||||
|
} else {
|
||||||
snprintf(file_content, sizeof(file_content),
|
snprintf(file_content, sizeof(file_content),
|
||||||
"#EXTM3U\n"
|
"#EXTM3U\n"
|
||||||
"#EXT-X-VERSION:3\n"
|
"#EXT-X-VERSION:3\n"
|
||||||
@ -43,6 +54,7 @@ void HlsMaker::makeIndexFile(bool eof) {
|
|||||||
"#EXT-X-MEDIA-SEQUENCE:%llu\n",
|
"#EXT-X-MEDIA-SEQUENCE:%llu\n",
|
||||||
(maxSegmentDuration + 999) / 1000,
|
(maxSegmentDuration + 999) / 1000,
|
||||||
sequence);
|
sequence);
|
||||||
|
}
|
||||||
|
|
||||||
m3u8.assign(file_content);
|
m3u8.assign(file_content);
|
||||||
|
|
||||||
@ -100,7 +112,7 @@ void HlsMaker::addNewSegment(uint32_t stamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//关闭并保存上一个切片,如果_seg_number==0,那么是点播。
|
//关闭并保存上一个切片,如果_seg_number==0,那么是点播。
|
||||||
flushLastSegment(_seg_number == 0);
|
flushLastSegment(false);
|
||||||
//新增切片
|
//新增切片
|
||||||
_last_file_name = onOpenSegment(_file_index++);
|
_last_file_name = onOpenSegment(_file_index++);
|
||||||
//记录本次切片的起始时间戳
|
//记录本次切片的起始时间戳
|
||||||
|
Loading…
Reference in New Issue
Block a user