Index: webrtc/call/bitrate_allocator.cc |
diff --git a/webrtc/call/bitrate_allocator.cc b/webrtc/call/bitrate_allocator.cc |
index 2eb40b0670813c008b1b594541fc1e12147e47e9..3a1eb58c2612c9852b342a145c92f593afa84093 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,25 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates( |
if (bitrate_observer_configs_.empty()) |
return ObserverAllocation(); |
+ if (bitrate_allocation_strategy_ != nullptr) { |
+ std::vector<const rtc::BitrateAllocationStrategy::TrackConfig*> |
+ track_configs(bitrate_observer_configs_.size()); |
+ for (auto it = bitrate_observer_configs_.begin(); |
+ it != bitrate_observer_configs_.end(); ++it) { |
+ track_configs[it - bitrate_observer_configs_.begin()] = &*it; |
+ } |
Taylor Brandstetter
2017/09/15 01:24:41
nit: I think a foreach style loop would still be m
alexnarest
2017/09/15 08:29:39
Done.
|
+ 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; |
+ 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(); |