diff --git a/webrtc/modules/rtp_rtcp/source/CPPLINT.cfg b/webrtc/modules/rtp_rtcp/source/CPPLINT.cfg index c318452482..baec43c3e6 100644 --- a/webrtc/modules/rtp_rtcp/source/CPPLINT.cfg +++ b/webrtc/modules/rtp_rtcp/source/CPPLINT.cfg @@ -1,5 +1,3 @@ -#tmmbr_help is refactored in CL#1474693002 -exclude_files=tmmbr_help.* #rtcp_utility planned to be removed when webrtc:5260 will be finished. exclude_files=rtcp_utility.* #rtcp_receiver/rtcp_receiver_help will be refactored more deeply as part of webrtc:5260 diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc index ae1f87596b..31a11e2892 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -1234,7 +1234,6 @@ void RTCPReceiver::HandleTransportFeedback( } int32_t RTCPReceiver::UpdateTMMBR() { TMMBRHelp tmmbr_help; - int32_t numBoundingSet = 0; uint32_t bitrate = 0; uint32_t accNumCandidates = 0; @@ -1245,19 +1244,14 @@ int32_t RTCPReceiver::UpdateTMMBR() { accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); } // Find bounding set - TMMBRSet* boundingSet = NULL; - numBoundingSet = tmmbr_help.FindTMMBRBoundingSet(boundingSet); - if (numBoundingSet == -1) { - LOG(LS_WARNING) << "Failed to find TMMBR bounding set."; - return -1; - } + std::vector bounding = tmmbr_help.FindTMMBRBoundingSet(); // Set bounding set // Inform remote clients about the new bandwidth // inform the remote client - _rtpRtcp.SetTMMBN(boundingSet); + _rtpRtcp.SetTMMBN(&bounding); // might trigger a TMMBN - if (numBoundingSet == 0) { + if (bounding.empty()) { // owner of max bitrate request has timed out // empty bounding set has been sent return 0; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index d4c1cd1e1f..23da9cac95 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -614,13 +614,10 @@ std::unique_ptr RTCPSender::BuildTMMBR( // add current tuple candidateSet->SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_oh_send_, ssrc_); - int numCandidates = lengthOfBoundingSet + 1; // find bounding set - TMMBRSet* boundingSet = nullptr; - int numBoundingSet = tmmbr_help.FindTMMBRBoundingSet(boundingSet); - if (numBoundingSet > 0 || numBoundingSet <= numCandidates) - tmmbrOwner = tmmbr_help.IsOwner(ssrc_, numBoundingSet); + std::vector bounding = tmmbr_help.FindTMMBRBoundingSet(); + tmmbrOwner = TMMBRHelp::IsOwner(bounding, ssrc_); if (!tmmbrOwner) { // Did not enter bounding set, no meaning to send this request. return nullptr; diff --git a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc index c153181da9..5aa8f945aa 100644 --- a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc +++ b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc @@ -12,6 +12,7 @@ #include #include +#include #include "webrtc/base/checks.h" #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" @@ -60,7 +61,7 @@ TMMBRSet* TMMBRHelp::CandidateSet() { return &_candidateSet; } -int32_t TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) { +std::vector TMMBRHelp::FindTMMBRBoundingSet() { // Work on local variable, will be modified TMMBRSet candidateSet; candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); @@ -80,16 +81,14 @@ int32_t TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) { // Number of set candidates int32_t numSetCandidates = candidateSet.lengthOfSet(); // Find bounding set - uint32_t numBoundingSet = 0; + std::vector bounding; if (numSetCandidates > 0) { - FindBoundingSet(std::move(candidateSet), &_boundingSet); - numBoundingSet = _boundingSet.size(); - if (numBoundingSet < 1 || (numBoundingSet > _candidateSet.size())) { - return -1; - } - boundingSet = &_boundingSet; + FindBoundingSet(std::move(candidateSet), &bounding); + size_t numBoundingSet = bounding.size(); + RTC_DCHECK_GE(numBoundingSet, 1u); + RTC_DCHECK_LE(numBoundingSet, _candidateSet.size()); } - return numBoundingSet; + return bounding; } void TMMBRHelp::FindBoundingSet(std::vector candidates, @@ -231,13 +230,10 @@ void TMMBRHelp::FindBoundingSet(std::vector candidates, } } -bool TMMBRHelp::IsOwner(const uint32_t ssrc, const uint32_t length) const { - if (length == 0) { - // Empty bounding set. - return false; - } - for (size_t i = 0; (i < length) && (i < _boundingSet.size()); ++i) { - if (_boundingSet.Ssrc(i) == ssrc) { +bool TMMBRHelp::IsOwner(const std::vector& bounding, + uint32_t ssrc) { + for (const rtcp::TmmbItem& item : bounding) { + if (item.ssrc() == ssrc) { return true; } } diff --git a/webrtc/modules/rtp_rtcp/source/tmmbr_help.h b/webrtc/modules/rtp_rtcp/source/tmmbr_help.h index f901b37531..ecae946f97 100644 --- a/webrtc/modules/rtp_rtcp/source/tmmbr_help.h +++ b/webrtc/modules/rtp_rtcp/source/tmmbr_help.h @@ -44,9 +44,10 @@ class TMMBRHelp { TMMBRSet* CandidateSet(); TMMBRSet* VerifyAndAllocateCandidateSet(const uint32_t minimumSize); - int32_t FindTMMBRBoundingSet(TMMBRSet*& boundingSet); + std::vector FindTMMBRBoundingSet(); - bool IsOwner(const uint32_t ssrc, const uint32_t length) const; + static bool IsOwner(const std::vector& bounding, + uint32_t ssrc); bool CalcMinBitRate(uint32_t* minBitrateKbit) const; @@ -55,7 +56,6 @@ class TMMBRHelp { private: TMMBRSet _candidateSet; - TMMBRSet _boundingSet; }; } // namespace webrtc