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