| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 swap((*this)[i], (*this)[j]); | 62 swap((*this)[i], (*this)[j]); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void TMMBRSet::ClearEntry(uint32_t idx) { | 65 void TMMBRSet::ClearEntry(uint32_t idx) { |
| 66 SetEntry(idx, 0, 0, 0); | 66 SetEntry(idx, 0, 0, 0); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TMMBRHelp::TMMBRHelp() | 69 TMMBRHelp::TMMBRHelp() |
| 70 : _candidateSet(), | 70 : _candidateSet(), |
| 71 _boundingSet(), | 71 _boundingSet(), |
| 72 _boundingSetToSend(), | |
| 73 _ptrIntersectionBoundingSet(NULL), | 72 _ptrIntersectionBoundingSet(NULL), |
| 74 _ptrMaxPRBoundingSet(NULL) { | 73 _ptrMaxPRBoundingSet(NULL) { |
| 75 } | 74 } |
| 76 | 75 |
| 77 TMMBRHelp::~TMMBRHelp() { | 76 TMMBRHelp::~TMMBRHelp() { |
| 78 delete [] _ptrIntersectionBoundingSet; | 77 delete [] _ptrIntersectionBoundingSet; |
| 79 delete [] _ptrMaxPRBoundingSet; | 78 delete [] _ptrMaxPRBoundingSet; |
| 80 _ptrIntersectionBoundingSet = 0; | 79 _ptrIntersectionBoundingSet = 0; |
| 81 _ptrMaxPRBoundingSet = 0; | 80 _ptrMaxPRBoundingSet = 0; |
| 82 } | 81 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 _ptrMaxPRBoundingSet = new float[minimumSize]; | 97 _ptrMaxPRBoundingSet = new float[minimumSize]; |
| 99 } | 98 } |
| 100 _boundingSet.VerifyAndAllocateSet(minimumSize); | 99 _boundingSet.VerifyAndAllocateSet(minimumSize); |
| 101 return &_boundingSet; | 100 return &_boundingSet; |
| 102 } | 101 } |
| 103 | 102 |
| 104 TMMBRSet* TMMBRHelp::BoundingSet() { | 103 TMMBRSet* TMMBRHelp::BoundingSet() { |
| 105 return &_boundingSet; | 104 return &_boundingSet; |
| 106 } | 105 } |
| 107 | 106 |
| 108 int32_t | |
| 109 TMMBRHelp::SetTMMBRBoundingSetToSend(const TMMBRSet* boundingSetToSend) | |
| 110 { | |
| 111 rtc::CritScope lock(&_criticalSection); | |
| 112 | |
| 113 if (boundingSetToSend == NULL) | |
| 114 { | |
| 115 _boundingSetToSend.clearSet(); | |
| 116 return 0; | |
| 117 } | |
| 118 | |
| 119 VerifyAndAllocateBoundingSetToSend(boundingSetToSend->lengthOfSet()); | |
| 120 _boundingSetToSend.clearSet(); | |
| 121 for (uint32_t i = 0; i < boundingSetToSend->lengthOfSet(); i++) | |
| 122 { | |
| 123 // cap at our configured max bitrate | |
| 124 uint32_t bitrate = boundingSetToSend->Tmmbr(i); | |
| 125 _boundingSetToSend.SetEntry(i, bitrate, | |
| 126 boundingSetToSend->PacketOH(i), | |
| 127 boundingSetToSend->Ssrc(i)); | |
| 128 } | |
| 129 return 0; | |
| 130 } | |
| 131 | |
| 132 int32_t | |
| 133 TMMBRHelp::VerifyAndAllocateBoundingSetToSend(uint32_t minimumSize) | |
| 134 { | |
| 135 rtc::CritScope lock(&_criticalSection); | |
| 136 | |
| 137 _boundingSetToSend.VerifyAndAllocateSet(minimumSize); | |
| 138 return 0; | |
| 139 } | |
| 140 | |
| 141 TMMBRSet* | 107 TMMBRSet* |
| 142 TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) | 108 TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize) |
| 143 { | 109 { |
| 144 rtc::CritScope lock(&_criticalSection); | 110 rtc::CritScope lock(&_criticalSection); |
| 145 | 111 |
| 146 _candidateSet.VerifyAndAllocateSet(minimumSize); | 112 _candidateSet.VerifyAndAllocateSet(minimumSize); |
| 147 return &_candidateSet; | 113 return &_candidateSet; |
| 148 } | 114 } |
| 149 | 115 |
| 150 TMMBRSet* | 116 TMMBRSet* |
| 151 TMMBRHelp::CandidateSet() | 117 TMMBRHelp::CandidateSet() |
| 152 { | 118 { |
| 153 return &_candidateSet; | 119 return &_candidateSet; |
| 154 } | 120 } |
| 155 | 121 |
| 156 TMMBRSet* | |
| 157 TMMBRHelp::BoundingSetToSend() | |
| 158 { | |
| 159 return &_boundingSetToSend; | |
| 160 } | |
| 161 | |
| 162 int32_t | 122 int32_t |
| 163 TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) | 123 TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet) |
| 164 { | 124 { |
| 165 rtc::CritScope lock(&_criticalSection); | 125 rtc::CritScope lock(&_criticalSection); |
| 166 | 126 |
| 167 // Work on local variable, will be modified | 127 // Work on local variable, will be modified |
| 168 TMMBRSet candidateSet; | 128 TMMBRSet candidateSet; |
| 169 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); | 129 candidateSet.VerifyAndAllocateSet(_candidateSet.capacity()); |
| 170 | 130 |
| 171 for (uint32_t i = 0; i < _candidateSet.size(); i++) | 131 for (uint32_t i = 0; i < _candidateSet.size(); i++) |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); | 398 uint32_t curNetBitRateKbit = _candidateSet.Tmmbr(i); |
| 439 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { | 399 if (curNetBitRateKbit < MIN_VIDEO_BW_MANAGEMENT_BITRATE) { |
| 440 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; | 400 curNetBitRateKbit = MIN_VIDEO_BW_MANAGEMENT_BITRATE; |
| 441 } | 401 } |
| 442 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? | 402 *minBitrateKbit = curNetBitRateKbit < *minBitrateKbit ? |
| 443 curNetBitRateKbit : *minBitrateKbit; | 403 curNetBitRateKbit : *minBitrateKbit; |
| 444 } | 404 } |
| 445 return true; | 405 return true; |
| 446 } | 406 } |
| 447 } // namespace webrtc | 407 } // namespace webrtc |
| OLD | NEW |