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

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

Issue 1932683002: Remove ViEEncoder::SetNetworkStatus (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_pacer
Patch Set: Addressed comments Created 4 years, 7 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/congestion_controller_unittest.cc » ('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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 packet_router_(new PacketRouter()), 144 packet_router_(new PacketRouter()),
145 pacer_(new PacedSender(clock_, 145 pacer_(new PacedSender(clock_,
146 packet_router_.get(), 146 packet_router_.get(),
147 BitrateController::kDefaultStartBitratebps)), 147 BitrateController::kDefaultStartBitratebps)),
148 remote_bitrate_estimator_( 148 remote_bitrate_estimator_(
149 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 149 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
150 bitrate_controller_(BitrateController::CreateBitrateController(clock_)), 150 bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
151 remote_estimator_proxy_(clock_, packet_router_.get()), 151 remote_estimator_proxy_(clock_, packet_router_.get()),
152 transport_feedback_adapter_(bitrate_controller_.get(), clock_), 152 transport_feedback_adapter_(bitrate_controller_.get(), clock_),
153 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 153 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
154 send_queue_is_full_(false) { 154 last_reported_bitrate_bps_(0),
155 network_state_(kNetworkUp) {
155 Init(); 156 Init();
156 } 157 }
157 158
158 CongestionController::CongestionController( 159 CongestionController::CongestionController(
159 Clock* clock, 160 Clock* clock,
160 Observer* observer, 161 Observer* observer,
161 RemoteBitrateObserver* remote_bitrate_observer, 162 RemoteBitrateObserver* remote_bitrate_observer,
162 std::unique_ptr<PacketRouter> packet_router, 163 std::unique_ptr<PacketRouter> packet_router,
163 std::unique_ptr<PacedSender> pacer) 164 std::unique_ptr<PacedSender> pacer)
164 : clock_(clock), 165 : clock_(clock),
165 observer_(observer), 166 observer_(observer),
166 packet_router_(std::move(packet_router)), 167 packet_router_(std::move(packet_router)),
167 pacer_(std::move(pacer)), 168 pacer_(std::move(pacer)),
168 remote_bitrate_estimator_( 169 remote_bitrate_estimator_(
169 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 170 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
170 // Constructed last as this object calls the provided callback on 171 // Constructed last as this object calls the provided callback on
171 // construction. 172 // construction.
172 bitrate_controller_(BitrateController::CreateBitrateController(clock_)), 173 bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
173 remote_estimator_proxy_(clock_, packet_router_.get()), 174 remote_estimator_proxy_(clock_, packet_router_.get()),
174 transport_feedback_adapter_(bitrate_controller_.get(), clock_), 175 transport_feedback_adapter_(bitrate_controller_.get(), clock_),
175 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 176 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
176 send_queue_is_full_(false) { 177 last_reported_bitrate_bps_(0),
178 network_state_(kNetworkUp) {
177 Init(); 179 Init();
178 } 180 }
179 181
180 CongestionController::~CongestionController() {} 182 CongestionController::~CongestionController() {}
181 183
182 void CongestionController::Init() { 184 void CongestionController::Init() {
183 transport_feedback_adapter_.SetBitrateEstimator( 185 transport_feedback_adapter_.SetBitrateEstimator(
184 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); 186 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_));
185 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( 187 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
186 min_bitrate_bps_); 188 min_bitrate_bps_);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 int64_t CongestionController::GetPacerQueuingDelayMs() const { 246 int64_t CongestionController::GetPacerQueuingDelayMs() const {
245 return pacer_->QueueInMs(); 247 return pacer_->QueueInMs();
246 } 248 }
247 249
248 void CongestionController::SignalNetworkState(NetworkState state) { 250 void CongestionController::SignalNetworkState(NetworkState state) {
249 if (state == kNetworkUp) { 251 if (state == kNetworkUp) {
250 pacer_->Resume(); 252 pacer_->Resume();
251 } else { 253 } else {
252 pacer_->Pause(); 254 pacer_->Pause();
253 } 255 }
256 rtc::CritScope cs(&critsect_);
257 network_state_ = state;
254 } 258 }
255 259
256 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { 260 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
257 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, 261 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id,
258 sent_packet.send_time_ms); 262 sent_packet.send_time_ms);
259 } 263 }
260 264
261 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 265 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
262 remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 266 remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
263 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); 267 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
264 } 268 }
265 269
266 int64_t CongestionController::TimeUntilNextProcess() { 270 int64_t CongestionController::TimeUntilNextProcess() {
267 return std::min(bitrate_controller_->TimeUntilNextProcess(), 271 return std::min(bitrate_controller_->TimeUntilNextProcess(),
268 remote_bitrate_estimator_->TimeUntilNextProcess()); 272 remote_bitrate_estimator_->TimeUntilNextProcess());
269 } 273 }
270 274
271 void CongestionController::Process() { 275 void CongestionController::Process() {
272 bitrate_controller_->Process(); 276 bitrate_controller_->Process();
273 remote_bitrate_estimator_->Process(); 277 remote_bitrate_estimator_->Process();
274 MaybeTriggerOnNetworkChanged(); 278 MaybeTriggerOnNetworkChanged();
275 } 279 }
276 280
277 void CongestionController::MaybeTriggerOnNetworkChanged() { 281 void CongestionController::MaybeTriggerOnNetworkChanged() {
278 uint32_t bitrate_bps; 282 uint32_t bitrate_bps;
279 uint8_t fraction_loss; 283 uint8_t fraction_loss;
280 int64_t rtt; 284 int64_t rtt;
281 bool network_changed = bitrate_controller_->GetNetworkParameters( 285 bool estimate_changed = bitrate_controller_->GetNetworkParameters(
282 &bitrate_bps, &fraction_loss, &rtt); 286 &bitrate_bps, &fraction_loss, &rtt);
283 if (network_changed) 287 if (estimate_changed)
284 pacer_->SetEstimatedBitrate(bitrate_bps); 288 pacer_->SetEstimatedBitrate(bitrate_bps);
285 bool send_queue_is_full = 289
286 pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 290 bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps;
287 bitrate_bps = send_queue_is_full ? 0 : bitrate_bps; 291
288 if ((network_changed && !send_queue_is_full) || 292 if (HasBitrateToReportChanged(bitrate_bps)) {
289 UpdateSendQueueStatus(send_queue_is_full)) {
290 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt); 293 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt);
291 } 294 }
292 } 295 }
296 bool CongestionController::HasBitrateToReportChanged(uint32_t bitrate_bps) {
stefan-webrtc 2016/05/04 09:21:20 Empty line above.
perkj_webrtc 2016/05/04 10:00:15 Done.
297 rtc::CritScope cs(&critsect_);
298 bool changed = last_reported_bitrate_bps_ != bitrate_bps;
299 last_reported_bitrate_bps_ = bitrate_bps;
300 return changed;
301 }
293 302
294 bool CongestionController::UpdateSendQueueStatus(bool send_queue_is_full) { 303 bool CongestionController::IsSendQueueFull() const {
304 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
305 }
306
307 bool CongestionController::IsNetworkDown() const {
295 rtc::CritScope cs(&critsect_); 308 rtc::CritScope cs(&critsect_);
296 bool result = send_queue_is_full_ != send_queue_is_full; 309 return network_state_ == kNetworkDown;
297 send_queue_is_full_ = send_queue_is_full;
298 return result;
299 } 310 }
300 311
301 } // namespace webrtc 312 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/congestion_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698