From 6813538118fc8a38bebaa01a30b705341c6d8be3 Mon Sep 17 00:00:00 2001 From: gongluck Date: Mon, 6 May 2024 14:23:14 +0800 Subject: [PATCH] =?UTF-8?q?nack=E7=9B=B8=E5=85=B3=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Nack.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/webrtc/Nack.cpp b/webrtc/Nack.cpp index 6197117e..f3e6fa77 100644 --- a/webrtc/Nack.cpp +++ b/webrtc/Nack.cpp @@ -9,24 +9,39 @@ */ #include "Nack.h" +#include "Common/config.h" using namespace std; using namespace toolkit; namespace mediakit { -static constexpr uint32_t kMaxNackMS = 5 * 1000; -static constexpr uint32_t kRtpCacheCheckInterval = 100; +// RTC配置项目 +namespace Rtc { +#define RTC_FIELD "rtc." +// Nack缓存包最早时间间隔 +const string kMaxNackMS = RTC_FIELD "maxNackMS"; +// Nack包检查间隔(包数量) +const string kRtpCacheCheckInterval = RTC_FIELD "rtpCacheCheckInterval"; + +static onceToken token([]() { + mINI::Instance()[kMaxNackMS] = 5 * 1000; + mINI::Instance()[kRtpCacheCheckInterval] = 100; +}); + +} // namespace Rtc void NackList::pushBack(RtpPacket::Ptr rtp) { auto seq = rtp->getSeq(); _nack_cache_seq.emplace_back(seq); _nack_cache_pkt.emplace(seq, std::move(rtp)); - if (++_cache_ms_check < kRtpCacheCheckInterval) { + GET_CONFIG(uint32_t, rtpcache_checkinterval, Rtc::kRtpCacheCheckInterval); + if (++_cache_ms_check < rtpcache_checkinterval) { return; } _cache_ms_check = 0; - while (getCacheMS() >= kMaxNackMS) { + GET_CONFIG(uint32_t, maxnackms, Rtc::kMaxNackMS); + while (getCacheMS() >= maxnackms) { // 需要清除部分nack缓存 popFront(); }