OLD | NEW |
---|---|
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 | 53 |
54 TMMBRSet* TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) { | 54 TMMBRSet* TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) { |
55 _candidateSet.VerifyAndAllocateSet(minimumSize); | 55 _candidateSet.VerifyAndAllocateSet(minimumSize); |
56 return &_candidateSet; | 56 return &_candidateSet; |
57 } | 57 } |
58 | 58 |
59 TMMBRSet* TMMBRHelp::CandidateSet() { | 59 TMMBRSet* TMMBRHelp::CandidateSet() { |
60 return &_candidateSet; | 60 return &_candidateSet; |
61 } | 61 } |
62 | 62 |
63 int32_t TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) { | 63 std::vector<rtcp::TmmbItem> TMMBRHelp::FindTMMBRBoundingSet() { |
64 // Work on local variable, will be modified | 64 // Work on local variable, will be modified |
65 TMMBRSet candidateSet; | 65 TMMBRSet candidateSet; |
66 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); | 66 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); |
67 | 67 |
68 for (size_t i = 0; i < _candidateSet.size(); i++) { | 68 for (size_t i = 0; i < _candidateSet.size(); i++) { |
69 if (_candidateSet.Tmmbr(i)) { | 69 if (_candidateSet.Tmmbr(i)) { |
70 candidateSet.AddEntry(_candidateSet.Tmmbr(i), _candidateSet.PacketOH(i), | 70 candidateSet.AddEntry(_candidateSet.Tmmbr(i), _candidateSet.PacketOH(i), |
71 _candidateSet.Ssrc(i)); | 71 _candidateSet.Ssrc(i)); |
72 } else { | 72 } else { |
73 // make sure this is zero if tmmbr = 0 | 73 // make sure this is zero if tmmbr = 0 |
74 RTC_DCHECK_EQ(_candidateSet.PacketOH(i), 0u); | 74 RTC_DCHECK_EQ(_candidateSet.PacketOH(i), 0u); |
75 // Old code: | 75 // Old code: |
76 // _candidateSet.ptrPacketOHSet[i] = 0; | 76 // _candidateSet.ptrPacketOHSet[i] = 0; |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 // Number of set candidates | 80 // Number of set candidates |
81 int32_t numSetCandidates = candidateSet.lengthOfSet(); | 81 int32_t numSetCandidates = candidateSet.lengthOfSet(); |
82 // Find bounding set | 82 // Find bounding set |
83 uint32_t numBoundingSet = 0; | 83 std::vector<rtcp::TmmbItem> bounding; |
84 if (numSetCandidates > 0) { | 84 if (numSetCandidates > 0) { |
85 FindBoundingSet(std::move(candidateSet), &_boundingSet); | 85 FindBoundingSet(std::move(candidateSet), &bounding); |
86 numBoundingSet = _boundingSet.size(); | 86 size_t numBoundingSet = bounding.size(); |
87 if (numBoundingSet < 1 || (numBoundingSet > _candidateSet.size())) { | 87 RTC_DCHECK_GE(numBoundingSet, 1u); |
88 return -1; | 88 RTC_DCHECK_LE(numBoundingSet, _candidateSet.size()); |
philipel
2016/08/09 12:00:24
Earlier if we failed to find a bounding set then i
danilchap
2016/08/09 13:02:13
yes, DCHECK shouldn't be used to validate bad inpu
| |
89 } | |
90 boundingSet = &_boundingSet; | |
91 } | 89 } |
92 return numBoundingSet; | 90 return bounding; |
93 } | 91 } |
94 | 92 |
95 void TMMBRHelp::FindBoundingSet(std::vector<rtcp::TmmbItem> candidates, | 93 void TMMBRHelp::FindBoundingSet(std::vector<rtcp::TmmbItem> candidates, |
96 std::vector<rtcp::TmmbItem>* bounding_set) { | 94 std::vector<rtcp::TmmbItem>* bounding_set) { |
97 RTC_DCHECK(bounding_set); | 95 RTC_DCHECK(bounding_set); |
98 RTC_DCHECK(!candidates.empty()); | 96 RTC_DCHECK(!candidates.empty()); |
99 size_t num_candidates = candidates.size(); | 97 size_t num_candidates = candidates.size(); |
100 | 98 |
101 if (num_candidates == 1) { | 99 if (num_candidates == 1) { |
102 RTC_DCHECK(candidates[0].bitrate_bps()); | 100 RTC_DCHECK(candidates[0].bitrate_bps()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 static_cast<float>(packet_overhead); | 222 static_cast<float>(packet_overhead); |
225 } | 223 } |
226 --num_candidates; | 224 --num_candidates; |
227 get_new_candidate = true; | 225 get_new_candidate = true; |
228 } | 226 } |
229 | 227 |
230 // 9. Go back to step 5 if any tuple remains in candidate list. | 228 // 9. Go back to step 5 if any tuple remains in candidate list. |
231 } | 229 } |
232 } | 230 } |
233 | 231 |
234 bool TMMBRHelp::IsOwner(const uint32_t ssrc, const uint32_t length) const { | 232 bool TMMBRHelp::IsOwner(const std::vector<rtcp::TmmbItem>& bounding, |
235 if (length == 0) { | 233 uint32_t ssrc) { |
236 // Empty bounding set. | 234 for (const rtcp::TmmbItem& item : bounding) { |
237 return false; | 235 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; | 236 return true; |
242 } | 237 } |
243 } | 238 } |
244 return false; | 239 return false; |
245 } | 240 } |
246 | 241 |
247 bool TMMBRHelp::CalcMinBitRate(uint32_t* minBitrateKbit) const { | 242 bool TMMBRHelp::CalcMinBitRate(uint32_t* minBitrateKbit) const { |
248 if (_candidateSet.size() == 0) { | 243 if (_candidateSet.size() == 0) { |
249 // Empty bounding set. | 244 // Empty bounding set. |
250 return false; | 245 return false; |
251 } | 246 } |
252 *minBitrateKbit = std::numeric_limits<uint32_t>::max(); | 247 *minBitrateKbit = std::numeric_limits<uint32_t>::max(); |
253 | 248 |
254 for (size_t i = 0; i < _candidateSet.lengthOfSet(); ++i) { | 249 for (size_t i = 0; i < _candidateSet.lengthOfSet(); ++i) { |
255 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); | 250 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); |
256 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { | 251 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { |
257 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; | 252 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; |
258 } | 253 } |
259 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? curNetBitRateKbit | 254 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? curNetBitRateKbit |
260 : *minBitrateKbit; | 255 : *minBitrateKbit; |
261 } | 256 } |
262 return true; | 257 return true; |
263 } | 258 } |
264 } // namespace webrtc | 259 } // namespace webrtc |
OLD | NEW |