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

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: Rebased. 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
« no previous file with comments | « no previous file | webrtc/call/bitrate_allocator.cc » ('j') | webrtc/call/bitrate_allocator.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <list> 16 #include <list>
17 #include <map> 17 #include <map>
18 #include <utility> 18 #include <utility>
19 19
20 #include "webrtc/base/criticalsection.h" 20 #include "webrtc/base/thread_checker.h"
21 #include "webrtc/base/thread_annotations.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 // Used by all send streams with adaptive bitrate, to get the currently 24 // Used by all send streams with adaptive bitrate, to get the currently
26 // allocated bitrate for the send stream. The current network properties are 25 // allocated bitrate for the send stream. The current network properties are
27 // given at the same time, to let the send stream decide about possible loss 26 // given at the same time, to let the send stream decide about possible loss
28 // protection. 27 // protection.
29 class BitrateAllocatorObserver { 28 class BitrateAllocatorObserver {
30 public: 29 public:
31 virtual void OnBitrateUpdated(uint32_t bitrate_bps, 30 virtual void OnBitrateUpdated(uint32_t bitrate_bps,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 uint32_t pad_up_bitrate_bps; 104 uint32_t pad_up_bitrate_bps;
106 bool enforce_min_bitrate; 105 bool enforce_min_bitrate;
107 }; 106 };
108 107
109 // Calculates the minimum requested send bitrate and max padding bitrate and 108 // Calculates the minimum requested send bitrate and max padding bitrate and
110 // calls LimitObserver::OnAllocationLimitsChanged. 109 // calls LimitObserver::OnAllocationLimitsChanged.
111 void UpdateAllocationLimits(); 110 void UpdateAllocationLimits();
112 111
113 typedef std::list<ObserverConfig> ObserverConfigList; 112 typedef std::list<ObserverConfig> ObserverConfigList;
114 ObserverConfigList::iterator FindObserverConfig( 113 ObserverConfigList::iterator FindObserverConfig(
115 const BitrateAllocatorObserver* observer) 114 const BitrateAllocatorObserver* observer);
116 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
117 115
118 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap; 116 typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
119 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation; 117 typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
120 118
121 ObserverAllocation AllocateBitrates(uint32_t bitrate) 119 ObserverAllocation AllocateBitrates(uint32_t bitrate);
122 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
123 120
124 ObserverAllocation ZeroRateAllocation() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 121 ObserverAllocation ZeroRateAllocation();
125 ObserverAllocation LowRateAllocation(uint32_t bitrate) 122 ObserverAllocation LowRateAllocation(uint32_t bitrate);
126 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
127 ObserverAllocation NormalRateAllocation(uint32_t bitrate, 123 ObserverAllocation NormalRateAllocation(uint32_t bitrate,
128 uint32_t sum_min_bitrates) 124 uint32_t sum_min_bitrates);
129 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
130 ObserverAllocation MaxRateAllocation(uint32_t bitrate, 125 ObserverAllocation MaxRateAllocation(uint32_t bitrate,
131 uint32_t sum_max_bitrates) 126 uint32_t sum_max_bitrates);
132 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
133 127
134 uint32_t LastAllocatedBitrate(const ObserverConfig& observer_config) 128 uint32_t LastAllocatedBitrate(const ObserverConfig& observer_config);
135 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
136 // The minimum bitrate required by this observer, including enable-hysteresis 129 // The minimum bitrate required by this observer, including enable-hysteresis
137 // if the observer is in a paused state. 130 // if the observer is in a paused state.
138 uint32_t MinBitrateWithHysteresis(const ObserverConfig& observer_config) 131 uint32_t MinBitrateWithHysteresis(const ObserverConfig& observer_config);
139 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
140 // Splits |bitrate| evenly to observers already in |allocation|. 132 // Splits |bitrate| evenly to observers already in |allocation|.
141 // |include_zero_allocations| decides if zero allocations should be part of 133 // |include_zero_allocations| decides if zero allocations should be part of
142 // the distribution or not. The allowed max bitrate is |max_multiplier| x 134 // the distribution or not. The allowed max bitrate is |max_multiplier| x
143 // observer max bitrate. 135 // observer max bitrate.
144 void DistributeBitrateEvenly(uint32_t bitrate, 136 void DistributeBitrateEvenly(uint32_t bitrate,
145 bool include_zero_allocations, 137 bool include_zero_allocations,
146 int max_multiplier, 138 int max_multiplier,
147 ObserverAllocation* allocation) 139 ObserverAllocation* allocation);
148 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 140 bool EnoughBitrateForAllObservers(uint32_t bitrate,
149 bool EnoughBitrateForAllObservers(uint32_t bitrate, uint32_t sum_min_bitrates) 141 uint32_t sum_min_bitrates);
150 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
151 142
152 LimitObserver* const limit_observer_; 143 LimitObserver* const limit_observer_;
153 144 rtc::ThreadChecker thread_checker_;
154 rtc::CriticalSection crit_sect_;
155 // Stored in a list to keep track of the insertion order. 145 // Stored in a list to keep track of the insertion order.
156 ObserverConfigList bitrate_observer_configs_ GUARDED_BY(crit_sect_); 146 ObserverConfigList bitrate_observer_configs_;
157 uint32_t last_bitrate_bps_ GUARDED_BY(crit_sect_); 147 uint32_t last_bitrate_bps_;
158 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(crit_sect_); 148 uint32_t last_non_zero_bitrate_bps_;
159 uint8_t last_fraction_loss_ GUARDED_BY(crit_sect_); 149 uint8_t last_fraction_loss_;
160 int64_t last_rtt_ GUARDED_BY(crit_sect_); 150 int64_t last_rtt_;
161 ObserverAllocation last_allocation_ GUARDED_BY(crit_sect_); 151 ObserverAllocation last_allocation_;
162 }; 152 };
163 } // namespace webrtc 153 } // namespace webrtc
164 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ 154 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/call/bitrate_allocator.cc » ('j') | webrtc/call/bitrate_allocator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698