Chromium Code Reviews| Index: webrtc/call/bitrate_allocator.cc |
| diff --git a/webrtc/call/bitrate_allocator.cc b/webrtc/call/bitrate_allocator.cc |
| index 097378f02a17b9728581d955c83dfe5860b31681..0763b0e23497d1652b10fe44cf4f670c99387f88 100644 |
| --- a/webrtc/call/bitrate_allocator.cc |
| +++ b/webrtc/call/bitrate_allocator.cc |
| @@ -31,20 +31,17 @@ BitrateAllocator::BitrateAllocator() |
| last_fraction_loss_(0), |
| last_rtt_(0) {} |
| -uint32_t BitrateAllocator::OnNetworkChanged(uint32_t bitrate, |
| - uint8_t fraction_loss, |
| - int64_t rtt) { |
| +void BitrateAllocator::OnNetworkChanged(uint32_t bitrate, |
|
stefan-webrtc
2016/04/29 10:48:38
Is there a point in changing this method?
perkj_webrtc
2016/05/02 11:29:09
Reverting as discussed.
|
| + uint8_t fraction_loss, |
| + int64_t rtt) { |
| rtc::CritScope lock(&crit_sect_); |
| last_bitrate_bps_ = bitrate; |
| last_fraction_loss_ = fraction_loss; |
| last_rtt_ = rtt; |
| - uint32_t allocated_bitrate_bps = 0; |
| ObserverBitrateMap allocation = AllocateBitrates(); |
| for (const auto& kv : allocation) { |
| kv.first->OnBitrateUpdated(kv.second, last_fraction_loss_, last_rtt_); |
| - allocated_bitrate_bps += kv.second; |
| } |
| - return allocated_bitrate_bps; |
| } |
| BitrateAllocator::ObserverBitrateMap BitrateAllocator::AllocateBitrates() { |
| @@ -54,7 +51,9 @@ BitrateAllocator::ObserverBitrateMap BitrateAllocator::AllocateBitrates() { |
| uint32_t sum_min_bitrates = 0; |
| for (const auto& observer : bitrate_observers_) |
| sum_min_bitrates += observer.second.min_bitrate; |
| - if (last_bitrate_bps_ <= sum_min_bitrates) |
| + if (last_bitrate_bps_ == 0) |
| + return ZeroRateAllocation(); |
| + else if (last_bitrate_bps_ <= sum_min_bitrates) |
| return LowRateAllocation(last_bitrate_bps_); |
| else |
| return NormalRateAllocation(last_bitrate_bps_, sum_min_bitrates); |
| @@ -104,16 +103,17 @@ void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) { |
| } |
| } |
| -void BitrateAllocator::GetMinMaxBitrateSumBps(int* min_bitrate_sum_bps, |
| - int* max_bitrate_sum_bps) const { |
| - *min_bitrate_sum_bps = 0; |
| - *max_bitrate_sum_bps = 0; |
| - |
| +int BitrateAllocator::GetMinSendBitrate() const { |
| rtc::CritScope lock(&crit_sect_); |
| + int min_bitrate = 0; |
| + |
| + if (!enforce_min_bitrate_) |
| + return 0; |
| + |
| for (const auto& observer : bitrate_observers_) { |
| - *min_bitrate_sum_bps += observer.second.min_bitrate; |
| - *max_bitrate_sum_bps += observer.second.max_bitrate; |
| + min_bitrate += observer.second.min_bitrate; |
| } |
| + return min_bitrate; |
| } |
| BitrateAllocator::BitrateObserverConfList::iterator |
| @@ -170,6 +170,14 @@ BitrateAllocator::ObserverBitrateMap BitrateAllocator::NormalRateAllocation( |
| return allocation; |
| } |
| +BitrateAllocator::ObserverBitrateMap BitrateAllocator::ZeroRateAllocation() { |
| + ObserverBitrateMap allocation; |
| + // Zero bitrate to all observers. |
| + for (const auto& observer : bitrate_observers_) |
| + allocation[observer.first] = 0; |
| + return allocation; |
| +} |
| + |
| BitrateAllocator::ObserverBitrateMap BitrateAllocator::LowRateAllocation( |
| uint32_t bitrate) { |
| ObserverBitrateMap allocation; |