From 7e6467615c8ed39205527990e1d2198275d765f2 Mon Sep 17 00:00:00 2001 From: Johnny Date: Thu, 18 Nov 2021 19:29:54 +0800 Subject: [PATCH] refine: rename TwccContext::checkIfNeedSendTwcc to TwccContext::needSendTwcc. --- webrtc/TwccContext.cpp | 16 ++++------------ webrtc/TwccContext.h | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/webrtc/TwccContext.cpp b/webrtc/TwccContext.cpp index 1d8b9821..6a3bfbd6 100644 --- a/webrtc/TwccContext.cpp +++ b/webrtc/TwccContext.cpp @@ -38,25 +38,17 @@ void TwccContext::onRtp(uint32_t ssrc, uint16_t twcc_ext_seq, uint64_t stamp_ms) _min_stamp = _max_stamp; } - if (checkIfNeedSendTwcc()) { + if (needSendTwcc()) { //其他匹配条件立即发送twcc onSendTwcc(ssrc); } } -bool TwccContext::checkIfNeedSendTwcc() const { - auto size = _rtp_recv_status.size(); - if (!size) { +bool TwccContext::needSendTwcc() const { + if (_rtp_recv_status.empty()) { return false; } - if (size >= kMaxSeqDelta) { - return true; - } - auto delta_ms = _max_stamp - _min_stamp; - if (delta_ms >= kMaxTimeDelta) { - return true; - } - return false; + return (_rtp_recv_status.size() >= kMaxSeqSize) || (_max_stamp - _min_stamp >= kMaxTimeDelta); } int TwccContext::checkSeqStatus(uint16_t twcc_ext_seq) const { diff --git a/webrtc/TwccContext.h b/webrtc/TwccContext.h index 98790a18..9455508d 100644 --- a/webrtc/TwccContext.h +++ b/webrtc/TwccContext.h @@ -21,7 +21,7 @@ class TwccContext { public: using onSendTwccCB = function; //每个twcc rtcp包最多表明的rtp ext seq增量 - static constexpr size_t kMaxSeqDelta = 20; + static constexpr size_t kMaxSeqSize = 20; //每个twcc rtcp包发送的最大时间间隔,单位毫秒 static constexpr size_t kMaxTimeDelta = 256; @@ -33,7 +33,7 @@ public: private: void onSendTwcc(uint32_t ssrc); - bool checkIfNeedSendTwcc() const; + bool needSendTwcc() const; int checkSeqStatus(uint16_t twcc_ext_seq) const; void clearStatus();