从直播到录像,不删除直播的8个切片。

This commit is contained in:
renlu 2022-12-08 09:47:33 +08:00
parent 0d40bf9272
commit c28e96c3af
2 changed files with 19 additions and 19 deletions

View File

@ -43,24 +43,24 @@ void HlsMakerSub::startRecord(bool isRecord) {
if (isRecord == _is_record) { if (isRecord == _is_record) {
return; return;
} }
//如果是录像则删除之前直播的8个ts文件 ////如果是录像则删除之前直播的8个ts文件
if (isRecord) { //if (isRecord) {
std::map<uint64_t, std::string> delete_file_paths = _segment_file_paths; // std::map<uint64_t, std::string> delete_file_paths = _segment_file_paths;
_segment_file_paths.clear(); // _segment_file_paths.clear();
int count = 0; // int count = 0;
//删除_segment_file_paths路径对应的直播文件,过30s再删除免得hls直播突然断掉 // //删除_segment_file_paths路径对应的直播文件,过10s再删除免得hls直播突然断掉
for (auto it : delete_file_paths) { // for (auto it : delete_file_paths) {
count ++; // count ++;
if (count < delete_file_paths.size()) { // if (count < delete_file_paths.size()) {
auto ts_path = it.second; // auto ts_path = it.second;
File::delete_file(ts_path.data()); // File::delete_file(ts_path.data());
//_poller->doDelayTask(30 * 1000, [ts_path]() { // _poller->doDelayTask(10 * 1000, [ts_path]() {
// File::delete_file(ts_path.data()); // File::delete_file(ts_path.data());
// return 0; // return 0;
// }); // });
} // }
} // }
} //}
if(isRecord) { if(isRecord) {
_seg_keep = true; _seg_keep = true;

View File

@ -18,7 +18,7 @@
#include "Util/File.h" #include "Util/File.h"
#include "Util/util.h" #include "Util/util.h"
#include "Util/logger.h" #include "Util/logger.h"
#include "ZLToolKit/src/Poller/EventPoller.h" //#include "ZLToolKit/src/Poller/EventPoller.h"
namespace mediakit { namespace mediakit {
class HlsMakerSub { class HlsMakerSub {