Chromium Code Reviews| Index: webrtc/call/bitrate_allocator.cc |
| diff --git a/webrtc/call/bitrate_allocator.cc b/webrtc/call/bitrate_allocator.cc |
| index 2eb40b0670813c008b1b594541fc1e12147e47e9..db7acb80af6e941948716aea84a36e1200803f53 100644 |
| --- a/webrtc/call/bitrate_allocator.cc |
| +++ b/webrtc/call/bitrate_allocator.cc |
| @@ -56,7 +56,8 @@ BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer) |
| clock_(Clock::GetRealTimeClock()), |
| last_bwe_log_time_(0), |
| total_requested_padding_bitrate_(0), |
| - total_requested_min_bitrate_(0) { |
| + total_requested_min_bitrate_(0), |
| + bitrate_allocation_strategy_(nullptr) { |
| sequenced_checker_.Detach(); |
| } |
| @@ -199,6 +200,7 @@ void BitrateAllocator::UpdateAllocationLimits() { |
| void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) { |
| RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); |
| + |
| auto it = FindObserverConfig(observer); |
| if (it != bitrate_observer_configs_.end()) { |
| bitrate_observer_configs_.erase(it); |
| @@ -224,6 +226,12 @@ int BitrateAllocator::GetStartBitrate(BitrateAllocatorObserver* observer) { |
| } |
| } |
| +void BitrateAllocator::SetBitrateAllocationStrategy( |
| + rtc::BitrateAllocationStrategy* bitrate_allocation_strategy) { |
| + RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); |
| + bitrate_allocation_strategy_ = bitrate_allocation_strategy; |
| +} |
| + |
| BitrateAllocator::ObserverConfigs::iterator |
| BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) { |
| RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); |
| @@ -241,6 +249,24 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates( |
| if (bitrate_observer_configs_.empty()) |
| return ObserverAllocation(); |
| + if (bitrate_allocation_strategy_ != nullptr) { |
| + std::vector<const rtc::BitrateAllocationStrategy::TrackConfig*> |
| + track_configs; |
|
nisse-webrtc
2017/09/12 10:39:05
Consider allocating a vector of size bitrate_obser
alexnarest
2017/09/14 13:08:33
Done.
|
| + for (const auto& observer_config : bitrate_observer_configs_) { |
| + track_configs.push_back(&observer_config); |
| + } |
| + std::vector<uint32_t> track_allocations = |
| + bitrate_allocation_strategy_->AllocateBitrates(bitrate, track_configs); |
| + // The strategy should return allocation for all tracks. |
| + RTC_CHECK(track_allocations.size() == bitrate_observer_configs_.size()); |
| + ObserverAllocation allocation; |
|
nisse-webrtc
2017/09/12 10:39:05
Not for this cl to fix, but I dislike both the Obs
alexnarest
2017/09/14 13:08:33
Acknowledged.
|
| + auto track_allocations_it = track_allocations.begin(); |
| + for (const auto& observer_config : bitrate_observer_configs_) { |
| + allocation[observer_config.observer] = *track_allocations_it++; |
| + } |
| + return allocation; |
| + } |
| + |
| if (bitrate == 0) |
| return ZeroRateAllocation(); |