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

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

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Use SequencedTaskChecker in i420_buffer_pool.cc Created 4 years, 5 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 <utility> 17 #include <utility>
18 #include <vector> 18 #include <vector>
19 19
20 #include "webrtc/base/criticalsection.h" 20 #include "webrtc/base/sequenced_task_checker.h"
21 #include "webrtc/base/thread_annotations.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 class Clock; 24 class Clock;
26 25
27 // Used by all send streams with adaptive bitrate, to get the currently 26 // Used by all send streams with adaptive bitrate, to get the currently
28 // allocated bitrate for the send stream. The current network properties are 27 // 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 28 // given at the same time, to let the send stream decide about possible loss
30 // protection. 29 // protection.
31 class BitrateAllocatorObserver { 30 class BitrateAllocatorObserver {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 int64_t allocated_bitrate_bps; 113 int64_t allocated_bitrate_bps;
115 double media_ratio; // Part of the total bitrate used for media [0.0, 1.0]. 114 double media_ratio; // Part of the total bitrate used for media [0.0, 1.0].
116 }; 115 };
117 116
118 // Calculates the minimum requested send bitrate and max padding bitrate and 117 // Calculates the minimum requested send bitrate and max padding bitrate and
119 // calls LimitObserver::OnAllocationLimitsChanged. 118 // calls LimitObserver::OnAllocationLimitsChanged.
120 void UpdateAllocationLimits(); 119 void UpdateAllocationLimits();
121 120
122 typedef std::vector<ObserverConfig> ObserverConfigs; 121 typedef std::vector<ObserverConfig> ObserverConfigs;
123 ObserverConfigs::iterator FindObserverConfig( 122 ObserverConfigs::iterator FindObserverConfig(
124 const BitrateAllocatorObserver* observer) 123 const BitrateAllocatorObserver* observer);
125 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
126 124
127 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; 125 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
128 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; 126 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
129 127
130 ObserverAllocation AllocateBitrates(uint32_t bitrate) 128 ObserverAllocation AllocateBitrates(uint32_t bitrate);
131 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
132 129
133 ObserverAllocation ZeroRateAllocation() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 130 ObserverAllocation ZeroRateAllocation();
134 ObserverAllocation LowRateAllocation(uint32_t bitrate) 131 ObserverAllocation LowRateAllocation(uint32_t bitrate);
135 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
136 ObserverAllocation NormalRateAllocation(uint32_t bitrate, 132 ObserverAllocation NormalRateAllocation(uint32_t bitrate,
137 uint32_t sum_min_bitrates) 133 uint32_t sum_min_bitrates);
138 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
139 ObserverAllocation MaxRateAllocation(uint32_t bitrate, 134 ObserverAllocation MaxRateAllocation(uint32_t bitrate,
140 uint32_t sum_max_bitrates) 135 uint32_t sum_max_bitrates);
141 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
142 136
143 uint32_t LastAllocatedBitrate(const ObserverConfig& observer_config) 137 uint32_t LastAllocatedBitrate(const ObserverConfig& observer_config);
144 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
145 // The minimum bitrate required by this observer, including enable-hysteresis 138 // The minimum bitrate required by this observer, including enable-hysteresis
146 // if the observer is in a paused state. 139 // if the observer is in a paused state.
147 uint32_t MinBitrateWithHysteresis(const ObserverConfig& observer_config) 140 uint32_t MinBitrateWithHysteresis(const ObserverConfig& observer_config);
148 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
149 // Splits |bitrate| evenly to observers already in |allocation|. 141 // Splits |bitrate| evenly to observers already in |allocation|.
150 // |include_zero_allocations| decides if zero allocations should be part of 142 // |include_zero_allocations| decides if zero allocations should be part of
151 // the distribution or not. The allowed max bitrate is |max_multiplier| x 143 // the distribution or not. The allowed max bitrate is |max_multiplier| x
152 // observer max bitrate. 144 // observer max bitrate.
153 void DistributeBitrateEvenly(uint32_t bitrate, 145 void DistributeBitrateEvenly(uint32_t bitrate,
154 bool include_zero_allocations, 146 bool include_zero_allocations,
155 int max_multiplier, 147 int max_multiplier,
156 ObserverAllocation* allocation) 148 ObserverAllocation* allocation);
157 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 149 bool EnoughBitrateForAllObservers(uint32_t bitrate,
158 bool EnoughBitrateForAllObservers(uint32_t bitrate, uint32_t sum_min_bitrates) 150 uint32_t sum_min_bitrates);
159 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
160 151
161 LimitObserver* const limit_observer_; 152 LimitObserver* const limit_observer_;
162 153 rtc::SequencedTaskChecker sequenced_checker_;
163 rtc::CriticalSection crit_sect_;
164 // Stored in a list to keep track of the insertion order. 154 // Stored in a list to keep track of the insertion order.
165 ObserverConfigs bitrate_observer_configs_ GUARDED_BY(crit_sect_); 155 ObserverConfigs bitrate_observer_configs_;
pbos-webrtc 2016/07/13 12:35:38 Can you have these GUARDED_BY the sequenced_checke
perkj_webrtc 2016/07/14 10:11:27 Done.
166 uint32_t last_bitrate_bps_ GUARDED_BY(crit_sect_); 156 uint32_t last_bitrate_bps_;
167 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(crit_sect_); 157 uint32_t last_non_zero_bitrate_bps_;
168 uint8_t last_fraction_loss_ GUARDED_BY(crit_sect_); 158 uint8_t last_fraction_loss_;
169 int64_t last_rtt_ GUARDED_BY(crit_sect_); 159 int64_t last_rtt_;
170 // Number of mute events based on too low BWE, not network up/down. 160 // Number of mute events based on too low BWE, not network up/down.
171 int num_pause_events_ GUARDED_BY(crit_sect_); 161 int num_pause_events_;
172 Clock* const clock_; 162 Clock* const clock_;
173 int64_t last_bwe_log_time_; 163 int64_t last_bwe_log_time_;
174 }; 164 };
175 } // namespace webrtc 165 } // namespace webrtc
176 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ 166 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/call/BUILD.gn ('k') | webrtc/call/bitrate_allocator.cc » ('j') | webrtc/call/call.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698