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 |
11 #ifndef WEBRTC_CALL_BITRATE_ALLOCATOR_H_ | 11 #ifndef WEBRTC_CALL_BITRATE_ALLOCATOR_H_ |
12 #define WEBRTC_CALL_BITRATE_ALLOCATOR_H_ | 12 #define WEBRTC_CALL_BITRATE_ALLOCATOR_H_ |
13 | 13 |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 | 15 |
16 #include <map> | 16 #include <map> |
| 17 #include <string> |
17 #include <utility> | 18 #include <utility> |
18 #include <vector> | 19 #include <vector> |
19 #include <string> | |
20 | 20 |
| 21 #include "webrtc/base/bitrateallocationstrategy.h" |
| 22 #include "webrtc/base/refcountedobject.h" |
| 23 #include "webrtc/base/scoped_ref_ptr.h" |
21 #include "webrtc/base/sequenced_task_checker.h" | 24 #include "webrtc/base/sequenced_task_checker.h" |
22 | 25 |
23 namespace webrtc { | 26 namespace webrtc { |
24 | 27 |
25 class Clock; | 28 class Clock; |
26 | 29 |
27 // Used by all send streams with adaptive bitrate, to get the currently | 30 // Used by all send streams with adaptive bitrate, to get the currently |
28 // allocated bitrate for the send stream. The current network properties are | 31 // allocated bitrate for the send stream. The current network properties are |
29 // given at the same time, to let the send stream decide about possible loss | 32 // given at the same time, to let the send stream decide about possible loss |
30 // protection. | 33 // protection. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 std::string track_id); | 90 std::string track_id); |
88 | 91 |
89 // Removes a previously added observer, but will not trigger a new bitrate | 92 // Removes a previously added observer, but will not trigger a new bitrate |
90 // allocation. | 93 // allocation. |
91 void RemoveObserver(BitrateAllocatorObserver* observer); | 94 void RemoveObserver(BitrateAllocatorObserver* observer); |
92 | 95 |
93 // Returns initial bitrate allocated for |observer|. If |observer| is not in | 96 // Returns initial bitrate allocated for |observer|. If |observer| is not in |
94 // the list of added observers, a best guess is returned. | 97 // the list of added observers, a best guess is returned. |
95 int GetStartBitrate(BitrateAllocatorObserver* observer); | 98 int GetStartBitrate(BitrateAllocatorObserver* observer); |
96 | 99 |
| 100 // Sets external allocation strategy. If strategy is not set default WEBRTC |
| 101 // allocation mechanism will be used. The strategy may be changed during call. |
| 102 // Setting NULL value will restore default WEBRTC allocation strategy. |
| 103 void SetBitrateAllocationStrategy( |
| 104 rtc::BitrateAllocationStrategy* bitrate_allocation_strategy); |
| 105 |
97 private: | 106 private: |
98 // Note: All bitrates for member variables and methods are in bps. | 107 // Note: All bitrates for member variables and methods are in bps. |
99 struct ObserverConfig { | 108 struct ObserverConfig { |
100 ObserverConfig(BitrateAllocatorObserver* observer, | 109 ObserverConfig(BitrateAllocatorObserver* observer, |
101 uint32_t min_bitrate_bps, | 110 uint32_t min_bitrate_bps, |
102 uint32_t max_bitrate_bps, | 111 uint32_t max_bitrate_bps, |
103 uint32_t pad_up_bitrate_bps, | 112 uint32_t pad_up_bitrate_bps, |
104 bool enforce_min_bitrate, | 113 bool enforce_min_bitrate, |
105 std::string track_id) | 114 std::string track_id) |
106 : observer(observer), | 115 : observer(observer), |
(...skipping 15 matching lines...) Expand all Loading... |
122 std::string track_id; | 131 std::string track_id; |
123 }; | 132 }; |
124 | 133 |
125 // Calculates the minimum requested send bitrate and max padding bitrate and | 134 // Calculates the minimum requested send bitrate and max padding bitrate and |
126 // calls LimitObserver::OnAllocationLimitsChanged. | 135 // calls LimitObserver::OnAllocationLimitsChanged. |
127 void UpdateAllocationLimits(); | 136 void UpdateAllocationLimits(); |
128 | 137 |
129 typedef std::vector<ObserverConfig> ObserverConfigs; | 138 typedef std::vector<ObserverConfig> ObserverConfigs; |
130 ObserverConfigs::iterator FindObserverConfig( | 139 ObserverConfigs::iterator FindObserverConfig( |
131 const BitrateAllocatorObserver* observer); | 140 const BitrateAllocatorObserver* observer); |
| 141 ObserverConfigs::iterator FindObserverConfig(const std::string track_id); |
132 | 142 |
133 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; | 143 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; |
134 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; | 144 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; |
135 | 145 |
136 ObserverAllocation AllocateBitrates(uint32_t bitrate); | 146 ObserverAllocation AllocateBitrates(uint32_t bitrate); |
137 | 147 |
138 ObserverAllocation ZeroRateAllocation(); | 148 ObserverAllocation ZeroRateAllocation(); |
139 ObserverAllocation LowRateAllocation(uint32_t bitrate); | 149 ObserverAllocation LowRateAllocation(uint32_t bitrate); |
140 ObserverAllocation NormalRateAllocation(uint32_t bitrate, | 150 ObserverAllocation NormalRateAllocation(uint32_t bitrate, |
141 uint32_t sum_min_bitrates); | 151 uint32_t sum_min_bitrates); |
(...skipping 23 matching lines...) Expand all Loading... |
165 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_); | 175 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_); |
166 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_); | 176 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_); |
167 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_); | 177 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_); |
168 int64_t last_bwe_period_ms_ GUARDED_BY(&sequenced_checker_); | 178 int64_t last_bwe_period_ms_ GUARDED_BY(&sequenced_checker_); |
169 // Number of mute events based on too low BWE, not network up/down. | 179 // Number of mute events based on too low BWE, not network up/down. |
170 int num_pause_events_ GUARDED_BY(&sequenced_checker_); | 180 int num_pause_events_ GUARDED_BY(&sequenced_checker_); |
171 Clock* const clock_ GUARDED_BY(&sequenced_checker_); | 181 Clock* const clock_ GUARDED_BY(&sequenced_checker_); |
172 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_); | 182 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_); |
173 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_); | 183 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_); |
174 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_); | 184 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_); |
| 185 rtc::scoped_refptr<rtc::BitrateAllocationStrategy> |
| 186 bitrate_allocation_strategy_ GUARDED_BY(&sequenced_checker_); |
175 }; | 187 }; |
176 } // namespace webrtc | 188 } // namespace webrtc |
177 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ | 189 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ |
OLD | NEW |