diff --git a/conf/config.ini b/conf/config.ini index 72ca1b43..755222a0 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -66,6 +66,8 @@ segDur=2 segNum=3 #HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数 segRetain=5 +# 是否广播 ts 切片完成通知 +broadcastRecordTs=0 [hook] #在推流时,如果url参数匹对admin_params,那么可以不经过hook鉴权直接推流成功,播放时亦然 @@ -83,6 +85,8 @@ on_play=https://127.0.0.1/index/hook/on_play on_publish=https://127.0.0.1/index/hook/on_publish #录制mp4切片完成事件 on_record_mp4=https://127.0.0.1/index/hook/on_record_mp4 +# 录制 hls ts 切片完成事件 +on_record_ts=https://127.0.0.1/index/hook/on_record_ts #rtsp播放鉴权事件,此事件中比对rtsp的用户名密码 on_rtsp_auth=https://127.0.0.1/index/hook/on_rtsp_auth #rtsp播放是否开启专属鉴权事件,置空则关闭rtsp鉴权。rtsp播放鉴权还支持url方式鉴权 diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 79520970..f26c504d 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -252,6 +252,8 @@ const string kSegmentRetain = HLS_FIELD"segRetain"; const string kFileBufSize = HLS_FIELD"fileBufSize"; //录制文件路径 const string kFilePath = HLS_FIELD"filePath"; +// 是否广播 ts 切片完成通知 +const string kBroadcastRecordTs = HLS_FIELD"broadcastRecordTs"; onceToken token([](){ mINI::Instance()[kSegmentDuration] = 2; @@ -259,6 +261,7 @@ onceToken token([](){ mINI::Instance()[kSegmentRetain] = 5; mINI::Instance()[kFileBufSize] = 64 * 1024; mINI::Instance()[kFilePath] = "./www"; + mINI::Instance()[kBroadcastRecordTs] = false; },nullptr); } //namespace Hls diff --git a/src/Common/config.h b/src/Common/config.h index c3cf643b..3f9869a8 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -285,6 +285,8 @@ extern const string kSegmentRetain; extern const string kFileBufSize; //录制文件路径 extern const string kFilePath; +// 是否广播 ts 切片完成通知 +extern const string kBroadcastRecordTs; } //namespace Hls ////////////Rtp代理相关配置/////////// diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index f3ac9bb6..0ea5048a 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -109,14 +109,18 @@ void HlsMakerImp::onWriteHls(const char *data, int len) { } void HlsMakerImp::onFlushLastSegment(uint32_t duration) { - auto info = _info; - info.ui64TimeLen = duration; - WorkThreadPool::Instance().getExecutor()->async([info]() { - struct stat fileData; - stat(info.strFilePath.data(), &fileData); - const_cast(info).ui64FileSize = fileData.st_size; - NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); - }); + GET_CONFIG(bool, broadcastRecordTs, Hls::kBroadcastRecordTs); + + if (broadcastRecordTs) { + auto info = _info; + info.ui64TimeLen = duration; + WorkThreadPool::Instance().getExecutor()->async([info]() { + struct stat fileData; + stat(info.strFilePath.data(), &fileData); + const_cast(info).ui64FileSize = fileData.st_size; + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); + }); + } }