OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | 11 |
12 #include "webrtc/modules/bitrate_controller/include/bitrate_allocator.h" | 12 #include "webrtc/call/bitrate_allocator.h" |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <utility> | 15 #include <utility> |
16 | 16 |
17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 // Allow packets to be transmitted in up to 2 times max video bitrate if the | 21 // Allow packets to be transmitted in up to 2 times max video bitrate if the |
22 // bandwidth estimate allows it. | 22 // bandwidth estimate allows it. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 void BitrateAllocator::EnforceMinBitrate(bool enforce_min_bitrate) { | 131 void BitrateAllocator::EnforceMinBitrate(bool enforce_min_bitrate) { |
132 CriticalSectionScoped lock(crit_sect_.get()); | 132 CriticalSectionScoped lock(crit_sect_.get()); |
133 enforce_min_bitrate_ = enforce_min_bitrate; | 133 enforce_min_bitrate_ = enforce_min_bitrate; |
134 } | 134 } |
135 | 135 |
136 BitrateAllocator::ObserverBitrateMap BitrateAllocator::NormalRateAllocation( | 136 BitrateAllocator::ObserverBitrateMap BitrateAllocator::NormalRateAllocation( |
137 uint32_t bitrate, | 137 uint32_t bitrate, |
138 uint32_t sum_min_bitrates) { | 138 uint32_t sum_min_bitrates) { |
139 uint32_t number_of_observers = bitrate_observers_.size(); | 139 uint32_t number_of_observers = |
| 140 static_cast<uint32_t>(bitrate_observers_.size()); |
140 uint32_t bitrate_per_observer = | 141 uint32_t bitrate_per_observer = |
141 (bitrate - sum_min_bitrates) / number_of_observers; | 142 (bitrate - sum_min_bitrates) / number_of_observers; |
142 // Use map to sort list based on max bitrate. | 143 // Use map to sort list based on max bitrate. |
143 ObserverSortingMap list_max_bitrates; | 144 ObserverSortingMap list_max_bitrates; |
144 for (const auto& observer : bitrate_observers_) { | 145 for (const auto& observer : bitrate_observers_) { |
145 list_max_bitrates.insert(std::pair<uint32_t, ObserverConfiguration>( | 146 list_max_bitrates.insert(std::pair<uint32_t, ObserverConfiguration>( |
146 observer.second.max_bitrate, | 147 observer.second.max_bitrate, |
147 ObserverConfiguration(observer.first, observer.second.min_bitrate))); | 148 ObserverConfiguration(observer.first, observer.second.min_bitrate))); |
148 } | 149 } |
149 ObserverBitrateMap allocation; | 150 ObserverBitrateMap allocation; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 for (const auto& observer : bitrate_observers_) { | 185 for (const auto& observer : bitrate_observers_) { |
185 uint32_t allocated_bitrate = | 186 uint32_t allocated_bitrate = |
186 std::min(remainder, observer.second.min_bitrate); | 187 std::min(remainder, observer.second.min_bitrate); |
187 allocation[observer.first] = allocated_bitrate; | 188 allocation[observer.first] = allocated_bitrate; |
188 remainder -= allocated_bitrate; | 189 remainder -= allocated_bitrate; |
189 } | 190 } |
190 } | 191 } |
191 return allocation; | 192 return allocation; |
192 } | 193 } |
193 } // namespace webrtc | 194 } // namespace webrtc |
OLD | NEW |