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

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

Issue 2795643002: Add methods to register congestion controller observer after construction. (Closed)
Patch Set: Added TODO comment. 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
« no previous file with comments | « webrtc/modules/congestion_controller/include/send_side_congestion_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/congestion_controller/send_side_congestion_controller.cc
diff --git a/webrtc/modules/congestion_controller/send_side_congestion_controller.cc b/webrtc/modules/congestion_controller/send_side_congestion_controller.cc
index e0918d7b765b1c128ceea0faf5928df68ecea1cb..e3f84d0e539b5b74ef397fd1255594ee7cc0f0b4 100644
--- a/webrtc/modules/congestion_controller/send_side_congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/send_side_congestion_controller.cc
@@ -93,6 +93,19 @@ void SendSideCongestionController::DeRegisterPacketFeedbackObserver(
transport_feedback_adapter_.DeRegisterPacketFeedbackObserver(observer);
}
+void SendSideCongestionController::RegisterNetworkObserver(Observer* observer) {
+ rtc::CritScope cs(&observer_lock_);
+ RTC_DCHECK(observer_ == nullptr);
+ observer_ = observer;
+}
+
+void SendSideCongestionController::DeRegisterNetworkObserver(
+ Observer* observer) {
+ rtc::CritScope cs(&observer_lock_);
+ RTC_DCHECK_EQ(observer_, observer);
+ observer_ = nullptr;
+}
+
void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps,
int start_bitrate_bps,
int max_bitrate_bps) {
@@ -245,11 +258,6 @@ SendSideCongestionController::GetTransportFeedbackVector() const {
}
void SendSideCongestionController::MaybeTriggerOnNetworkChanged() {
- // TODO(perkj): |observer_| can be nullptr if the ctor that accepts a
- // BitrateObserver is used. Remove this check once the ctor is removed.
- if (!observer_)
- return;
-
uint32_t bitrate_bps;
uint8_t fraction_loss;
int64_t rtt;
@@ -269,8 +277,13 @@ void SendSideCongestionController::MaybeTriggerOnNetworkChanged() {
rtc::CritScope cs(&bwe_lock_);
probing_interval_ms = delay_based_bwe_->GetProbingIntervalMs();
}
- observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt,
- probing_interval_ms);
+ {
+ rtc::CritScope cs(&observer_lock_);
+ if (observer_) {
+ observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt,
+ probing_interval_ms);
+ }
+ }
}
}
« no previous file with comments | « webrtc/modules/congestion_controller/include/send_side_congestion_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698