Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1751)

Unified Diff: webrtc/call/bitrate_allocator.cc

Issue 2996643002: BWE allocation strategy
Patch Set: Comments handling Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/call/bitrate_allocator.h ('k') | webrtc/call/call.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/bitrate_allocator.cc
diff --git a/webrtc/call/bitrate_allocator.cc b/webrtc/call/bitrate_allocator.cc
index 2eb40b0670813c008b1b594541fc1e12147e47e9..cebce9e0031bbc9accf4dff22766709c1567b5b2 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());
+ int i = 0;
+ for (const auto& c : bitrate_observer_configs_) {
+ track_configs[i++] = &c;
+ }
+ 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();
« no previous file with comments | « webrtc/call/bitrate_allocator.h ('k') | webrtc/call/call.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698