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

Unified 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: Rebased and fixed CongestionController unittests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/congestion_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 157258291ae92df4ea30a85a8206729886123dd7..ab3a90c2ecc6ee42efedf7086e971f8fbd5edef5 100644
--- a/webrtc/modules/congestion_controller/congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc
@@ -151,7 +151,10 @@ CongestionController::CongestionController(
remote_estimator_proxy_(clock_, packet_router_.get()),
transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- send_queue_is_full_(false) {
+ last_reported_bitrate_bps_(0),
+ last_reported_fraction_loss_(0),
+ last_reported_rtt_(0),
+ network_state_(kNetworkUp) {
Init();
}
@@ -170,7 +173,10 @@ CongestionController::CongestionController(
remote_estimator_proxy_(clock_, packet_router_.get()),
transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- send_queue_is_full_(false) {
+ last_reported_bitrate_bps_(0),
+ last_reported_fraction_loss_(0),
+ last_reported_rtt_(0),
+ network_state_(kNetworkUp) {
Init();
}
@@ -192,7 +198,10 @@ CongestionController::CongestionController(
remote_estimator_proxy_(clock_, packet_router_.get()),
transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- send_queue_is_full_(false) {
+ last_reported_bitrate_bps_(0),
+ last_reported_fraction_loss_(0),
+ last_reported_rtt_(0),
+ network_state_(kNetworkUp) {
Init();
}
@@ -265,6 +274,11 @@ void CongestionController::SignalNetworkState(NetworkState state) {
} else {
pacer_->Pause();
}
+ {
+ rtc::CritScope cs(&critsect_);
+ network_state_ = state;
+ }
+ MaybeTriggerOnNetworkChanged();
}
void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
@@ -297,24 +311,40 @@ void CongestionController::MaybeTriggerOnNetworkChanged() {
uint32_t bitrate_bps;
uint8_t fraction_loss;
int64_t rtt;
- bool network_changed = bitrate_controller_->GetNetworkParameters(
+ bool estimate_changed = bitrate_controller_->GetNetworkParameters(
&bitrate_bps, &fraction_loss, &rtt);
- if (network_changed)
+ if (estimate_changed)
pacer_->SetEstimatedBitrate(bitrate_bps);
- bool send_queue_is_full =
- pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
- bitrate_bps = send_queue_is_full ? 0 : bitrate_bps;
- if ((network_changed && !send_queue_is_full) ||
- UpdateSendQueueStatus(send_queue_is_full)) {
+
+ bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps;
+
+ if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) {
observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt);
}
}
-bool CongestionController::UpdateSendQueueStatus(bool send_queue_is_full) {
+bool CongestionController::HasNetworkParametersToReportChanged(
+ uint32_t bitrate_bps,
+ uint8_t fraction_loss,
+ int64_t rtt) {
+ rtc::CritScope cs(&critsect_);
+ bool changed =
+ last_reported_bitrate_bps_ != bitrate_bps ||
+ (bitrate_bps > 0 && (last_reported_fraction_loss_ != fraction_loss ||
+ last_reported_rtt_ != rtt));
+ last_reported_bitrate_bps_ = bitrate_bps;
+ last_reported_fraction_loss_ = fraction_loss;
+ last_reported_rtt_ = rtt;
+ return changed;
+}
+
+bool CongestionController::IsSendQueueFull() const {
+ return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
+}
+
+bool CongestionController::IsNetworkDown() const {
rtc::CritScope cs(&critsect_);
- bool result = send_queue_is_full_ != send_queue_is_full;
- send_queue_is_full_ = send_queue_is_full;
- return result;
+ return network_state_ == kNetworkDown;
}
} // namespace webrtc
« 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