_boundingSetToSend moved out of tmmbr_help_ into tmmbn_to_send_

because in the TMMBRHelp class it is independent of other members.

BUG=webrtc:5565
R=philipel

Review-Url: https://codereview.webrtc.org/1746773002
Cr-Commit-Position: refs/heads/master@{#12669}
This commit is contained in:
danilchap
2016-05-09 10:59:50 -07:00
committed by Commit bot
parent db3eea0ede
commit 6eaa3a41ce
7 changed files with 23 additions and 69 deletions

View File

@ -639,16 +639,11 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN(
const RtcpContext& ctx) {
TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend();
if (boundingSet == nullptr)
return nullptr;
rtcp::Tmmbn* tmmbn = new rtcp::Tmmbn();
tmmbn->From(ssrc_);
for (uint32_t i = 0; i < boundingSet->lengthOfSet(); i++) {
if (boundingSet->Tmmbr(i) > 0) {
tmmbn->WithTmmbr(boundingSet->Ssrc(i), boundingSet->Tmmbr(i),
boundingSet->PacketOH(i));
for (const rtcp::TmmbItem& tmmbr : tmmbn_to_send_) {
if (tmmbr.bitrate_bps() > 0) {
tmmbn->WithTmmbr(tmmbr);
}
}
@ -975,14 +970,14 @@ bool RTCPSender::RtcpXrReceiverReferenceTime() const {
}
// no callbacks allowed inside this function
int32_t RTCPSender::SetTMMBN(const TMMBRSet* boundingSet) {
void RTCPSender::SetTMMBN(const std::vector<rtcp::TmmbItem>* bounding_set) {
rtc::CritScope lock(&critical_section_rtcp_sender_);
if (0 == tmmbr_help_.SetTMMBRBoundingSetToSend(boundingSet)) {
SetFlag(kRtcpTmmbn, true);
return 0;
if (bounding_set) {
tmmbn_to_send_ = *bounding_set;
} else {
tmmbn_to_send_.clear();
}
return -1;
SetFlag(kRtcpTmmbn, true);
}
void RTCPSender::SetFlag(RTCPPacketType type, bool is_volatile) {

View File

@ -135,7 +135,7 @@ class RTCPSender {
void SetMaxPayloadLength(size_t max_payload_length);
int32_t SetTMMBN(const TMMBRSet* boundingSet);
void SetTMMBN(const std::vector<rtcp::TmmbItem>* boundingSet);
int32_t SetApplicationSpecificData(uint8_t subType,
uint32_t name,
@ -241,6 +241,8 @@ class RTCPSender {
std::vector<uint32_t> remb_ssrcs_ GUARDED_BY(critical_section_rtcp_sender_);
TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_);
std::vector<rtcp::TmmbItem> tmmbn_to_send_
GUARDED_BY(critical_section_rtcp_sender_);
uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_);
uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_);
size_t max_payload_length_;

View File

@ -688,13 +688,14 @@ TEST_F(RtcpSenderTest, TmmbrIncludedInCompoundPacketIfEnabled) {
TEST_F(RtcpSenderTest, SendTmmbn) {
rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound);
TMMBRSet bounding_set;
bounding_set.VerifyAndAllocateSet(1);
std::vector<rtcp::TmmbItem> bounding_set;
const uint32_t kBitrateKbps = 32768;
const uint32_t kPacketOh = 40;
const uint32_t kSourceSsrc = 12345;
bounding_set.AddEntry(kBitrateKbps, kPacketOh, kSourceSsrc);
EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set));
const rtcp::TmmbItem tmmbn(kSourceSsrc, kBitrateKbps * 1000, kPacketOh);
bounding_set.push_back(tmmbn);
rtcp_sender_->SetTMMBN(&bounding_set);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpSr));
EXPECT_EQ(1, parser()->sender_report()->num_packets());
EXPECT_EQ(1, parser()->tmmbn()->num_packets());
@ -713,8 +714,8 @@ TEST_F(RtcpSenderTest, SendTmmbn) {
// situation where this caused confusion.
TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) {
rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound);
TMMBRSet bounding_set;
EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set));
std::vector<rtcp::TmmbItem> bounding_set;
rtcp_sender_->SetTMMBN(&bounding_set);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpSr));
EXPECT_EQ(1, parser()->sender_report()->num_packets());
EXPECT_EQ(1, parser()->tmmbn()->num_packets());

