From 64ee0bcaf2db284c4572ffc5f757224c01ded6b6 Mon Sep 17 00:00:00 2001 From: renlu Date: Mon, 28 Nov 2022 16:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Bug:=20=E4=BB=8E=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E5=88=B0=E5=BD=95=E5=83=8F=EF=BC=8C=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AAts=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/HlsMakerSub.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Record/HlsMakerSub.cpp b/src/Record/HlsMakerSub.cpp index 55de73cf..7ebf99b6 100644 --- a/src/Record/HlsMakerSub.cpp +++ b/src/Record/HlsMakerSub.cpp @@ -47,13 +47,17 @@ void HlsMakerSub::startRecord(bool isRecord) { if (isRecord) { std::map delete_file_paths = _segment_file_paths; _segment_file_paths.clear(); + int count = 0; //删除_segment_file_paths路径对应的直播文件,过30s再删除,免得hls直播突然断掉 for (auto it : delete_file_paths) { - auto ts_path = it.second; - _poller->doDelayTask(30 * 1000, [ts_path]() { - File::delete_file(ts_path.data()); - return 0; - }); + count ++; + if (count < delete_file_paths.size()) { + auto ts_path = it.second; + _poller->doDelayTask(30 * 1000, [ts_path]() { + File::delete_file(ts_path.data()); + return 0; + }); + } } }