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

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

Issue 2917873002: Refactored incoming bitrate estimator. (Closed)
Patch Set: Created 3 years, 6 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) 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
11 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 11 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/ptr_util.h"
19 #include "webrtc/base/rate_limiter.h" 20 #include "webrtc/base/rate_limiter.h"
20 #include "webrtc/base/socket.h" 21 #include "webrtc/base/socket.h"
21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
23 #include "webrtc/modules/congestion_controller/incoming_bitrate_estimator.h"
22 #include "webrtc/modules/congestion_controller/probe_controller.h" 24 #include "webrtc/modules/congestion_controller/probe_controller.h"
23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 25 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
24 26
25 namespace webrtc { 27 namespace webrtc {
26 namespace { 28 namespace {
27 29
28 static const int64_t kRetransmitWindowSizeMs = 500; 30 static const int64_t kRetransmitWindowSizeMs = 500;
29 31
30 // Makes sure that the bitrate and the min, max values are in valid range. 32 // Makes sure that the bitrate and the min, max values are in valid range.
31 static void ClampBitrates(int* bitrate_bps, 33 static void ClampBitrates(int* bitrate_bps,
(...skipping 28 matching lines...) Expand all
60 const Clock* clock, 62 const Clock* clock,
61 Observer* observer, 63 Observer* observer,
62 RtcEventLog* event_log, 64 RtcEventLog* event_log,
63 std::unique_ptr<PacedSender> pacer) 65 std::unique_ptr<PacedSender> pacer)
64 : clock_(clock), 66 : clock_(clock),
65 observer_(observer), 67 observer_(observer),
66 event_log_(event_log), 68 event_log_(event_log),
67 pacer_(std::move(pacer)), 69 pacer_(std::move(pacer)),
68 bitrate_controller_( 70 bitrate_controller_(
69 BitrateController::CreateBitrateController(clock_, event_log)), 71 BitrateController::CreateBitrateController(clock_, event_log)),
72 incoming_bitrate_estimator_(rtc::MakeUnique<IncomingBitrateEstimator>()),
70 probe_controller_(new ProbeController(pacer_.get(), clock_)), 73 probe_controller_(new ProbeController(pacer_.get(), clock_)),
71 retransmission_rate_limiter_( 74 retransmission_rate_limiter_(
72 new RateLimiter(clock, kRetransmitWindowSizeMs)), 75 new RateLimiter(clock, kRetransmitWindowSizeMs)),
73 transport_feedback_adapter_(clock_), 76 transport_feedback_adapter_(clock_),
74 last_reported_bitrate_bps_(0), 77 last_reported_bitrate_bps_(0),
75 last_reported_fraction_loss_(0), 78 last_reported_fraction_loss_(0),
76 last_reported_rtt_(0), 79 last_reported_rtt_(0),
77 network_state_(kNetworkUp), 80 network_state_(kNetworkUp),
78 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), 81 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
79 delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) { 82 delay_based_bwe_(new DelayBasedBwe(event_log_,
83 incoming_bitrate_estimator_.get(),
84 clock_)) {
80 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); 85 delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
81 worker_thread_checker_.DetachFromThread(); 86 worker_thread_checker_.DetachFromThread();
82 } 87 }
83 88
84 SendSideCongestionController::~SendSideCongestionController() {} 89 SendSideCongestionController::~SendSideCongestionController() {}
85 90
86 void SendSideCongestionController::RegisterPacketFeedbackObserver( 91 void SendSideCongestionController::RegisterPacketFeedbackObserver(
87 PacketFeedbackObserver* observer) { 92 PacketFeedbackObserver* observer) {
88 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); 93 transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer);
89 } 94 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // TODO(honghaiz): Recreate this object once the bitrate controller is 142 // TODO(honghaiz): Recreate this object once the bitrate controller is
138 // no longer exposed outside SendSideCongestionController. 143 // no longer exposed outside SendSideCongestionController.
139 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, 144 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps,
140 max_bitrate_bps); 145 max_bitrate_bps);
141 146
142 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id, 147 transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id,
143 network_route.remote_network_id); 148 network_route.remote_network_id);
144 { 149 {
145 rtc::CritScope cs(&bwe_lock_); 150 rtc::CritScope cs(&bwe_lock_);
146 min_bitrate_bps_ = min_bitrate_bps; 151 min_bitrate_bps_ = min_bitrate_bps;
147 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_)); 152 delay_based_bwe_.reset(new DelayBasedBwe(
153 event_log_, incoming_bitrate_estimator_.get(), clock_));
terelius 2017/06/01 15:15:04 Could we pass the actual bitrate estimate to the d
tschumi 2017/06/02 11:48:44 Changed according offline discussions.
148 delay_based_bwe_->SetStartBitrate(bitrate_bps); 154 delay_based_bwe_->SetStartBitrate(bitrate_bps);
149 delay_based_bwe_->SetMinBitrate(min_bitrate_bps); 155 delay_based_bwe_->SetMinBitrate(min_bitrate_bps);
150 } 156 }
151 157
152 probe_controller_->Reset(); 158 probe_controller_->Reset();
153 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps); 159 probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps);
154 160
155 MaybeTriggerOnNetworkChanged(); 161 MaybeTriggerOnNetworkChanged();
156 } 162 }
157 163
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 bool SendSideCongestionController::IsSendQueueFull() const { 326 bool SendSideCongestionController::IsSendQueueFull() const {
321 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 327 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
322 } 328 }
323 329
324 bool SendSideCongestionController::IsNetworkDown() const { 330 bool SendSideCongestionController::IsNetworkDown() const {
325 rtc::CritScope cs(&network_state_lock_); 331 rtc::CritScope cs(&network_state_lock_);
326 return network_state_ == kNetworkDown; 332 return network_state_ == kNetworkDown;
327 } 333 }
328 334
329 } // namespace webrtc 335 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698