View File

@ -680,8 +680,9 @@ void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) {
rtcp_sender_.SetTMMBRStatus(enable);
}
int32_t ModuleRtpRtcpImpl::SetTMMBN(const TMMBRSet* bounding_set) {
return rtcp_sender_.SetTMMBN(bounding_set);
void ModuleRtpRtcpImpl::SetTMMBN(
const std::vector<rtcp::TmmbItem>* bounding_set) {
rtcp_sender_.SetTMMBN(bounding_set);
}
// Returns the currently configured retransmission mode.

View File

@ -202,7 +202,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
void SetTMMBRStatus(bool enable) override;
int32_t SetTMMBN(const TMMBRSet* bounding_set);
void SetTMMBN(const std::vector<rtcp::TmmbItem>* bounding_set);
uint16_t MaxPayloadLength() const override;

View File

@ -69,7 +69,6 @@ void TMMBRSet::ClearEntry(uint32_t idx) {
TMMBRHelp::TMMBRHelp()
: _candidateSet(),
_boundingSet(),
_boundingSetToSend(),
_ptrIntersectionBoundingSet(NULL),
_ptrMaxPRBoundingSet(NULL) {
}
@ -105,39 +104,6 @@ TMMBRSet* TMMBRHelp::BoundingSet() {
return &_boundingSet;
}
int32_t
TMMBRHelp::SetTMMBRBoundingSetToSend(const TMMBRSet* boundingSetToSend)
{
rtc::CritScope lock(&_criticalSection);
if (boundingSetToSend == NULL)
{
_boundingSetToSend.clearSet();
return 0;
}
VerifyAndAllocateBoundingSetToSend(boundingSetToSend->lengthOfSet());
_boundingSetToSend.clearSet();
for (uint32_t i = 0; i < boundingSetToSend->lengthOfSet(); i++)
{
// cap at our configured max bitrate
uint32_t bitrate = boundingSetToSend->Tmmbr(i);
_boundingSetToSend.SetEntry(i, bitrate,
boundingSetToSend->PacketOH(i),
boundingSetToSend->Ssrc(i));
}
return 0;
}
int32_t
TMMBRHelp::VerifyAndAllocateBoundingSetToSend(uint32_t minimumSize)
{
rtc::CritScope lock(&_criticalSection);
_boundingSetToSend.VerifyAndAllocateSet(minimumSize);
return 0;
}
TMMBRSet*
TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize)
{
@ -153,12 +119,6 @@ TMMBRHelp::CandidateSet()
return &_candidateSet;
}
TMMBRSet*
TMMBRHelp::BoundingSetToSend()
{
return &_boundingSetToSend;
}
int32_t
TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet)
{

View File

@ -63,11 +63,9 @@ public:
TMMBRSet* BoundingSet(); // used for debuging
TMMBRSet* CandidateSet();
TMMBRSet* BoundingSetToSend();
TMMBRSet* VerifyAndAllocateCandidateSet(const uint32_t minimumSize);
int32_t FindTMMBRBoundingSet(TMMBRSet*& boundingSet);
int32_t SetTMMBRBoundingSetToSend(const TMMBRSet* boundingSetToSend);
bool IsOwner(const uint32_t ssrc, const uint32_t length) const;
@ -75,15 +73,12 @@ public:
protected:
TMMBRSet* VerifyAndAllocateBoundingSet(uint32_t minimumSize);
int32_t VerifyAndAllocateBoundingSetToSend(uint32_t minimumSize);
int32_t FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet);
private:
rtc::CriticalSection _criticalSection;
TMMBRSet _candidateSet;
TMMBRSet _boundingSet;
TMMBRSet _boundingSetToSend;
float* _ptrIntersectionBoundingSet;
float* _ptrMaxPRBoundingSet;