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

Unified Diff: webrtc/modules/congestion_controller/congestion_controller.cc

Issue 2725823002: Move delay_based_bwe_ into CongestionController (Closed)
Patch Set: UT thread-checking. 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/congestion_controller/congestion_controller.cc
diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc
index bc2f29cf0cfee22cd75ac6facf4a9bb74e6a7bd9..6ed64a299d73799ef4781277eacdb0e8770a39d4 100644
--- a/webrtc/modules/congestion_controller/congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc
@@ -160,6 +160,7 @@ CongestionController::CongestionController(
std::unique_ptr<PacedSender> pacer)
: clock_(clock),
observer_(observer),
+ event_log_(event_log),
packet_router_(packet_router),
pacer_(std::move(pacer)),
bitrate_controller_(
@@ -169,15 +170,16 @@ CongestionController::CongestionController(
new RateLimiter(clock, kRetransmitWindowSizeMs)),
remote_bitrate_estimator_(remote_bitrate_observer, clock_),
remote_estimator_proxy_(clock_, packet_router_),
- transport_feedback_adapter_(event_log, clock_, bitrate_controller_.get()),
+ transport_feedback_adapter_(clock_),
min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
max_bitrate_bps_(0),
last_reported_bitrate_bps_(0),
last_reported_fraction_loss_(0),
last_reported_rtt_(0),
- network_state_(kNetworkUp) {
- transport_feedback_adapter_.InitBwe();
- transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_);
+ network_state_(kNetworkUp),
+ delay_based_bwe_(new DelayBasedBwe(event_log_, clock_)) {
+ delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
+ worker_thread_checker_.DetachFromThread();
}
CongestionController::~CongestionController() {}
@@ -210,9 +212,12 @@ void CongestionController::SetBweBitrates(int min_bitrate_bps,
remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps);
min_bitrate_bps_ = min_bitrate_bps;
- if (start_bitrate_bps > 0)
- transport_feedback_adapter_.SetStartBitrate(start_bitrate_bps);
- transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_);
+ {
+ rtc::CritScope cs(&bwe_lock_);
+ if (start_bitrate_bps > 0)
+ delay_based_bwe_->SetStartBitrate(start_bitrate_bps);
+ delay_based_bwe_->SetMinBitrate(min_bitrate_bps_);
+ }
MaybeTriggerOnNetworkChanged();
}
@@ -231,9 +236,12 @@ void CongestionController::ResetBweAndBitrates(int bitrate_bps,
remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps);
transport_feedback_adapter_.ClearSendTimeHistory();
- transport_feedback_adapter_.InitBwe();
- transport_feedback_adapter_.SetStartBitrate(bitrate_bps);
- transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps);
+ {
+ rtc::CritScope cs(&bwe_lock_);
+ delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_));
+ delay_based_bwe_->SetStartBitrate(bitrate_bps);
+ delay_based_bwe_->SetMinBitrate(min_bitrate_bps);
+ }
probe_controller_->Reset();
probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, max_bitrate_bps);
@@ -254,11 +262,6 @@ RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator(
}
}
-TransportFeedbackObserver*
-CongestionController::GetTransportFeedbackObserver() {
- return &transport_feedback_adapter_;
-}
-
RateLimiter* CongestionController::GetRetransmissionRateLimiter() {
return retransmission_rate_limiter_.get();
}
@@ -286,7 +289,7 @@ void CongestionController::SignalNetworkState(NetworkState state) {
pacer_->Pause();
}
{
- rtc::CritScope cs(&critsect_);
+ rtc::CritScope cs(&network_state_lock_);
network_state_ = state;
}
probe_controller_->OnNetworkStateChanged(state);
@@ -310,7 +313,10 @@ void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
remote_bitrate_estimator_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
- transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
+ {
+ rtc::CritScope cs(&bwe_lock_);
+ delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
+ }
}
int64_t CongestionController::TimeUntilNextProcess() {
@@ -325,6 +331,32 @@ void CongestionController::Process() {
MaybeTriggerOnNetworkChanged();
}
+void CongestionController::AddPacket(uint16_t sequence_number,
+ size_t length,
+ const PacedPacketInfo& pacing_info) {
+ transport_feedback_adapter_.AddPacket(sequence_number, length, pacing_info);
+}
+
+void CongestionController::OnTransportFeedback(
+ const rtcp::TransportFeedback& feedback) {
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
+ transport_feedback_adapter_.OnTransportFeedback(feedback);
+ DelayBasedBwe::Result result;
+ {
+ rtc::CritScope cs(&bwe_lock_);
+ result = delay_based_bwe_->IncomingPacketFeedbackVector(
+ transport_feedback_adapter_.GetTransportFeedbackVector());
+ }
+ if (result.updated)
+ bitrate_controller_->OnDelayBasedBweResult(result);
+}
+
+std::vector<PacketFeedback> CongestionController::GetTransportFeedbackVector()
+ const {
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
+ return transport_feedback_adapter_.GetTransportFeedbackVector();
+}
+
void CongestionController::MaybeTriggerOnNetworkChanged() {
// TODO(perkj): |observer_| can be nullptr if the ctor that accepts a
// BitrateObserver is used. Remove this check once the ctor is removed.
@@ -345,9 +377,13 @@ void CongestionController::MaybeTriggerOnNetworkChanged() {
bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps;
if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) {
- observer_->OnNetworkChanged(
- bitrate_bps, fraction_loss, rtt,
- transport_feedback_adapter_.GetProbingIntervalMs());
+ int64_t probing_interval_ms;
+ {
+ rtc::CritScope cs(&bwe_lock_);
+ probing_interval_ms = delay_based_bwe_->GetProbingIntervalMs();
+ }
+ observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt,
+ probing_interval_ms);
remote_estimator_proxy_.OnBitrateChanged(bitrate_bps);
}
}
@@ -356,7 +392,7 @@ bool CongestionController::HasNetworkParametersToReportChanged(
uint32_t bitrate_bps,
uint8_t fraction_loss,
int64_t rtt) {
- rtc::CritScope cs(&critsect_);
+ rtc::CritScope cs(&network_state_lock_);
bool changed =
last_reported_bitrate_bps_ != bitrate_bps ||
(bitrate_bps > 0 && (last_reported_fraction_loss_ != fraction_loss ||
@@ -376,7 +412,7 @@ bool CongestionController::IsSendQueueFull() const {
}
bool CongestionController::IsNetworkDown() const {
- rtc::CritScope cs(&critsect_);
+ rtc::CritScope cs(&network_state_lock_);
return network_state_ == kNetworkDown;
}
« no previous file with comments | « webrtc/modules/congestion_controller/BUILD.gn ('k') | webrtc/modules/congestion_controller/congestion_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698