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

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

Issue 2224933002: Cleaned out boundingSet member from TMMBRHelp class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nit from presubmit Created 4 years, 4 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
11 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" 11 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 #include <utility>
15 16
16 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
20 void TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize) { 21 void TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize) {
21 clear(); 22 clear();
22 reserve(minimumSize); 23 reserve(minimumSize);
23 } 24 }
24 25
(...skipping 28 matching lines...) Expand all
53 54
54 TMMBRSet* TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) { 55 TMMBRSet* TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) {
55 _candidateSet.VerifyAndAllocateSet(minimumSize); 56 _candidateSet.VerifyAndAllocateSet(minimumSize);
56 return &_candidateSet; 57 return &_candidateSet;
57 } 58 }
58 59
59 TMMBRSet* TMMBRHelp::CandidateSet() { 60 TMMBRSet* TMMBRHelp::CandidateSet() {
60 return &_candidateSet; 61 return &_candidateSet;
61 } 62 }
62 63
63 int32_t TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) { 64 std::vector<rtcp::TmmbItem> TMMBRHelp::FindTMMBRBoundingSet() {
64 // Work on local variable, will be modified 65 // Work on local variable, will be modified
65 TMMBRSet candidateSet; 66 TMMBRSet candidateSet;
66 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); 67 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity());
67 68
68 for (size_t i = 0; i < _candidateSet.size(); i++) { 69 for (size_t i = 0; i < _candidateSet.size(); i++) {
69 if (_candidateSet.Tmmbr(i)) { 70 if (_candidateSet.Tmmbr(i)) {
70 candidateSet.AddEntry(_candidateSet.Tmmbr(i), _candidateSet.PacketOH(i), 71 candidateSet.AddEntry(_candidateSet.Tmmbr(i), _candidateSet.PacketOH(i),
71 _candidateSet.Ssrc(i)); 72 _candidateSet.Ssrc(i));
72 } else { 73 } else {
73 // make sure this is zero if tmmbr = 0 74 // make sure this is zero if tmmbr = 0
74 RTC_DCHECK_EQ(_candidateSet.PacketOH(i), 0u); 75 RTC_DCHECK_EQ(_candidateSet.PacketOH(i), 0u);
75 // Old code: 76 // Old code:
76 // _candidateSet.ptrPacketOHSet[i] = 0; 77 // _candidateSet.ptrPacketOHSet[i] = 0;
77 } 78 }
78 } 79 }
79 80
80 // Number of set candidates 81 // Number of set candidates
81 int32_t numSetCandidates = candidateSet.lengthOfSet(); 82 int32_t numSetCandidates = candidateSet.lengthOfSet();
82 // Find bounding set 83 // Find bounding set
83 uint32_t numBoundingSet = 0; 84 std::vector<rtcp::TmmbItem> bounding;
84 if (numSetCandidates > 0) { 85 if (numSetCandidates > 0) {
85 FindBoundingSet(std::move(candidateSet), &_boundingSet); 86 FindBoundingSet(std::move(candidateSet), &bounding);
86 numBoundingSet = _boundingSet.size(); 87 size_t numBoundingSet = bounding.size();
87 if (numBoundingSet < 1 || (numBoundingSet > _candidateSet.size())) { 88 RTC_DCHECK_GE(numBoundingSet, 1u);
88 return -1; 89 RTC_DCHECK_LE(numBoundingSet, _candidateSet.size());
89 }
90 boundingSet = &_boundingSet;
91 } 90 }
92 return numBoundingSet; 91 return bounding;
93 } 92 }
94 93
95 void TMMBRHelp::FindBoundingSet(std::vector<rtcp::TmmbItem> candidates, 94 void TMMBRHelp::FindBoundingSet(std::vector<rtcp::TmmbItem> candidates,
96 std::vector<rtcp::TmmbItem>* bounding_set) { 95 std::vector<rtcp::TmmbItem>* bounding_set) {
97 RTC_DCHECK(bounding_set); 96 RTC_DCHECK(bounding_set);
98 RTC_DCHECK(!candidates.empty()); 97 RTC_DCHECK(!candidates.empty());
99 size_t num_candidates = candidates.size(); 98 size_t num_candidates = candidates.size();
100 99
101 if (num_candidates == 1) { 100 if (num_candidates == 1) {
102 RTC_DCHECK(candidates[0].bitrate_bps()); 101 RTC_DCHECK(candidates[0].bitrate_bps());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 static_cast<float>(packet_overhead); 223 static_cast<float>(packet_overhead);
225 } 224 }
226 --num_candidates; 225 --num_candidates;
227 get_new_candidate = true; 226 get_new_candidate = true;
228 } 227 }
229 228
230 // 9. Go back to step 5 if any tuple remains in candidate list. 229 // 9. Go back to step 5 if any tuple remains in candidate list.
231 } 230 }
232 } 231 }
233 232
234 bool TMMBRHelp::IsOwner(const uint32_t ssrc, const uint32_t length) const { 233 bool TMMBRHelp::IsOwner(const std::vector<rtcp::TmmbItem>& bounding,
235 if (length == 0) { 234 uint32_t ssrc) {
236 // Empty bounding set. 235 for (const rtcp::TmmbItem& item : bounding) {
237 return false; 236 if (item.ssrc() == ssrc) {
238 }
239 for (size_t i = 0; (i < length) && (i < _boundingSet.size()); ++i) {
240 if (_boundingSet.Ssrc(i) == ssrc) {
241 return true; 237 return true;
242 } 238 }
243 } 239 }
244 return false; 240 return false;
245 } 241 }
246 242
247 bool TMMBRHelp::CalcMinBitRate(uint32_t* minBitrateKbit) const { 243 bool TMMBRHelp::CalcMinBitRate(uint32_t* minBitrateKbit) const {
248 if (_candidateSet.size() == 0) { 244 if (_candidateSet.size() == 0) {
249 // Empty bounding set. 245 // Empty bounding set.
250 return false; 246 return false;
251 } 247 }
252 *minBitrateKbit = std::numeric_limits<uint32_t>::max(); 248 *minBitrateKbit = std::numeric_limits<uint32_t>::max();
253 249
254 for (size_t i = 0; i < _candidateSet.lengthOfSet(); ++i) { 250 for (size_t i = 0; i < _candidateSet.lengthOfSet(); ++i) {
255 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); 251 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i);
256 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { 252 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) {
257 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; 253 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE;
258 } 254 }
259 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? curNetBitRateKbit 255 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? curNetBitRateKbit
260 : *minBitrateKbit; 256 : *minBitrateKbit;
261 } 257 }
262 return true; 258 return true;
263 } 259 }
264 } // namespace webrtc 260 } // 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