Chromium Code Reviews| Index: webrtc/call/bitrate_allocator.h |
| diff --git a/webrtc/call/bitrate_allocator.h b/webrtc/call/bitrate_allocator.h |
| index bf26a6ae9bbc2d035f8dbd51eeab3b300348116c..55f428ee6f348f8f5feeee3b49b849a249ccd986 100644 |
| --- a/webrtc/call/bitrate_allocator.h |
| +++ b/webrtc/call/bitrate_allocator.h |
| @@ -31,6 +31,8 @@ class BitrateAllocatorObserver { |
| virtual void OnBitrateUpdated(uint32_t bitrate_bps, |
| uint8_t fraction_loss, |
| int64_t rtt) = 0; |
| + |
| + protected: |
| virtual ~BitrateAllocatorObserver() {} |
| }; |
| @@ -39,14 +41,24 @@ class BitrateAllocatorObserver { |
| // and push the result to the encoders via BitrateAllocatorObserver(s). |
| class BitrateAllocator { |
| public: |
| - BitrateAllocator(); |
| + // Used to get notified when send stream limits such as the minimum send |
| + // bitrate and max padding bitrate is changed. |
| + class LimitObserver { |
| + public: |
| + virtual void OnAllocationLimitsChanged( |
| + uint32_t min_send_bitrate_bps, |
| + uint32_t max_padding_bitrate_bps) = 0; |
| + |
| + protected: |
| + virtual ~LimitObserver() {} |
| + }; |
| + |
| + explicit BitrateAllocator(LimitObserver* limit_observer); |
| // Allocate target_bitrate across the registered BitrateAllocatorObservers. |
| - // Returns actual bitrate allocated (might be higher than target_bitrate if |
| - // for instance EnforceMinBitrate() is enabled. |
| - uint32_t OnNetworkChanged(uint32_t target_bitrate, |
| - uint8_t fraction_loss, |
| - int64_t rtt); |
| + void OnNetworkChanged(uint32_t target_bitrate, |
| + uint8_t fraction_loss, |
| + int64_t rtt); |
| // Set the start and max send bitrate used by the bandwidth management. |
| // |
| @@ -64,26 +76,43 @@ class BitrateAllocator { |
| int AddObserver(BitrateAllocatorObserver* observer, |
| uint32_t min_bitrate_bps, |
| uint32_t max_bitrate_bps, |
| + uint32_t pad_up_bitrate_bps, |
| bool enforce_min_bitrate); |
| void RemoveObserver(BitrateAllocatorObserver* observer); |
| + // Called by a BitrateAllocatorObserver when it is inactive, ie not producing |
| + // encoded frames for one reason or the other. |
| + // The observer will still be allocated a target bitrate but padding will |
| + // not be sent. |
|
stefan-webrtc
2016/06/08 09:25:13
I know this is how it's behaving today, but is it
perkj_webrtc
2016/06/08 15:35:27
ok- NotifyObserverInactive has been removed.
|
| + void NotifyObserverInactive(BitrateAllocatorObserver* observer, |
| + bool inactive); |
| + |
| private: |
| struct ObserverConfig { |
| ObserverConfig(BitrateAllocatorObserver* observer, |
| uint32_t min_bitrate_bps, |
| uint32_t max_bitrate_bps, |
| + uint32_t pad_up_bitrate_bps, |
| bool enforce_min_bitrate) |
| : observer(observer), |
| + active(true), |
| min_bitrate_bps(min_bitrate_bps), |
| max_bitrate_bps(max_bitrate_bps), |
| + pad_up_bitrate_bps(pad_up_bitrate_bps), |
| enforce_min_bitrate(enforce_min_bitrate) {} |
| BitrateAllocatorObserver* const observer; |
| + bool active; |
| uint32_t min_bitrate_bps; |
| uint32_t max_bitrate_bps; |
| + uint32_t pad_up_bitrate_bps; |
| bool enforce_min_bitrate; |
| }; |
| + // Calculates the minimum requested send bitrate and max padding bitrate and |
| + // calls LimitObserver::OnAllocationLimitsChanged. |
| + void UpdateAllocationLimits() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| + |
| // This method controls the behavior when the available bitrate is lower than |
| // the minimum bitrate, or the sum of minimum bitrates. |
| // When true, the bitrate will never be set lower than the minimum bitrate(s). |
| @@ -110,6 +139,8 @@ class BitrateAllocator { |
| ObserverAllocation LowRateAllocation(uint32_t bitrate) |
| EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| + LimitObserver* const limit_observer_; |
| + |
| rtc::CriticalSection crit_sect_; |
| // Stored in a list to keep track of the insertion order. |
| ObserverConfigList bitrate_observer_configs_ GUARDED_BY(crit_sect_); |