Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: webrtc/call/bitrate_allocator.h

Issue 2996643002: BWE allocation strategy
Patch Set: . Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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
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 {
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 : observer(observer),
(...skipping 15 matching lines...) Expand all
122 std::string track_id; 130 std::string track_id;
123 }; 131 };
124 132
125 // Calculates the minimum requested send bitrate and max padding bitrate and 133 // Calculates the minimum requested send bitrate and max padding bitrate and
126 // calls LimitObserver::OnAllocationLimitsChanged. 134 // calls LimitObserver::OnAllocationLimitsChanged.
127 void UpdateAllocationLimits(); 135 void UpdateAllocationLimits();
128 136
129 typedef std::vector<ObserverConfig> ObserverConfigs; 137 typedef std::vector<ObserverConfig> ObserverConfigs;
130 ObserverConfigs::iterator FindObserverConfig( 138 ObserverConfigs::iterator FindObserverConfig(
131 const BitrateAllocatorObserver* observer); 139 const BitrateAllocatorObserver* observer);
140 ObserverConfigs::iterator FindObserverConfig(const std::string track_id);
132 141
133 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; 142 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
134 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; 143 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
135 144
136 ObserverAllocation AllocateBitrates(uint32_t bitrate); 145 ObserverAllocation AllocateBitrates(uint32_t bitrate);
137 146
138 ObserverAllocation ZeroRateAllocation(); 147 ObserverAllocation ZeroRateAllocation();
139 ObserverAllocation LowRateAllocation(uint32_t bitrate); 148 ObserverAllocation LowRateAllocation(uint32_t bitrate);
140 ObserverAllocation NormalRateAllocation(uint32_t bitrate, 149 ObserverAllocation NormalRateAllocation(uint32_t bitrate,
141 uint32_t sum_min_bitrates); 150 uint32_t sum_min_bitrates);
(...skipping 23 matching lines...) Expand all
165 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_); 174 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_);
166 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_); 175 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_);
167 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_); 176 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_);
168 int64_t last_bwe_period_ms_ GUARDED_BY(&sequenced_checker_); 177 int64_t last_bwe_period_ms_ GUARDED_BY(&sequenced_checker_);
169 // Number of mute events based on too low BWE, not network up/down. 178 // Number of mute events based on too low BWE, not network up/down.
170 int num_pause_events_ GUARDED_BY(&sequenced_checker_); 179 int num_pause_events_ GUARDED_BY(&sequenced_checker_);
171 Clock* const clock_ GUARDED_BY(&sequenced_checker_); 180 Clock* const clock_ GUARDED_BY(&sequenced_checker_);
172 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_); 181 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_);
173 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_); 182 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_);
174 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_); 183 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_);
184 rtc::scoped_refptr<rtc::BitrateAllocationStrategy>
185 bitrate_allocation_strategy_ GUARDED_BY(&sequenced_checker_);
175 }; 186 };
176 } // namespace webrtc 187 } // namespace webrtc
177 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ 188 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698