| 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 */ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 config.media_ratio = MediaRatio(allocated_bitrate, protection_bitrate); | 117 config.media_ratio = MediaRatio(allocated_bitrate, protection_bitrate); |
| 118 config.allocated_bitrate_bps = allocated_bitrate; | 118 config.allocated_bitrate_bps = allocated_bitrate; |
| 119 } | 119 } |
| 120 UpdateAllocationLimits(); | 120 UpdateAllocationLimits(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer, | 123 void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer, |
| 124 uint32_t min_bitrate_bps, | 124 uint32_t min_bitrate_bps, |
| 125 uint32_t max_bitrate_bps, | 125 uint32_t max_bitrate_bps, |
| 126 uint32_t pad_up_bitrate_bps, | 126 uint32_t pad_up_bitrate_bps, |
| 127 bool enforce_min_bitrate) { | 127 bool enforce_min_bitrate, |
| 128 std::string track_id) { |
| 128 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); | 129 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); |
| 129 auto it = FindObserverConfig(observer); | 130 auto it = FindObserverConfig(observer); |
| 130 | 131 |
| 131 // Update settings if the observer already exists, create a new one otherwise. | 132 // Update settings if the observer already exists, create a new one otherwise. |
| 132 if (it != bitrate_observer_configs_.end()) { | 133 if (it != bitrate_observer_configs_.end()) { |
| 133 it->min_bitrate_bps = min_bitrate_bps; | 134 it->min_bitrate_bps = min_bitrate_bps; |
| 134 it->max_bitrate_bps = max_bitrate_bps; | 135 it->max_bitrate_bps = max_bitrate_bps; |
| 135 it->pad_up_bitrate_bps = pad_up_bitrate_bps; | 136 it->pad_up_bitrate_bps = pad_up_bitrate_bps; |
| 136 it->enforce_min_bitrate = enforce_min_bitrate; | 137 it->enforce_min_bitrate = enforce_min_bitrate; |
| 137 } else { | 138 } else { |
| 138 bitrate_observer_configs_.push_back( | 139 bitrate_observer_configs_.push_back( |
| 139 ObserverConfig(observer, min_bitrate_bps, max_bitrate_bps, | 140 ObserverConfig(observer, min_bitrate_bps, max_bitrate_bps, |
| 140 pad_up_bitrate_bps, enforce_min_bitrate)); | 141 pad_up_bitrate_bps, enforce_min_bitrate, track_id)); |
| 141 } | 142 } |
| 142 | 143 |
| 143 ObserverAllocation allocation; | 144 ObserverAllocation allocation; |
| 144 if (last_bitrate_bps_ > 0) { | 145 if (last_bitrate_bps_ > 0) { |
| 145 // Calculate a new allocation and update all observers. | 146 // Calculate a new allocation and update all observers. |
| 146 allocation = AllocateBitrates(last_bitrate_bps_); | 147 allocation = AllocateBitrates(last_bitrate_bps_); |
| 147 for (auto& config : bitrate_observer_configs_) { | 148 for (auto& config : bitrate_observer_configs_) { |
| 148 uint32_t allocated_bitrate = allocation[config.observer]; | 149 uint32_t allocated_bitrate = allocation[config.observer]; |
| 149 uint32_t protection_bitrate = config.observer->OnBitrateUpdated( | 150 uint32_t protection_bitrate = config.observer->OnBitrateUpdated( |
| 150 allocated_bitrate, last_fraction_loss_, last_rtt_, | 151 allocated_bitrate, last_fraction_loss_, last_rtt_, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 static_cast<uint32_t>(bitrate_observer_configs_.size()); | 432 static_cast<uint32_t>(bitrate_observer_configs_.size()); |
| 432 for (const auto& observer_config : bitrate_observer_configs_) { | 433 for (const auto& observer_config : bitrate_observer_configs_) { |
| 433 if (observer_config.min_bitrate_bps + extra_bitrate_per_observer < | 434 if (observer_config.min_bitrate_bps + extra_bitrate_per_observer < |
| 434 MinBitrateWithHysteresis(observer_config)) { | 435 MinBitrateWithHysteresis(observer_config)) { |
| 435 return false; | 436 return false; |
| 436 } | 437 } |
| 437 } | 438 } |
| 438 return true; | 439 return true; |
| 439 } | 440 } |
| 440 } // namespace webrtc | 441 } // namespace webrtc |
| OLD | NEW |