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

Side by Side Diff: webrtc/modules/congestion_controller/congestion_controller.cc

Issue 2752353003: Potential race-condition resolution in CongestionController::min_bitrate_bps_ (Closed)
Patch Set: Created 3 years, 9 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/modules/congestion_controller/include/congestion_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 packet_router_(packet_router), 164 packet_router_(packet_router),
165 pacer_(std::move(pacer)), 165 pacer_(std::move(pacer)),
166 bitrate_controller_( 166 bitrate_controller_(
167 BitrateController::CreateBitrateController(clock_, event_log)), 167 BitrateController::CreateBitrateController(clock_, event_log)),
168 probe_controller_(new ProbeController(pacer_.get(), clock_)), 168 probe_controller_(new ProbeController(pacer_.get(), clock_)),
169 retransmission_rate_limiter_( 169 retransmission_rate_limiter_(
170 new RateLimiter(clock, kRetransmitWindowSizeMs)), 170 new RateLimiter(clock, kRetransmitWindowSizeMs)),
171 remote_bitrate_estimator_(remote_bitrate_observer, clock_), 171 remote_bitrate_estimator_(remote_bitrate_observer, clock_),
172 remote_estimator_proxy_(clock_, packet_router_), 172 remote_estimator_proxy_(clock_, packet_router_),
173 transport_feedback_adapter_(clock_), 173 transport_feedback_adapter_(clock_),
174 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
175 max_bitrate_bps_(0),
176 last_reported_bitrate_bps_(0), 174 last_reported_bitrate_bps_(0),
177 last_reported_fraction_loss_(0), 175 last_reported_fraction_loss_(0),
178 last_reported_rtt_(0), 176 last_reported_rtt_(0),
179 network_state_(kNetworkUp), 177 network_state_(kNetworkUp),
178 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
180 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { 179 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) {
181 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); 180 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
182 worker_thread_checker_.DetachFromThread(); 181 worker_thread_checker_.DetachFromThread();
183 } 182 }
184 183
185 CongestionController::~CongestionController() {} 184 CongestionController::~CongestionController() {}
186 185
187 void CongestionController::OnReceivedPacket(int64_t arrival_time_ms, 186 void CongestionController::OnReceivedPacket(int64_t arrival_time_ms,
188 size_t payload_size, 187 size_t payload_size,
189 const RTPHeader& header) { 188 const RTPHeader& header) {
(...skipping 11 matching lines...) Expand all
201 void CongestionController::SetBweBitrates(int min_bitrate_bps, 200 void CongestionController::SetBweBitrates(int min_bitrate_bps,
202 int start_bitrate_bps, 201 int start_bitrate_bps,
203 int max_bitrate_bps) { 202 int max_bitrate_bps) {
204 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); 203 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
205 bitrate_controller_->SetBitrates(start_bitrate_bps, 204 bitrate_controller_->SetBitrates(start_bitrate_bps,
206 min_bitrate_bps, 205 min_bitrate_bps,
207 max_bitrate_bps); 206 max_bitrate_bps);
208 207
209 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, 208 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps,
210 max_bitrate_bps); 209 max_bitrate_bps);
211 max_bitrate_bps_ = max_bitrate_bps;
212 210
213 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps); 211 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps);
214 min_bitrate_bps_ = min_bitrate_bps;
215 { 212 {
216 rtc::CritScope cs(&bwe_lock_); 213 rtc::CritScope cs(&bwe_lock_);
217 if (start_bitrate_bps > 0) 214 if (start_bitrate_bps > 0)
218 delay_based_bwe_->SetStartBitrate(start_bitrate_bps); 215 delay_based_bwe_->SetStartBitrate(start_bitrate_bps);
216 min_bitrate_bps_ = min_bitrate_bps;
219 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); 217 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
220 } 218 }
221 MaybeTriggerOnNetworkChanged(); 219 MaybeTriggerOnNetworkChanged();
222 } 220 }
223 221
224 // TODO(holmer): Split this up and use SetBweBitrates in combination with 222 // TODO(holmer): Split this up and use SetBweBitrates in combination with
225 // OnNetworkRouteChanged. 223 // OnNetworkRouteChanged.
226 void CongestionController::OnNetworkRouteChanged( 224 void CongestionController::OnNetworkRouteChanged(
227 const rtc::NetworkRoute& network_route, 225 const rtc::NetworkRoute& network_route,
228 int bitrate_bps, 226 int bitrate_bps,
229 int min_bitrate_bps, 227 int min_bitrate_bps,
230 int max_bitrate_bps) { 228 int max_bitrate_bps) {
231 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); 229 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
232 // TODO(honghaiz): Recreate this object once the bitrate controller is 230 // TODO(honghaiz): Recreate this object once the bitrate controller is
233 // no longer exposed outside CongestionController. 231 // no longer exposed outside CongestionController.
234 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, 232 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps,
235 max_bitrate_bps); 233 max_bitrate_bps);
236 min_bitrate_bps_ = min_bitrate_bps;
237 max_bitrate_bps_ = max_bitrate_bps;
238 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is 234 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is
239 // no longer exposed outside CongestionController. 235 // no longer exposed outside CongestionController.
240 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps); 236 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps);
241 237
242 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id, 238 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id,
243 network_route.remote_network_id); 239 network_route.remote_network_id);
244 { 240 {
245 rtc::CritScope cs(&bwe_lock_); 241 rtc::CritScope cs(&bwe_lock_);
242 min_bitrate_bps_ = min_bitrate_bps;
246 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_)); 243 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_));
247 delay_based_bwe_->SetStartBitrate(bitrate_bps); 244 delay_based_bwe_->SetStartBitrate(bitrate_bps);
248 delay_based_bwe_->SetMinBitrate(min_bitrate_bps); 245 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
249 } 246 }
250 247
251 probe_controller_->Reset(); 248 probe_controller_->Reset();
252 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps); 249 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps);
253 250
254 MaybeTriggerOnNetworkChanged(); 251 MaybeTriggerOnNetworkChanged();
255 } 252 }
256 253
257 BitrateController* CongestionController::GetBitrateController() const { 254 BitrateController* CongestionController::GetBitrateController() const {
258 return bitrate_controller_.get(); 255 return bitrate_controller_.get();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 bool CongestionController::IsSendQueueFull() const { 412 bool CongestionController::IsSendQueueFull() const {
416 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 413 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
417 } 414 }
418 415
419 bool CongestionController::IsNetworkDown() const { 416 bool CongestionController::IsNetworkDown() const {
420 rtc::CritScope cs(&network_state_lock_); 417 rtc::CritScope cs(&network_state_lock_);
421 return network_state_ == kNetworkDown; 418 return network_state_ == kNetworkDown;
422 } 419 }
423 420
424 } // namespace webrtc 421 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/include/congestion_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698