| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 int64_t rtt); | 49 int64_t rtt); |
| 50 | 50 |
| 51 // Set the start and max send bitrate used by the bandwidth management. | 51 // Set the start and max send bitrate used by the bandwidth management. |
| 52 // | 52 // |
| 53 // |observer| updates bitrates if already in use. | 53 // |observer| updates bitrates if already in use. |
| 54 // |min_bitrate_bps| = 0 equals no min bitrate. | 54 // |min_bitrate_bps| = 0 equals no min bitrate. |
| 55 // |max_bitrate_bps| = 0 equals no max bitrate. | 55 // |max_bitrate_bps| = 0 equals no max bitrate. |
| 56 // |enforce_min_bitrate| = 'true' will allocate at least |min_bitrate_bps| for | 56 // |enforce_min_bitrate| = 'true' will allocate at least |min_bitrate_bps| for |
| 57 // this observer, even if the BWE is too low, 'false' will allocate 0 to | 57 // this observer, even if the BWE is too low, 'false' will allocate 0 to |
| 58 // the observer if BWE doesn't allow |min_bitrate_bps|. | 58 // the observer if BWE doesn't allow |min_bitrate_bps|. |
| 59 // Returns bitrate allocated for |observer|. | 59 // Returns initial bitrate allocated for |observer|. |
| 60 // Note that |observer|->OnBitrateUpdated() will be called within the scope of |
| 61 // this method with the current rtt, fraction_loss and available bitrate and |
| 62 // that the bitrate in OnBitrateUpdated will be zero if the |observer| is |
| 63 // currently not allowed to send data. |
| 60 int AddObserver(BitrateAllocatorObserver* observer, | 64 int AddObserver(BitrateAllocatorObserver* observer, |
| 61 uint32_t min_bitrate_bps, | 65 uint32_t min_bitrate_bps, |
| 62 uint32_t max_bitrate_bps, | 66 uint32_t max_bitrate_bps, |
| 63 bool enforce_min_bitrate); | 67 bool enforce_min_bitrate); |
| 64 | 68 |
| 65 void RemoveObserver(BitrateAllocatorObserver* observer); | 69 void RemoveObserver(BitrateAllocatorObserver* observer); |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 struct ObserverConfig { | 72 struct ObserverConfig { |
| 69 ObserverConfig(BitrateAllocatorObserver* observer, | 73 ObserverConfig(BitrateAllocatorObserver* observer, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 93 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 90 | 94 |
| 91 typedef std::list<ObserverConfig> ObserverConfigList; | 95 typedef std::list<ObserverConfig> ObserverConfigList; |
| 92 ObserverConfigList::iterator FindObserverConfig( | 96 ObserverConfigList::iterator FindObserverConfig( |
| 93 const BitrateAllocatorObserver* observer) | 97 const BitrateAllocatorObserver* observer) |
| 94 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 98 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 95 | 99 |
| 96 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; | 100 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; |
| 97 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; | 101 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; |
| 98 | 102 |
| 99 ObserverAllocation AllocateBitrates() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 103 ObserverAllocation AllocateBitrates(uint32_t bitrate) |
| 104 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 100 ObserverAllocation NormalRateAllocation(uint32_t bitrate, | 105 ObserverAllocation NormalRateAllocation(uint32_t bitrate, |
| 101 uint32_t sum_min_bitrates) | 106 uint32_t sum_min_bitrates) |
| 102 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 107 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 103 | 108 |
| 104 ObserverAllocation ZeroRateAllocation() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 109 ObserverAllocation ZeroRateAllocation() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 105 ObserverAllocation LowRateAllocation(uint32_t bitrate) | 110 ObserverAllocation LowRateAllocation(uint32_t bitrate) |
| 106 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 111 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 107 | 112 |
| 108 rtc::CriticalSection crit_sect_; | 113 rtc::CriticalSection crit_sect_; |
| 109 // Stored in a list to keep track of the insertion order. | 114 // Stored in a list to keep track of the insertion order. |
| 110 ObserverConfigList bitrate_observer_configs_; | 115 ObserverConfigList bitrate_observer_configs_; |
| 111 bool enforce_min_bitrate_ GUARDED_BY(crit_sect_); | 116 bool enforce_min_bitrate_ GUARDED_BY(crit_sect_); |
| 112 uint32_t last_bitrate_bps_ GUARDED_BY(crit_sect_); | 117 uint32_t last_bitrate_bps_ GUARDED_BY(crit_sect_); |
| 118 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(crit_sect_); |
| 113 uint8_t last_fraction_loss_ GUARDED_BY(crit_sect_); | 119 uint8_t last_fraction_loss_ GUARDED_BY(crit_sect_); |
| 114 int64_t last_rtt_ GUARDED_BY(crit_sect_); | 120 int64_t last_rtt_ GUARDED_BY(crit_sect_); |
| 115 }; | 121 }; |
| 116 } // namespace webrtc | 122 } // namespace webrtc |
| 117 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ | 123 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ |
| OLD | NEW |