commit 67ce175c82e2c18cbaceaf95763be34cbaa85239
parent 82e5ddb84f7a6a8e5043f33512ab6a0e939a1ce2
Author: Michael Froman <mfroman@mozilla.com>
Date: Thu, 9 Oct 2025 13:39:17 -0500
Bug 1993083 - Vendor libwebrtc from 49a2a8ce45
Upstream commit: https://webrtc.googlesource.com/src/+/49a2a8ce455b5881efe106bb500667b9d1340217
Use strong time and bitrate types in AlrDetector
Bug: webrtc:42224672
Change-Id: I40a2b50eda1eb8b47f871ccb33d4852b34b9326d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/400360
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45147}
Diffstat:
9 files changed, 128 insertions(+), 137 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T18:38:04.960332+00:00.
+libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T18:39:10.007533+00:00.
# base of lastest vendoring
-01df61ec4f
+49a2a8ce45
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/BUILD.gn b/third_party/libwebrtc/modules/congestion_controller/goog_cc/BUILD.gn
@@ -79,6 +79,10 @@ rtc_library("alr_detector") {
deps = [
"../../../api:field_trials_view",
"../../../api/rtc_event_log",
+ "../../../api/units:data_rate",
+ "../../../api/units:data_size",
+ "../../../api/units:time_delta",
+ "../../../api/units:timestamp",
"../../../logging:rtc_event_pacing",
"../../../rtc_base:checks",
"../../../rtc_base:safe_conversions",
@@ -312,6 +316,7 @@ if (rtc_include_tests) {
"../../../test/scenario:column_printer",
"../../pacing",
"//testing/gmock",
+ "//third_party/abseil-cpp/absl/base:nullability",
"//third_party/abseil-cpp/absl/strings:string_view",
]
}
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc
@@ -10,13 +10,15 @@
#include "modules/congestion_controller/goog_cc/alr_detector.h"
-#include <cstdint>
-#include <cstdio>
#include <memory>
#include <optional>
#include "api/field_trials_view.h"
#include "api/rtc_event_log/rtc_event_log.h"
+#include "api/units/data_rate.h"
+#include "api/units/data_size.h"
+#include "api/units/time_delta.h"
+#include "api/units/timestamp.h"
#include "logging/rtc_event_log/events/rtc_event_alr_state.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/alr_experiment.h"
@@ -70,44 +72,43 @@ AlrDetector::AlrDetector(const FieldTrialsView* key_value_config,
: AlrDetector(GetConfigFromTrials(key_value_config), event_log) {}
AlrDetector::~AlrDetector() {}
-void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t send_time_ms) {
- if (!last_send_time_ms_.has_value()) {
- last_send_time_ms_ = send_time_ms;
+void AlrDetector::OnBytesSent(DataSize bytes_sent, Timestamp send_time) {
+ if (!last_send_time_.has_value()) {
+ last_send_time_ = send_time;
// Since the duration for sending the bytes is unknwon, return without
// updating alr state.
return;
}
- int64_t delta_time_ms = send_time_ms - *last_send_time_ms_;
- last_send_time_ms_ = send_time_ms;
+ TimeDelta delta_time = send_time - *last_send_time_;
+ last_send_time_ = send_time;
- alr_budget_.UseBudget(bytes_sent);
- alr_budget_.IncreaseBudget(delta_time_ms);
+ alr_budget_.UseBudget(bytes_sent.bytes());
+ alr_budget_.IncreaseBudget(delta_time.ms());
bool state_changed = false;
if (alr_budget_.budget_ratio() > conf_.start_budget_level_ratio &&
- !alr_started_time_ms_) {
- alr_started_time_ms_.emplace(TimeMillis());
+ !alr_started_time_) {
+ alr_started_time_ = Timestamp::Millis(TimeMillis());
state_changed = true;
} else if (alr_budget_.budget_ratio() < conf_.stop_budget_level_ratio &&
- alr_started_time_ms_) {
+ alr_started_time_) {
state_changed = true;
- alr_started_time_ms_.reset();
+ alr_started_time_ = std::nullopt;
}
if (event_log_ && state_changed) {
event_log_->Log(
- std::make_unique<RtcEventAlrState>(alr_started_time_ms_.has_value()));
+ std::make_unique<RtcEventAlrState>(alr_started_time_.has_value()));
}
}
-void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
- RTC_DCHECK(bitrate_bps);
- int target_rate_kbps =
- static_cast<double>(bitrate_bps) * conf_.bandwidth_usage_ratio / 1000;
- alr_budget_.set_target_rate_kbps(target_rate_kbps);
+void AlrDetector::SetEstimatedBitrate(DataRate bitrate) {
+ RTC_DCHECK_GT(bitrate, DataRate::Zero());
+ alr_budget_.set_target_rate_kbps(
+ (bitrate * conf_.bandwidth_usage_ratio).kbps());
}
-std::optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
+std::optional<Timestamp> AlrDetector::GetApplicationLimitedRegionStartTime()
const {
- return alr_started_time_ms_;
+ return alr_started_time_;
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h
@@ -11,13 +11,13 @@
#ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_ALR_DETECTOR_H_
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ALR_DETECTOR_H_
-#include <stddef.h>
-#include <stdint.h>
-
#include <memory>
#include <optional>
#include "api/field_trials_view.h"
+#include "api/units/data_rate.h"
+#include "api/units/data_size.h"
+#include "api/units/timestamp.h"
#include "modules/pacing/interval_budget.h"
#include "rtc_base/experiments/struct_parameters_parser.h"
@@ -50,23 +50,23 @@ class AlrDetector {
AlrDetector(const FieldTrialsView* key_value_config, RtcEventLog* event_log);
~AlrDetector();
- void OnBytesSent(size_t bytes_sent, int64_t send_time_ms);
+ void OnBytesSent(DataSize bytes_sent, Timestamp send_time);
// Set current estimated bandwidth.
- void SetEstimatedBitrate(int bitrate_bps);
+ void SetEstimatedBitrate(DataRate bitrate);
// Returns time in milliseconds when the current application-limited region
// started or empty result if the sender is currently not application-limited.
- std::optional<int64_t> GetApplicationLimitedRegionStartTime() const;
+ std::optional<Timestamp> GetApplicationLimitedRegionStartTime() const;
private:
friend class GoogCcStatePrinter;
const AlrDetectorConfig conf_;
- std::optional<int64_t> last_send_time_ms_;
+ std::optional<Timestamp> last_send_time_;
IntervalBudget alr_budget_;
- std::optional<int64_t> alr_started_time_ms_;
+ std::optional<Timestamp> alr_started_time_;
RtcEventLog* event_log_;
};
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_unittest.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_unittest.cc
@@ -10,33 +10,32 @@
#include "modules/congestion_controller/goog_cc/alr_detector.h"
-#include <cstdint>
#include <optional>
+#include "absl/base/nullability.h"
#include "api/field_trials.h"
+#include "api/units/data_rate.h"
+#include "api/units/time_delta.h"
+#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/alr_experiment.h"
+#include "system_wrappers/include/clock.h"
#include "test/create_test_field_trials.h"
#include "test/gtest.h"
+namespace webrtc {
namespace {
-constexpr int kEstimatedBitrateBps = 300000;
-
-} // namespace
+constexpr DataRate kEstimatedBitrate = DataRate::BitsPerSec(300'000);
-namespace webrtc {
-namespace {
class SimulateOutgoingTrafficIn {
public:
- explicit SimulateOutgoingTrafficIn(AlrDetector* alr_detector,
- int64_t* timestamp_ms)
- : alr_detector_(alr_detector), timestamp_ms_(timestamp_ms) {
- RTC_CHECK(alr_detector_);
- }
+ explicit SimulateOutgoingTrafficIn(AlrDetector* absl_nonnull alr_detector,
+ SimulatedClock* absl_nonnull clock)
+ : alr_detector_(*alr_detector), clock_(*clock) {}
- SimulateOutgoingTrafficIn& ForTimeMs(int time_ms) {
- interval_ms_ = time_ms;
+ SimulateOutgoingTrafficIn& ForTime(TimeDelta time) {
+ interval_ = time;
ProduceTraffic();
return *this;
}
@@ -49,97 +48,92 @@ class SimulateOutgoingTrafficIn {
private:
void ProduceTraffic() {
- if (!interval_ms_ || !usage_percentage_)
+ if (!interval_ || !usage_percentage_)
return;
- const int kTimeStepMs = 10;
- for (int t = 0; t < *interval_ms_; t += kTimeStepMs) {
- *timestamp_ms_ += kTimeStepMs;
- alr_detector_->OnBytesSent(kEstimatedBitrateBps * *usage_percentage_ *
- kTimeStepMs / (8 * 100 * 1000),
- *timestamp_ms_);
- }
- int remainder_ms = *interval_ms_ % kTimeStepMs;
- if (remainder_ms > 0) {
- *timestamp_ms_ += kTimeStepMs;
- alr_detector_->OnBytesSent(kEstimatedBitrateBps * *usage_percentage_ *
- remainder_ms / (8 * 100 * 1000),
- *timestamp_ms_);
+ const TimeDelta kTimeStep = TimeDelta::Millis(10);
+ for (TimeDelta t = TimeDelta::Zero(); t < *interval_; t += kTimeStep) {
+ clock_.AdvanceTime(kTimeStep);
+ alr_detector_.OnBytesSent(
+ kEstimatedBitrate * *usage_percentage_ * kTimeStep / 100,
+ clock_.CurrentTime());
}
+ // As of now all tests use interval that is a multiple of 10ms.
+ RTC_DCHECK_EQ(interval_->ms() % kTimeStep.ms(), 0);
}
- AlrDetector* const alr_detector_;
- int64_t* timestamp_ms_;
- std::optional<int> interval_ms_;
+ AlrDetector& alr_detector_;
+ SimulatedClock& clock_;
+ std::optional<TimeDelta> interval_;
std::optional<int> usage_percentage_;
};
} // namespace
TEST(AlrDetectorTest, AlrDetection) {
FieldTrials field_trials = CreateTestFieldTrials();
- int64_t timestamp_ms = 1000;
+ SimulatedClock clock(Timestamp::Seconds(1));
AlrDetector alr_detector(&field_trials);
- alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps);
+ alr_detector.SetEstimatedBitrate(kEstimatedBitrate);
// Start in non-ALR state.
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// Stay in non-ALR state when usage is close to 100%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(1))
.AtPercentOfEstimatedBitrate(90);
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// Verify that we ALR starts when bitrate drops below 20%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1500)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Millis(1'500))
.AtPercentOfEstimatedBitrate(20);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
// Verify that ALR ends when usage is above 65%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(4000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(4))
.AtPercentOfEstimatedBitrate(100);
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
}
TEST(AlrDetectorTest, ShortSpike) {
FieldTrials field_trials = CreateTestFieldTrials();
- int64_t timestamp_ms = 1000;
+ SimulatedClock clock(Timestamp::Seconds(1));
AlrDetector alr_detector(&field_trials);
- alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps);
+ alr_detector.SetEstimatedBitrate(kEstimatedBitrate);
// Start in non-ALR state.
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// Verify that we ALR starts when bitrate drops below 20%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(1))
.AtPercentOfEstimatedBitrate(20);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
// Verify that we stay in ALR region even after a short bitrate spike.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(100)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Millis(100))
.AtPercentOfEstimatedBitrate(150);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
// ALR ends when usage is above 65%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(3000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(3))
.AtPercentOfEstimatedBitrate(100);
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
}
TEST(AlrDetectorTest, BandwidthEstimateChanges) {
FieldTrials field_trials = CreateTestFieldTrials();
- int64_t timestamp_ms = 1000;
+ SimulatedClock clock(Timestamp::Seconds(1));
AlrDetector alr_detector(&field_trials);
- alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps);
+ alr_detector.SetEstimatedBitrate(kEstimatedBitrate);
// Start in non-ALR state.
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// ALR starts when bitrate drops below 20%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(1))
.AtPercentOfEstimatedBitrate(20);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
@@ -147,10 +141,10 @@ TEST(AlrDetectorTest, BandwidthEstimateChanges) {
// it shortly afterwards as the sender continues sending the same amount of
// traffic. This is necessary to ensure that ProbeController can still react
// to the BWE drop by initiating a new probe.
- alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps / 5);
+ alr_detector.SetEstimatedBitrate(kEstimatedBitrate / 5);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(1))
.AtPercentOfEstimatedBitrate(50);
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
}
@@ -184,23 +178,23 @@ TEST(AlrDetectorTest, ParseAlrSpecificFieldTrial) {
"WebRTC-AlrDetectorParameters/"
"bw_usage:90%,start:0%,stop:-10%/");
AlrDetector alr_detector(&field_trials);
- int64_t timestamp_ms = 1000;
- alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps);
+ SimulatedClock clock(Timestamp::Seconds(1));
+ alr_detector.SetEstimatedBitrate(kEstimatedBitrate);
// Start in non-ALR state.
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// ALR does not start at 100% utilization.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(1000)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Seconds(1))
.AtPercentOfEstimatedBitrate(100);
EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime());
// ALR does start at 85% utilization.
// Overused 10% above so it should take about 2s to reach a budget level of
// 0%.
- SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms)
- .ForTimeMs(2100)
+ SimulateOutgoingTrafficIn(&alr_detector, &clock)
+ .ForTime(TimeDelta::Millis(2'100))
.AtPercentOfEstimatedBitrate(85);
EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime());
}
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc
@@ -221,9 +221,8 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval(
msg.pacer_queue->bytes());
}
bandwidth_estimation_->UpdateEstimate(msg.at_time);
- std::optional<int64_t> start_time_ms =
- alr_detector_->GetApplicationLimitedRegionStartTime();
- probe_controller_->SetAlrStartTimeMs(start_time_ms);
+ probe_controller_->SetAlrStartTime(
+ alr_detector_->GetApplicationLimitedRegionStartTime());
auto probes = probe_controller_->Process(msg.at_time);
update.probe_cluster_configs.insert(update.probe_cluster_configs.end(),
@@ -264,8 +263,7 @@ NetworkControlUpdate GoogCcNetworkController::OnRoundTripTimeUpdate(
NetworkControlUpdate GoogCcNetworkController::OnSentPacket(
SentPacket sent_packet) {
- alr_detector_->OnBytesSent(sent_packet.size.bytes(),
- sent_packet.send_time.ms());
+ alr_detector_->OnBytesSent(sent_packet.size, sent_packet.send_time);
acknowledged_bitrate_estimator_->SetAlr(
alr_detector_->GetApplicationLimitedRegionStartTime().has_value());
@@ -446,12 +444,11 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
min_propagation_rtt);
}
- std::optional<int64_t> alr_start_time =
+ std::optional<Timestamp> alr_start_time =
alr_detector_->GetApplicationLimitedRegionStartTime();
if (previously_in_alr_ && !alr_start_time.has_value()) {
- int64_t now_ms = report.feedback_time.ms();
acknowledged_bitrate_estimator_->SetAlrEndedTime(report.feedback_time);
- probe_controller_->SetAlrEndedTimeMs(now_ms);
+ probe_controller_->SetAlrEndedTime(report.feedback_time);
}
previously_in_alr_ = alr_start_time.has_value();
acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector(
@@ -521,7 +518,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
recovered_from_overuse = result.recovered_from_overuse;
if (recovered_from_overuse) {
- probe_controller_->SetAlrStartTimeMs(alr_start_time);
+ probe_controller_->SetAlrStartTime(alr_start_time);
auto probes = probe_controller_->RequestProbe(report.feedback_time);
update.probe_cluster_configs.insert(update.probe_cluster_configs.end(),
probes.begin(), probes.end());
@@ -617,7 +614,7 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
last_estimated_round_trip_time_ = round_trip_time;
last_loss_base_state_ = loss_based_state;
- alr_detector_->SetEstimatedBitrate(loss_based_target_rate.bps());
+ alr_detector_->SetEstimatedBitrate(loss_based_target_rate);
TimeDelta bwe_period = delay_based_bwe_->GetExpectedBwePeriod();
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller.cc
@@ -11,7 +11,6 @@
#include "modules/congestion_controller/goog_cc/probe_controller.h"
#include <algorithm>
-#include <cstdint>
#include <initializer_list>
#include <memory>
#include <optional>
@@ -376,16 +375,11 @@ void ProbeController::EnableRepeatedInitialProbing(bool enable) {
repeated_initial_probing_enabled_ = enable;
}
-void ProbeController::SetAlrStartTimeMs(
- std::optional<int64_t> alr_start_time_ms) {
- if (alr_start_time_ms) {
- alr_start_time_ = Timestamp::Millis(*alr_start_time_ms);
- } else {
- alr_start_time_ = std::nullopt;
- }
+void ProbeController::SetAlrStartTime(std::optional<Timestamp> alr_start_time) {
+ alr_start_time_ = alr_start_time;
}
-void ProbeController::SetAlrEndedTimeMs(int64_t alr_end_time_ms) {
- alr_end_time_.emplace(Timestamp::Millis(alr_end_time_ms));
+void ProbeController::SetAlrEndedTime(Timestamp alr_end_time) {
+ alr_end_time_ = alr_end_time;
}
std::vector<ProbeClusterConfig> ProbeController::RequestProbe(
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller.h
@@ -146,8 +146,8 @@ class ProbeController {
// SetBitrates.
void EnableRepeatedInitialProbing(bool enable);
- void SetAlrStartTimeMs(std::optional<int64_t> alr_start_time);
- void SetAlrEndedTimeMs(int64_t alr_end_time);
+ void SetAlrStartTime(std::optional<Timestamp> alr_start_time);
+ void SetAlrEndedTime(Timestamp alr_end_time);
ABSL_MUST_USE_RESULT std::vector<ProbeClusterConfig> RequestProbe(
Timestamp at_time);
diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_unittest.cc
@@ -206,14 +206,14 @@ TEST(ProbeControllerTest, ProbesOnMaxAllocatedBitrateIncreaseOnlyWhenInAlr) {
EXPECT_TRUE(probes.empty());
// Probe when in alr.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probes = probe_controller->OnMaxTotalAllocatedBitrate(
kMaxBitrate + DataRate::BitsPerSec(1), fixture.CurrentTime());
EXPECT_EQ(probes.size(), 2u);
EXPECT_EQ(probes.at(0).target_data_rate, kMaxBitrate);
// Do not probe when not in alr.
- probe_controller->SetAlrStartTimeMs(std::nullopt);
+ probe_controller->SetAlrStartTime(std::nullopt);
probes = probe_controller->OnMaxTotalAllocatedBitrate(
kMaxBitrate + DataRate::BitsPerSec(2), fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -240,7 +240,7 @@ TEST(ProbeControllerTest, ProbesOnMaxAllocatedBitrateLimitedByCurrentBwe) {
EXPECT_TRUE(probes.empty());
// Probe when in alr.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probes = probe_controller->OnMaxTotalAllocatedBitrate(kMaxBitrate,
fixture.CurrentTime());
EXPECT_EQ(probes.size(), 1u);
@@ -271,10 +271,10 @@ TEST(ProbeControllerTest, CanDisableProbingOnMaxTotalAllocatedBitrateIncrease) {
fixture.AdvanceTime(kExponentialProbingTimeout);
probes = probe_controller->Process(fixture.CurrentTime());
ASSERT_TRUE(probes.empty());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
// Do no probe, since probe_max_allocation:false.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probes = probe_controller->OnMaxTotalAllocatedBitrate(
kMaxBitrate + DataRate::BitsPerSec(1), fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -496,7 +496,7 @@ TEST(ProbeControllerTest, RequestProbeInAlr) {
DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
probes = probe_controller->SetEstimatedBitrate(
@@ -522,13 +522,13 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) {
DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(std::nullopt);
+ probe_controller->SetAlrStartTime(std::nullopt);
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
probes = probe_controller->SetEstimatedBitrate(
DataRate::BitsPerSec(250), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrEndedTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrEndedTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrEndedTimeout - TimeDelta::Millis(1));
probes = probe_controller->RequestProbe(fixture.CurrentTime());
@@ -550,13 +550,13 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) {
DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(std::nullopt);
+ probe_controller->SetAlrStartTime(std::nullopt);
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
probes = probe_controller->SetEstimatedBitrate(
DataRate::BitsPerSec(250), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrEndedTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrEndedTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrEndedTimeout + TimeDelta::Millis(1));
probes = probe_controller->RequestProbe(fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -576,7 +576,7 @@ TEST(ProbeControllerTest, RequestProbeWhenBweDropNotRecent) {
DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
probes = probe_controller->SetEstimatedBitrate(
@@ -605,7 +605,7 @@ TEST(ProbeControllerTest, PeriodicProbing) {
Timestamp start_time = fixture.CurrentTime();
// Expect the controller to send a new probe after 5s has passed.
- probe_controller->SetAlrStartTimeMs(start_time.ms());
+ probe_controller->SetAlrStartTime(start_time);
fixture.AdvanceTime(TimeDelta::Seconds(5));
probes = probe_controller->Process(fixture.CurrentTime());
EXPECT_EQ(probes.size(), 1u);
@@ -616,7 +616,7 @@ TEST(ProbeControllerTest, PeriodicProbing) {
fixture.CurrentTime());
// The following probe should be sent at 10s into ALR.
- probe_controller->SetAlrStartTimeMs(start_time.ms());
+ probe_controller->SetAlrStartTime(start_time);
fixture.AdvanceTime(TimeDelta::Seconds(4));
probes = probe_controller->Process(fixture.CurrentTime());
probes = probe_controller->SetEstimatedBitrate(
@@ -624,7 +624,7 @@ TEST(ProbeControllerTest, PeriodicProbing) {
fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
- probe_controller->SetAlrStartTimeMs(start_time.ms());
+ probe_controller->SetAlrStartTime(start_time);
fixture.AdvanceTime(TimeDelta::Seconds(1));
probes = probe_controller->Process(fixture.CurrentTime());
EXPECT_EQ(probes.size(), 1u);
@@ -643,7 +643,7 @@ TEST(ProbeControllerTest, PeriodicProbingAfterReset) {
IsEmpty());
Timestamp alr_start_time = fixture.CurrentTime();
- probe_controller->SetAlrStartTimeMs(alr_start_time.ms());
+ probe_controller->SetAlrStartTime(alr_start_time);
probe_controller->EnablePeriodicAlrProbing(true);
auto probes = probe_controller->SetBitrates(
kMinBitrate, kStartBitrate, kMaxBitrate, fixture.CurrentTime());
@@ -732,7 +732,7 @@ TEST(ProbeControllerTest, TestAllocatedBitrateCap) {
// Configure ALR for periodic probing.
probe_controller->EnablePeriodicAlrProbing(true);
Timestamp alr_start_time = fixture.CurrentTime();
- probe_controller->SetAlrStartTimeMs(alr_start_time.ms());
+ probe_controller->SetAlrStartTime(alr_start_time);
DataRate estimated_bitrate = 10 * kMbpsMultiplier;
probes = probe_controller->SetEstimatedBitrate(
@@ -799,7 +799,7 @@ TEST(ProbeControllerTest, ConfigurableProbingFieldTrial) {
fixture.AdvanceTime(TimeDelta::Seconds(5));
probes = probe_controller->Process(fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probes = probe_controller->OnMaxTotalAllocatedBitrate(
DataRate::KilobitsPerSec(200), fixture.CurrentTime());
EXPECT_EQ(probes.size(), 1u);
@@ -820,7 +820,7 @@ TEST(ProbeControllerTest, LimitAlrProbeWhenLossBasedBweLimited) {
DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
// Expect the controller to send a new probe after 5s has passed.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(TimeDelta::Seconds(5));
probes = probe_controller->Process(fixture.CurrentTime());
ASSERT_EQ(probes.size(), 1u);
@@ -919,7 +919,7 @@ TEST(ProbeControllerTest, AlrProbesLimitedByNetworkStateEstimate) {
probes = probe_controller->SetEstimatedBitrate(
DataRate::KilobitsPerSec(6), BandwidthLimitedCause::kDelayBasedLimited,
fixture.CurrentTime());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(TimeDelta::Seconds(5));
probes = probe_controller->Process(fixture.CurrentTime());
@@ -982,7 +982,7 @@ TEST(ProbeControllerTest, ProbeInAlrIfLossBasedIncreasing) {
ASSERT_TRUE(probes.empty());
// Probe when in alr.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
ASSERT_EQ(probes.size(), 1u);
@@ -1009,7 +1009,7 @@ TEST(ProbeControllerTest, NotProbeWhenInAlrIfLossBasedDecreases) {
ASSERT_TRUE(probes.empty());
// Not probe in alr when loss based estimate decreases.
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -1034,7 +1034,7 @@ TEST(ProbeControllerTest, NotProbeIfLossBasedIncreasingOutsideAlr) {
probes = probe_controller->Process(fixture.CurrentTime());
ASSERT_TRUE(probes.empty());
- probe_controller->SetAlrStartTimeMs(std::nullopt);
+ probe_controller->SetAlrStartTime(std::nullopt);
fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1));
probes = probe_controller->Process(fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -1320,7 +1320,7 @@ TEST(ProbeControllerTest, SkipAlrProbeIfEstimateLargerThanMaxProbe) {
fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
fixture.AdvanceTime(TimeDelta::Seconds(10));
probes = probe_controller->Process(fixture.CurrentTime());
EXPECT_TRUE(probes.empty());
@@ -1350,7 +1350,7 @@ TEST(ProbeControllerTest,
fixture.CurrentTime());
fixture.AdvanceTime(TimeDelta::Seconds(10));
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probes = probe_controller->OnMaxTotalAllocatedBitrate(kMaxBitrate / 2,
fixture.CurrentTime());
// No probes since total allocated is not higher than the current estimate.
@@ -1453,7 +1453,7 @@ TEST(ProbeControllerTest,
probes = probe_controller->Process(fixture.CurrentTime());
ASSERT_TRUE(probes.empty());
- probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms());
+ probe_controller->SetAlrStartTime(fixture.CurrentTime());
probe_controller->SetNetworkStateEstimate(
{.link_capacity_upper = kStartBitrate / 2});
fixture.AdvanceTime(TimeDelta::Seconds(6));