diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index e8e90692..be1c9f01 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -92,7 +92,7 @@ void HlsMaker::inputData(void *data, size_t len, uint32_t timestamp, bool is_idr } } else { //resetTracks时触发此逻辑 - flushLastSegment(true); + flushLastSegment(false); } } @@ -151,6 +151,7 @@ bool HlsMaker::isLive() { void HlsMaker::clear() { _file_index = 0; + _last_timestamp = 0; _last_seg_timestamp = 0; _seg_dur_list.clear(); _last_file_name.clear(); diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 05f783fe..5e73a54b 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -37,12 +37,16 @@ HlsMakerImp::HlsMakerImp(const string &m3u8_file, } 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()) { return; } diff --git a/src/Record/HlsMakerImp.h b/src/Record/HlsMakerImp.h index d401e08a..8de756b1 100644 --- a/src/Record/HlsMakerImp.h +++ b/src/Record/HlsMakerImp.h @@ -45,9 +45,8 @@ public: /** * 清空缓存 - * @param immediately 时候立即删除 */ - void clearCache(bool immediately = true); + void clearCache(); protected: std::string onOpenSegment(uint64_t index) override ; @@ -58,6 +57,7 @@ protected: private: std::shared_ptr makeFile(const std::string &file,bool setbuf = false); + void clearCache(bool immediately, bool eof); private: int _buf_size;