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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/tmmbr_help.cc

Issue 1959013003: TMMBRHelp moved from member object/base class to stack object, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: includes adjusted Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/tmmbr_help.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 TMMBRHelp::~TMMBRHelp() { 76 TMMBRHelp::~TMMBRHelp() {
77 delete [] _ptrIntersectionBoundingSet; 77 delete [] _ptrIntersectionBoundingSet;
78 delete [] _ptrMaxPRBoundingSet; 78 delete [] _ptrMaxPRBoundingSet;
79 _ptrIntersectionBoundingSet = 0; 79 _ptrIntersectionBoundingSet = 0;
80 _ptrMaxPRBoundingSet = 0; 80 _ptrMaxPRBoundingSet = 0;
81 } 81 }
82 82
83 TMMBRSet* 83 TMMBRSet*
84 TMMBRHelp::VerifyAndAllocateBoundingSet(uint32_t minimumSize) 84 TMMBRHelp::VerifyAndAllocateBoundingSet(uint32_t minimumSize)
85 { 85 {
86 rtc::CritScope lock(&_criticalSection);
87
88 if(minimumSize > _boundingSet.capacity()) 86 if(minimumSize > _boundingSet.capacity())
89 { 87 {
90 // make sure that our buffers are big enough 88 // make sure that our buffers are big enough
91 if(_ptrIntersectionBoundingSet) 89 if(_ptrIntersectionBoundingSet)
92 { 90 {
93 delete [] _ptrIntersectionBoundingSet; 91 delete [] _ptrIntersectionBoundingSet;
94 delete [] _ptrMaxPRBoundingSet; 92 delete [] _ptrMaxPRBoundingSet;
95 } 93 }
96 _ptrIntersectionBoundingSet = new float[minimumSize]; 94 _ptrIntersectionBoundingSet = new float[minimumSize];
97 _ptrMaxPRBoundingSet = new float[minimumSize]; 95 _ptrMaxPRBoundingSet = new float[minimumSize];
98 } 96 }
99 _boundingSet.VerifyAndAllocateSet(minimumSize); 97 _boundingSet.VerifyAndAllocateSet(minimumSize);
100 return &_boundingSet; 98 return &_boundingSet;
101 } 99 }
102 100
103 TMMBRSet* TMMBRHelp::BoundingSet() { 101 TMMBRSet* TMMBRHelp::BoundingSet() {
104 return &_boundingSet; 102 return &_boundingSet;
105 } 103 }
106 104
107 TMMBRSet* 105 TMMBRSet*
108 TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) 106 TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize)
109 { 107 {
110 rtc::CritScope lock(&_criticalSection);
111
112 _candidateSet.VerifyAndAllocateSet(minimumSize); 108 _candidateSet.VerifyAndAllocateSet(minimumSize);
113 return &_candidateSet; 109 return &_candidateSet;
114 } 110 }
115 111
116 TMMBRSet* 112 TMMBRSet*
117 TMMBRHelp::CandidateSet() 113 TMMBRHelp::CandidateSet()
118 { 114 {
119 return &_candidateSet; 115 return &_candidateSet;
120 } 116 }
121 117
122 int32_t 118 int32_t
123 TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) 119 TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet)
124 { 120 {
125 rtc::CritScope lock(&_criticalSection);
126
127 // Work on local variable, will be modified 121 // Work on local variable, will be modified
128 TMMBRSet candidateSet; 122 TMMBRSet candidateSet;
129 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); 123 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity());
130 124
131 for (uint32_t i = 0; i < _candidateSet.size(); i++) 125 for (uint32_t i = 0; i < _candidateSet.size(); i++)
132 { 126 {
133 if(_candidateSet.Tmmbr(i)) 127 if(_candidateSet.Tmmbr(i))
134 { 128 {
135 candidateSet.AddEntry(_candidateSet.Tmmbr(i), 129 candidateSet.AddEntry(_candidateSet.Tmmbr(i),
136 _candidateSet.PacketOH(i), 130 _candidateSet.PacketOH(i),
(...skipping 21 matching lines...) Expand all
158 } 152 }
159 boundingSet = &_boundingSet; 153 boundingSet = &_boundingSet;
160 } 154 }
161 return numBoundingSet; 155 return numBoundingSet;
162 } 156 }
163 157
164 158
165 int32_t 159 int32_t
166 TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet) 160 TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
167 { 161 {
168 rtc::CritScope lock(&_criticalSection);
169
170 uint32_t numBoundingSet = 0; 162 uint32_t numBoundingSet = 0;
171 VerifyAndAllocateBoundingSet(candidateSet.capacity()); 163 VerifyAndAllocateBoundingSet(candidateSet.capacity());
172 164
173 if (numCandidates == 1) 165 if (numCandidates == 1)
174 { 166 {
175 for (uint32_t i = 0; i < candidateSet.size(); i++) 167 for (uint32_t i = 0; i < candidateSet.size(); i++)
176 { 168 {
177 if (candidateSet.Tmmbr(i) > 0) 169 if (candidateSet.Tmmbr(i) > 0)
178 { 170 {
179 _boundingSet.AddEntry(candidateSet.Tmmbr(i), 171 _boundingSet.AddEntry(candidateSet.Tmmbr(i),
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 355 }
364 356
365 // 9. Go back to step 5 if any tuple remains in candidate list 357 // 9. Go back to step 5 if any tuple remains in candidate list
366 } while (numCandidates > 0); 358 } while (numCandidates > 0);
367 359
368 return numBoundingSet; 360 return numBoundingSet;
369 } 361 }
370 362
371 bool TMMBRHelp::IsOwner(const uint32_t ssrc, 363 bool TMMBRHelp::IsOwner(const uint32_t ssrc,
372 const uint32_t length) const { 364 const uint32_t length) const {
373 rtc::CritScope lock(&_criticalSection);
374
375 if (length == 0) { 365 if (length == 0) {
376 // Empty bounding set. 366 // Empty bounding set.
377 return false; 367 return false;
378 } 368 }
379 for(uint32_t i = 0; 369 for(uint32_t i = 0;
380 (i < length) && (i < _boundingSet.size()); ++i) { 370 (i < length) && (i < _boundingSet.size()); ++i) {
381 if(_boundingSet.Ssrc(i) == ssrc) { 371 if(_boundingSet.Ssrc(i) == ssrc) {
382 return true; 372 return true;
383 } 373 }
384 } 374 }
385 return false; 375 return false;
386 } 376 }
387 377
388 bool TMMBRHelp::CalcMinBitRate( uint32_t* minBitrateKbit) const { 378 bool TMMBRHelp::CalcMinBitRate( uint32_t* minBitrateKbit) const {
389 rtc::CritScope lock(&_criticalSection);
390
391 if (_candidateSet.size() == 0) { 379 if (_candidateSet.size() == 0) {
392 // Empty bounding set. 380 // Empty bounding set.
393 return false; 381 return false;
394 } 382 }
395 *minBitrateKbit = std::numeric_limits<uint32_t>::max(); 383 *minBitrateKbit = std::numeric_limits<uint32_t>::max();
396 384
397 for (uint32_t i = 0; i < _candidateSet.lengthOfSet(); ++i) { 385 for (uint32_t i = 0; i < _candidateSet.lengthOfSet(); ++i) {
398 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); 386 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i);
399 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { 387 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) {
400 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; 388 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE;
401 } 389 }
402 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? 390 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ?
403 curNetBitRateKbit : *minBitrateKbit; 391 curNetBitRateKbit : *minBitrateKbit;
404 } 392 }
405 return true; 393 return true;
406 } 394 }
407 } // namespace webrtc 395 } // namespace webrtc
OLDNEW
« no previous file with comments | « 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