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

View File

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