Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: webrtc/modules/rtp_rtcp/source/tmmbr_help.cc

Issue 1669323002: TMMBRSet become vector<rtcp::TmmbItem> (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
diff --git a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
index f994ff704932ebc7ddddef5f1abebc4fcf667a66..c26013e1156919076dc0e7dc8030a8685067bb6f 100644
--- a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
+++ b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
@@ -19,32 +19,29 @@
namespace webrtc {
TMMBRSet::TMMBRSet() :
- _sizeOfSet(0),
_lengthOfSet(0)
{
}
TMMBRSet::~TMMBRSet()
{
- _sizeOfSet = 0;
_lengthOfSet = 0;
}
void
TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize)
{
- if(minimumSize > _sizeOfSet)
+ if(minimumSize > size())
{
// make sure that our buffers are big enough
- _data.resize(minimumSize);
- _sizeOfSet = minimumSize;
+ resize(minimumSize);
}
// reset memory
- for(uint32_t i = 0; i < _sizeOfSet; i++)
+ for(uint32_t i = 0; i < size(); i++)
{
- _data.at(i).tmmbr = 0;
- _data.at(i).packet_oh = 0;
- _data.at(i).ssrc = 0;
+ at(i).set_bitrate_bps(0);
philipel 2016/02/23 13:46:39 replace at() with operator[] since at() does bound
danilchap 2016/02/23 14:39:47 exception is not a problem, still better avoid unn
+ at(i).set_packet_overhead(0);
+ at(i).set_ssrc(0);
}
_lengthOfSet = 0;
}
@@ -52,12 +49,9 @@ TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize)
void
TMMBRSet::VerifyAndAllocateSetKeepingData(uint32_t minimumSize)
{
- if(minimumSize > _sizeOfSet)
+ if(minimumSize > size())
{
- {
- _data.resize(minimumSize);
- }
- _sizeOfSet = minimumSize;
+ resize(minimumSize);
}
}
@@ -65,10 +59,10 @@ void TMMBRSet::SetEntry(unsigned int i,
uint32_t tmmbrSet,
uint32_t packetOHSet,
uint32_t ssrcSet) {
- assert(i < _sizeOfSet);
- _data.at(i).tmmbr = tmmbrSet;
- _data.at(i).packet_oh = packetOHSet;
- _data.at(i).ssrc = ssrcSet;
+ assert(i < size());
philipel 2016/02/23 13:46:39 Use RTC_DCHECK instead of assert.
danilchap 2016/02/23 14:39:47 Done.
+ at(i).set_bitrate_bps(tmmbrSet * 1000);
philipel 2016/02/23 13:46:39 Again, replace at() with operator[].
danilchap 2016/02/23 14:39:47 Done.
+ at(i).set_packet_overhead(packetOHSet);
+ at(i).set_ssrc(ssrcSet);
if (i >= _lengthOfSet) {
_lengthOfSet = i + 1;
}
@@ -77,22 +71,20 @@ void TMMBRSet::SetEntry(unsigned int i,
void TMMBRSet::AddEntry(uint32_t tmmbrSet,
uint32_t packetOHSet,
uint32_t ssrcSet) {
- assert(_lengthOfSet < _sizeOfSet);
+ assert(_lengthOfSet < size());
philipel 2016/02/23 13:46:38 Use RTC_DCHECK.
danilchap 2016/02/23 14:39:47 Done.
SetEntry(_lengthOfSet, tmmbrSet, packetOHSet, ssrcSet);
}
void TMMBRSet::RemoveEntry(uint32_t sourceIdx) {
assert(sourceIdx < _lengthOfSet);
philipel 2016/02/23 13:46:38 RTC_DCHECK :)
danilchap 2016/02/23 14:39:47 Done.
- _data.erase(_data.begin() + sourceIdx);
+ erase(begin() + sourceIdx);
_lengthOfSet--;
- _data.resize(_sizeOfSet); // Ensure that size remains the same.
+ resize(size()+1); // Ensure that size remains the same.
}
void TMMBRSet::SwapEntries(uint32_t i, uint32_t j) {
- SetElement temp;
- temp = _data[i];
- _data[i] = _data[j];
- _data[j] = temp;
+ using std::swap;
+ swap(at(i), at(j));
philipel 2016/02/23 13:46:38 Remove line 86 and just go for std::swap instead.
danilchap 2016/02/23 14:39:47 But that is not recommended way to use swap functi
}
void TMMBRSet::ClearEntry(uint32_t idx) {
« webrtc/modules/rtp_rtcp/source/tmmbr_help.h ('K') | « webrtc/modules/rtp_rtcp/source/tmmbr_help.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698