Dont send probe if NetworkStateEstimate.link_capacity_upper=DataRate::Zero

Bug: webrtc:14392
Change-Id: I7df34239f3f9ef27a26d04a16e6f3edf3e45d4bb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276183
Reviewed-by: Diep Bui <diepbp@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38151}
diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc
index 0dfb8a3..501f14b 100644
--- a/modules/congestion_controller/goog_cc/probe_controller.cc
+++ b/modules/congestion_controller/goog_cc/probe_controller.cc
@@ -376,6 +376,7 @@
     send_probe_on_next_process_interval_ = true;
   }
   if (config_.network_state_estimate_drop_down_rate > 0 && network_estimate_ &&
+      !estimate.link_capacity_upper.IsZero() &&
       (estimated_bitrate_ > estimate.link_capacity_upper ||
        bwe_limited_due_to_packet_loss_) &&
       estimate.link_capacity_upper <=
@@ -470,8 +471,11 @@
     max_probe_bitrate = std::min(estimated_bitrate_, max_bitrate_);
   }
   if (config_.network_state_estimate_probing_interval->IsFinite() &&
-      network_estimate_ &&
-      network_estimate_->link_capacity_upper > DataRate::Zero()) {
+      network_estimate_ && network_estimate_->link_capacity_upper.IsFinite()) {
+    if (network_estimate_->link_capacity_upper.IsZero()) {
+      RTC_LOG(LS_INFO) << "Not sending probe, Network state estimate is zero";
+      return {};
+    }
     max_probe_bitrate =
         std::min(max_probe_bitrate, network_estimate_->link_capacity_upper *
                                         config_.network_state_probe_scale);
diff --git a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc
index 06ec681..2b2d712 100644
--- a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc
+++ b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc
@@ -909,5 +909,32 @@
   EXPECT_FALSE(probes.empty());
 }
 
+TEST(ProbeControllerTest, DontSendProbeIfNetworkStateEstimateIsZero) {
+  ProbeControllerFixture fixture(
+      "WebRTC-Bwe-ProbingConfiguration/"
+      "network_state_interval:5s,network_state_drop_down_rate:0.5,limit_probe_"
+      "target_rate_to_loss_bwe:true/");
+  std::unique_ptr<ProbeController> probe_controller =
+      fixture.CreateController();
+  auto probes = probe_controller->SetBitrates(
+      kMinBitrate, kStartBitrate, kMaxBitrate, fixture.CurrentTime());
+  probes = probe_controller->SetEstimatedBitrate(
+      kStartBitrate, /*bwe_limited_due_to_packet_loss=*/false,
+      fixture.CurrentTime());
+  probe_controller->SetNetworkStateEstimate(
+      {.link_capacity_upper = kStartBitrate});
+  // Need to wait at least one second before process can trigger a new probe.
+  fixture.AdvanceTime(TimeDelta::Millis(1100));
+  probes = probe_controller->Process(fixture.CurrentTime());
+  ASSERT_TRUE(probes.empty());
+
+  probe_controller->SetNetworkStateEstimate(
+      {.link_capacity_upper = DataRate::Zero()});
+  probes = probe_controller->Process(fixture.CurrentTime());
+  EXPECT_TRUE(probes.empty());
+  fixture.AdvanceTime(TimeDelta::Seconds(6));
+  probes = probe_controller->Process(fixture.CurrentTime());
+  EXPECT_TRUE(probes.empty());
+}
 }  // namespace test
 }  // namespace webrtc