Cleaned out boundingSet member from TMMBRHelp class

BUG=webrtc:5565
R=philipel@webrtc.org

Review URL: https://codereview.webrtc.org/2224933002 .

Cr-Commit-Position: refs/heads/master@{#13702}
This commit is contained in:
Danil Chapovalov 2016-08-10 11:29:50 +02:00
parent 630c6d58d3
commit daa90a7e35
5 changed files with 20 additions and 35 deletions

View File

@ -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

View File

@ -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<rtcp::TmmbItem> 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;

View File

@ -614,13 +614,10 @@ std::unique_ptr<rtcp::RtcpPacket> 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<rtcp::TmmbItem> bounding = tmmbr_help.FindTMMBRBoundingSet();
tmmbrOwner = TMMBRHelp::IsOwner(bounding, ssrc_);
if (!tmmbrOwner) {
// Did not enter bounding set, no meaning to send this request.
return nullptr;

View File

@ -12,6 +12,7 @@
#include <algorithm>
#include <limits>
#include <utility>
#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<rtcp::TmmbItem> 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<rtcp::TmmbItem> 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<rtcp::TmmbItem> candidates,
@ -231,13 +230,10 @@ void TMMBRHelp::FindBoundingSet(std::vector<rtcp::TmmbItem> 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<rtcp::TmmbItem>& bounding,
uint32_t ssrc) {
for (const rtcp::TmmbItem& item : bounding) {
if (item.ssrc() == ssrc) {
return true;
}
}

View File

@ -44,9 +44,10 @@ class TMMBRHelp {
TMMBRSet* CandidateSet();
TMMBRSet* VerifyAndAllocateCandidateSet(const uint32_t minimumSize);
int32_t FindTMMBRBoundingSet(TMMBRSet*& boundingSet);
std::vector<rtcp::TmmbItem> FindTMMBRBoundingSet();
bool IsOwner(const uint32_t ssrc, const uint32_t length) const;
static bool IsOwner(const std::vector<rtcp::TmmbItem>& bounding,
uint32_t ssrc);
bool CalcMinBitRate(uint32_t* minBitrateKbit) const;
@ -55,7 +56,6 @@ class TMMBRHelp {
private:
TMMBRSet _candidateSet;
TMMBRSet _boundingSet;
};
} // namespace webrtc