mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 11:17:09 +08:00
HLS: 解决hls断流重新生成后异常的bug
This commit is contained in:
parent
e37982adee
commit
83c1f29253
@ -92,7 +92,7 @@ void HlsMaker::inputData(void *data, size_t len, uint32_t timestamp, bool is_idr
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//resetTracks时触发此逻辑
|
//resetTracks时触发此逻辑
|
||||||
flushLastSegment(true);
|
flushLastSegment(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +151,7 @@ bool HlsMaker::isLive() {
|
|||||||
|
|
||||||
void HlsMaker::clear() {
|
void HlsMaker::clear() {
|
||||||
_file_index = 0;
|
_file_index = 0;
|
||||||
|
_last_timestamp = 0;
|
||||||
_last_seg_timestamp = 0;
|
_last_seg_timestamp = 0;
|
||||||
_seg_dur_list.clear();
|
_seg_dur_list.clear();
|
||||||
_last_file_name.clear();
|
_last_file_name.clear();
|
||||||
|
@ -37,12 +37,16 @@ HlsMakerImp::HlsMakerImp(const string &m3u8_file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
HlsMakerImp::~HlsMakerImp() {
|
HlsMakerImp::~HlsMakerImp() {
|
||||||
clearCache(false);
|
clearCache(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HlsMakerImp::clearCache(bool immediately) {
|
void HlsMakerImp::clearCache() {
|
||||||
|
clearCache(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HlsMakerImp::clearCache(bool immediately, bool eof) {
|
||||||
//录制完了
|
//录制完了
|
||||||
flushLastSegment(true);
|
flushLastSegment(eof);
|
||||||
if (!isLive()) {
|
if (!isLive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
* @param immediately 时候立即删除
|
|
||||||
*/
|
*/
|
||||||
void clearCache(bool immediately = true);
|
void clearCache();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string onOpenSegment(uint64_t index) override ;
|
std::string onOpenSegment(uint64_t index) override ;
|
||||||
@ -58,6 +57,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<FILE> makeFile(const std::string &file,bool setbuf = false);
|
std::shared_ptr<FILE> makeFile(const std::string &file,bool setbuf = false);
|
||||||
|
void clearCache(bool immediately, bool eof);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _buf_size;
|
int _buf_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user