Optional: Use nullopt and implicit construction in /modules/congestion_controller
Changes places where we explicitly construct an Optional to instead use nullopt or the requisite value type only. This CL was uploaded by git cl split. Bug: None Change-Id: If2a98dc714d1755f07af1f70248cf41e4a9db750 Reviewed-on: https://webrtc-review.googlesource.com/23612 Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Oskar Sundbom <ossu@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20887}
This commit is contained in:
parent
d0e196bd26
commit
5b8c0a2a1e
@ -94,8 +94,8 @@ float BitrateEstimator::UpdateWindow(int64_t now_ms,
|
||||
|
||||
rtc::Optional<uint32_t> BitrateEstimator::bitrate_bps() const {
|
||||
if (bitrate_estimate_ < 0.f)
|
||||
return rtc::Optional<uint32_t>();
|
||||
return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000);
|
||||
return rtc::nullopt;
|
||||
return bitrate_estimate_ * 1000;
|
||||
}
|
||||
|
||||
void BitrateEstimator::ExpectFastRateChange() {
|
||||
|
||||
@ -29,7 +29,7 @@ constexpr float kTargetUtilizationFraction = 0.95f;
|
||||
TEST_F(DelayBasedBweTest, NoCrashEmptyFeedback) {
|
||||
std::vector<PacketFeedback> packet_feedback_vector;
|
||||
bitrate_estimator_->IncomingPacketFeedbackVector(packet_feedback_vector,
|
||||
rtc::Optional<uint32_t>());
|
||||
rtc::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(DelayBasedBweTest, NoCrashOnlyLostFeedback) {
|
||||
@ -39,7 +39,7 @@ TEST_F(DelayBasedBweTest, NoCrashOnlyLostFeedback) {
|
||||
packet_feedback_vector.push_back(
|
||||
PacketFeedback(-1, -1, 1, 1500, PacedPacketInfo()));
|
||||
bitrate_estimator_->IncomingPacketFeedbackVector(packet_feedback_vector,
|
||||
rtc::Optional<uint32_t>());
|
||||
rtc::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(DelayBasedBweTest, ProbeDetection) {
|
||||
|
||||
@ -164,7 +164,7 @@ int ProbeBitrateEstimator::HandleProbeAndEstimateBitrate(
|
||||
event_log_->Log(
|
||||
rtc::MakeUnique<RtcEventProbeResultSuccess>(cluster_id, res));
|
||||
}
|
||||
estimated_bitrate_bps_ = rtc::Optional<int>(res);
|
||||
estimated_bitrate_bps_ = res;
|
||||
return *estimated_bitrate_bps_;
|
||||
}
|
||||
|
||||
|
||||
@ -130,8 +130,7 @@ TEST_F(ProbeControllerTest, RequestProbeInAlr) {
|
||||
testing::Mock::VerifyAndClearExpectations(&pacer_);
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(0.85 * 500)).Times(1);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(
|
||||
Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds())));
|
||||
.WillRepeatedly(Return(clock_.TimeInMilliseconds()));
|
||||
clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(250);
|
||||
@ -146,7 +145,7 @@ TEST_F(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) {
|
||||
testing::Mock::VerifyAndClearExpectations(&pacer_);
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(0.85 * 500)).Times(1);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(Return(rtc::Optional<int64_t>()));
|
||||
.WillRepeatedly(Return(rtc::nullopt));
|
||||
clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(250);
|
||||
@ -163,7 +162,7 @@ TEST_F(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) {
|
||||
testing::Mock::VerifyAndClearExpectations(&pacer_);
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(Return(rtc::Optional<int64_t>()));
|
||||
.WillRepeatedly(Return(rtc::nullopt));
|
||||
clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(250);
|
||||
@ -180,8 +179,7 @@ TEST_F(ProbeControllerTest, RequestProbeWhenBweDropNotRecent) {
|
||||
testing::Mock::VerifyAndClearExpectations(&pacer_);
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(
|
||||
Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds())));
|
||||
.WillRepeatedly(Return(clock_.TimeInMilliseconds()));
|
||||
clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(250);
|
||||
@ -202,7 +200,7 @@ TEST_F(ProbeControllerTest, PeriodicProbing) {
|
||||
// Expect the controller to send a new probe after 5s has passed.
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(1000)).Times(1);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
|
||||
.WillRepeatedly(Return(start_time));
|
||||
clock_.AdvanceTimeMilliseconds(5000);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(500);
|
||||
@ -211,7 +209,7 @@ TEST_F(ProbeControllerTest, PeriodicProbing) {
|
||||
// The following probe should be sent at 10s into ALR.
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
|
||||
.WillRepeatedly(Return(start_time));
|
||||
clock_.AdvanceTimeMilliseconds(4000);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(500);
|
||||
@ -219,7 +217,7 @@ TEST_F(ProbeControllerTest, PeriodicProbing) {
|
||||
|
||||
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(1);
|
||||
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
|
||||
.WillRepeatedly(Return(start_time));
|
||||
clock_.AdvanceTimeMilliseconds(1000);
|
||||
probe_controller_->Process();
|
||||
probe_controller_->SetEstimatedBitrate(500);
|
||||
@ -231,8 +229,7 @@ TEST_F(ProbeControllerTest, PeriodicProbingAfterReset) {
|
||||
probe_controller_.reset(new ProbeController(&local_pacer, &clock_));
|
||||
int64_t alr_start_time = clock_.TimeInMilliseconds();
|
||||
EXPECT_CALL(local_pacer, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(
|
||||
Return(rtc::Optional<int64_t>(alr_start_time)));
|
||||
.WillRepeatedly(Return(alr_start_time));
|
||||
|
||||
EXPECT_CALL(local_pacer, CreateProbeCluster(_)).Times(2);
|
||||
probe_controller_->EnablePeriodicAlrProbing(true);
|
||||
|
||||
@ -94,7 +94,7 @@ class SendSideCongestionControllerTest : public ::testing::Test {
|
||||
uint8_t fraction_loss, // 0 - 255.
|
||||
int64_t rtt_ms,
|
||||
int64_t probing_interval_ms) override {
|
||||
owner_->target_bitrate_bps_ = rtc::Optional<uint32_t>(bitrate_bps);
|
||||
owner_->target_bitrate_bps_ = bitrate_bps;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -39,8 +39,8 @@ rtc::Optional<double> LinearFitSlope(
|
||||
denominator += (point.first - x_avg) * (point.first - x_avg);
|
||||
}
|
||||
if (denominator == 0)
|
||||
return rtc::Optional<double>();
|
||||
return rtc::Optional<double>(numerator / denominator);
|
||||
return rtc::nullopt;
|
||||
return numerator / denominator;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user