Optional: Use nullopt and implicit construction in /video
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: Ie622c215e06956d8d5629733c76f531b7af45012 Reviewed-on: https://webrtc-review.googlesource.com/23568 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Oskar Sundbom <ossu@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21535}
This commit is contained in:
parent
62337e59dd
commit
8e07c134ab
@ -576,8 +576,7 @@ TEST_P(EndToEndTest, ReceivesNackAndRetransmitsAudio) {
|
||||
EXPECT_TRUE(parser_->Parse(packet, length, &header));
|
||||
|
||||
if (!sequence_number_to_retransmit_) {
|
||||
sequence_number_to_retransmit_ =
|
||||
rtc::Optional<uint16_t>(header.sequenceNumber);
|
||||
sequence_number_to_retransmit_ = header.sequenceNumber;
|
||||
|
||||
// Don't ask for retransmission straight away, may be deduped in pacer.
|
||||
} else if (header.sequenceNumber == *sequence_number_to_retransmit_) {
|
||||
|
||||
@ -546,7 +546,7 @@ void OveruseFrameDetector::StopCheckForOveruse() {
|
||||
void OveruseFrameDetector::EncodedFrameTimeMeasured(int encode_duration_ms) {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
|
||||
if (!metrics_)
|
||||
metrics_ = rtc::Optional<CpuOveruseMetrics>(CpuOveruseMetrics());
|
||||
metrics_ = CpuOveruseMetrics();
|
||||
metrics_->encode_usage_percent = usage_->Value();
|
||||
|
||||
metrics_observer_->OnEncodedFrameTimeMeasured(encode_duration_ms, *metrics_);
|
||||
@ -576,7 +576,7 @@ void OveruseFrameDetector::ResetAll(int num_pixels) {
|
||||
usage_->Reset();
|
||||
last_capture_time_us_ = -1;
|
||||
num_process_times_ = 0;
|
||||
metrics_ = rtc::Optional<CpuOveruseMetrics>();
|
||||
metrics_ = rtc::nullopt;
|
||||
OnTargetFramerateUpdated(max_framerate_);
|
||||
}
|
||||
|
||||
|
||||
@ -59,9 +59,9 @@ void QualityThreshold::AddMeasurement(int measurement) {
|
||||
|
||||
float sufficient_majority = fraction_ * max_measurements_;
|
||||
if (count_high_ >= sufficient_majority) {
|
||||
is_high_ = rtc::Optional<bool>(true);
|
||||
is_high_ = true;
|
||||
} else if (count_low_ >= sufficient_majority) {
|
||||
is_high_ = rtc::Optional<bool>(false);
|
||||
is_high_ = false;
|
||||
}
|
||||
|
||||
if (until_full_ > 0)
|
||||
@ -80,7 +80,7 @@ rtc::Optional<bool> QualityThreshold::IsHigh() const {
|
||||
|
||||
rtc::Optional<double> QualityThreshold::CalculateVariance() const {
|
||||
if (until_full_ > 0) {
|
||||
return rtc::Optional<double>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
double variance = 0;
|
||||
@ -88,17 +88,16 @@ rtc::Optional<double> QualityThreshold::CalculateVariance() const {
|
||||
for (int i = 0; i < max_measurements_; ++i) {
|
||||
variance += (buffer_[i] - mean) * (buffer_[i] - mean);
|
||||
}
|
||||
return rtc::Optional<double>(variance / (max_measurements_ - 1));
|
||||
return variance / (max_measurements_ - 1);
|
||||
}
|
||||
|
||||
rtc::Optional<double> QualityThreshold::FractionHigh(
|
||||
int min_required_samples) const {
|
||||
RTC_DCHECK_GT(min_required_samples, 0);
|
||||
if (num_certain_states_ < min_required_samples)
|
||||
return rtc::Optional<double>();
|
||||
return rtc::nullopt;
|
||||
|
||||
return rtc::Optional<double>(static_cast<double>(num_high_states_) /
|
||||
num_certain_states_);
|
||||
return static_cast<double>(num_high_states_) / num_certain_states_;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -645,14 +645,14 @@ void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional<uint8_t> qp,
|
||||
<< "Frames decoded was not 1 when first qp value was received.";
|
||||
stats_.frames_decoded = 1;
|
||||
}
|
||||
stats_.qp_sum = rtc::Optional<uint64_t>(0);
|
||||
stats_.qp_sum = 0;
|
||||
}
|
||||
*stats_.qp_sum += *qp;
|
||||
content_specific_stats->qp_counter.Add(*qp);
|
||||
} else if (stats_.qp_sum) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "QP sum was already set and no QP was given for a frame.";
|
||||
stats_.qp_sum = rtc::Optional<uint64_t>();
|
||||
stats_.qp_sum = rtc::nullopt;
|
||||
}
|
||||
last_content_type_ = content_type;
|
||||
decode_fps_estimator_.Update(1, now);
|
||||
|
||||
@ -70,7 +70,7 @@ class ReceiveStatisticsProxyTest
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) {
|
||||
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
|
||||
for (uint32_t i = 1; i <= 3; ++i) {
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt,
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
|
||||
}
|
||||
@ -79,24 +79,20 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) {
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) {
|
||||
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
|
||||
for (uint32_t i = 1; i <= 3; ++i) {
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt,
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
|
||||
}
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(1u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(1u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_decoded);
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) {
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(130u),
|
||||
statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(130u, statistics_proxy_->GetStats().qp_sum);
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) {
|
||||
@ -104,12 +100,10 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) {
|
||||
const std::string kScreenshareString("screen");
|
||||
EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString(
|
||||
statistics_proxy_->GetStats().content_type));
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
VideoContentType::SCREENSHARE);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::SCREENSHARE);
|
||||
EXPECT_EQ(kScreenshareString, videocontenttypehelpers::ToString(
|
||||
statistics_proxy_->GetStats().content_type));
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString(
|
||||
statistics_proxy_->GetStats().content_type));
|
||||
}
|
||||
@ -119,25 +113,21 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) {
|
||||
const int64_t kInterframeDelayMs2 = 200;
|
||||
const int64_t kInterframeDelayMs3 = 100;
|
||||
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(kInterframeDelayMs1,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(kInterframeDelayMs2,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
// kInterframeDelayMs3 is smaller than kInterframeDelayMs2.
|
||||
EXPECT_EQ(kInterframeDelayMs2,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
@ -148,46 +138,41 @@ TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) {
|
||||
const int64_t kInterframeDelayMs2 = 750;
|
||||
const int64_t kInterframeDelayMs3 = 700;
|
||||
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(kInterframeDelayMs1,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
// Still first delay is the maximum
|
||||
EXPECT_EQ(kInterframeDelayMs1,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnDecodedFrame(127u, VideoContentType::UNSPECIFIED);
|
||||
// Now the first sample is out of the window, so the second is the maximum.
|
||||
EXPECT_EQ(kInterframeDelayMs2,
|
||||
statistics_proxy_->GetStats().interframe_delay_max_ms);
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) {
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt,
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) {
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(3u, VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt,
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
||||
VideoContentType::UNSPECIFIED);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) {
|
||||
@ -688,7 +673,7 @@ TEST_F(ReceiveStatisticsProxyTest, DoesNotReportStaleFramerates) {
|
||||
// Since OnRenderedFrame is never called the fps in each sample will be 0,
|
||||
// i.e. bad
|
||||
frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds());
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt,
|
||||
VideoContentType::UNSPECIFIED);
|
||||
statistics_proxy_->OnRenderedFrame(frame);
|
||||
fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps);
|
||||
@ -803,12 +788,12 @@ TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) {
|
||||
const VideoContentType content_type = GetParam();
|
||||
const int kInterFrameDelayMs = 33;
|
||||
for (int i = 0; i < kMinRequiredSamples; ++i) {
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
}
|
||||
// One extra with double the interval.
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
const int kExpectedInterFrame =
|
||||
@ -836,16 +821,16 @@ TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysPercentilesAreReported) {
|
||||
const int kLastFivePercentsSamples = kMinRequiredSamples * 5 / 100;
|
||||
for (int i = 0; i <= kMinRequiredSamples - kLastFivePercentsSamples; ++i) {
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
}
|
||||
// Last 5% of intervals are double in size.
|
||||
for (int i = 0; i < kLastFivePercentsSamples; ++i) {
|
||||
fake_clock_.AdvanceTimeMilliseconds(2 * kInterFrameDelayMs);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
}
|
||||
// Final sample is outlier and 10 times as big.
|
||||
fake_clock_.AdvanceTimeMilliseconds(10 * kInterFrameDelayMs);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
const int kExpectedInterFrame = kInterFrameDelayMs * 2;
|
||||
@ -864,7 +849,7 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithValidAverage) {
|
||||
const VideoContentType content_type = GetParam();
|
||||
const int kInterFrameDelayMs = 33;
|
||||
for (int i = 0; i < kMinRequiredSamples; ++i) {
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
}
|
||||
|
||||
@ -883,7 +868,7 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) {
|
||||
const VideoContentType content_type = GetParam();
|
||||
const int kInterFrameDelayMs = 33;
|
||||
for (int i = 0; i <= kMinRequiredSamples; ++i) {
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
}
|
||||
|
||||
@ -894,9 +879,9 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) {
|
||||
|
||||
// Insert two more frames. The interval during the pause should be disregarded
|
||||
// in the stats.
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
if (videocontenttypehelpers::IsScreenshare(content_type)) {
|
||||
@ -930,13 +915,13 @@ TEST_P(ReceiveStatisticsProxyTest, StatsAreSlicedOnSimulcastAndExperiment) {
|
||||
videocontenttypehelpers::SetSimulcastId(&content_type, 1);
|
||||
for (int i = 0; i <= kMinRequiredSamples; ++i) {
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
}
|
||||
|
||||
videocontenttypehelpers::SetSimulcastId(&content_type, 2);
|
||||
for (int i = 0; i <= kMinRequiredSamples; ++i) {
|
||||
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
||||
statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type);
|
||||
}
|
||||
statistics_proxy_.reset();
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ bool IsForcedFallbackPossible(const CodecSpecificInfo* codec_info) {
|
||||
|
||||
rtc::Optional<int> GetFallbackMaxPixels(const std::string& group) {
|
||||
if (group.empty())
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
|
||||
int min_pixels;
|
||||
int max_pixels;
|
||||
@ -882,7 +882,7 @@ void SendStatisticsProxy::OnSendEncodedImage(
|
||||
|
||||
if (encoded_image.qp_ != -1) {
|
||||
if (!stats_.qp_sum)
|
||||
stats_.qp_sum = rtc::Optional<uint64_t>(0);
|
||||
stats_.qp_sum = 0;
|
||||
*stats_.qp_sum += encoded_image.qp_;
|
||||
|
||||
if (codec_info) {
|
||||
|
||||
@ -344,23 +344,22 @@ TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesFramesEncoded) {
|
||||
TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesQpSum) {
|
||||
EncodedImage encoded_image;
|
||||
CodecSpecificInfo codec_info;
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
encoded_image.qp_ = 3;
|
||||
statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum);
|
||||
encoded_image.qp_ = 127;
|
||||
statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(130u),
|
||||
statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(130u, statistics_proxy_->GetStats().qp_sum);
|
||||
}
|
||||
|
||||
TEST_F(SendStatisticsProxyTest, OnSendEncodedImageWithoutQpQpSumWontExist) {
|
||||
EncodedImage encoded_image;
|
||||
CodecSpecificInfo codec_info;
|
||||
encoded_image.qp_ = -1;
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
|
||||
EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
||||
EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum);
|
||||
}
|
||||
|
||||
TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) {
|
||||
|
||||
@ -312,8 +312,7 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
frames_.pop_front();
|
||||
RTC_CHECK(!frames_.empty());
|
||||
}
|
||||
first_encoded_timestamp_ =
|
||||
rtc::Optional<uint32_t>(video_frame.timestamp());
|
||||
first_encoded_timestamp_ = video_frame.timestamp();
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,7 +320,7 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!first_sent_timestamp_ &&
|
||||
encoded_frame.stream_id_ == selected_stream_) {
|
||||
first_sent_timestamp_ = rtc::Optional<uint32_t>(encoded_frame.timestamp_);
|
||||
first_sent_timestamp_ = encoded_frame.timestamp_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,7 +406,7 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
|
||||
AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
|
||||
|
||||
last_rendered_frame_ = rtc::Optional<VideoFrame>(video_frame);
|
||||
last_rendered_frame_ = video_frame;
|
||||
|
||||
StopExcludingCpuThreadTime();
|
||||
}
|
||||
@ -2042,12 +2041,11 @@ void VideoQualityTest::SetupAudio(int send_channel_id,
|
||||
audio_send_config_.min_bitrate_bps = kOpusMinBitrateBps;
|
||||
audio_send_config_.max_bitrate_bps = kOpusBitrateFbBps;
|
||||
}
|
||||
audio_send_config_.send_codec_spec =
|
||||
rtc::Optional<AudioSendStream::Config::SendCodecSpec>(
|
||||
{kAudioSendPayloadType,
|
||||
{"OPUS", 48000, 2,
|
||||
{{"usedtx", (params_.audio.dtx ? "1" : "0")},
|
||||
{"stereo", "1"}}}});
|
||||
audio_send_config_.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
|
||||
kAudioSendPayloadType,
|
||||
{"OPUS", 48000, 2,
|
||||
{{"usedtx", (params_.audio.dtx ? "1" : "0")},
|
||||
{"stereo", "1"}}});
|
||||
audio_send_config_.encoder_factory = encoder_factory_;
|
||||
audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_);
|
||||
|
||||
|
||||
@ -376,7 +376,7 @@ rtc::Optional<Syncable::Info> VideoReceiveStream::GetInfo() const {
|
||||
if (!rtp_receiver->GetLatestTimestamps(
|
||||
&info.latest_received_capture_timestamp,
|
||||
&info.latest_receive_time_ms))
|
||||
return rtc::Optional<Syncable::Info>();
|
||||
return rtc::nullopt;
|
||||
|
||||
RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp();
|
||||
RTC_DCHECK(rtp_rtcp);
|
||||
@ -385,11 +385,11 @@ rtc::Optional<Syncable::Info> VideoReceiveStream::GetInfo() const {
|
||||
nullptr,
|
||||
nullptr,
|
||||
&info.capture_time_source_clock) != 0) {
|
||||
return rtc::Optional<Syncable::Info>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
info.current_delay_ms = video_receiver_.Delay();
|
||||
return rtc::Optional<Syncable::Info>(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
uint32_t VideoReceiveStream::GetPlayoutTimestamp() const {
|
||||
|
||||
@ -158,25 +158,25 @@ const char kForcedFallbackFieldTrial[] =
|
||||
|
||||
rtc::Optional<int> GetFallbackMinBpsFromFieldTrial() {
|
||||
if (!webrtc::field_trial::IsEnabled(kForcedFallbackFieldTrial))
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
|
||||
std::string group =
|
||||
webrtc::field_trial::FindFullName(kForcedFallbackFieldTrial);
|
||||
if (group.empty())
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
|
||||
int min_pixels;
|
||||
int max_pixels;
|
||||
int min_bps;
|
||||
if (sscanf(group.c_str(), "Enabled-%d,%d,%d", &min_pixels, &max_pixels,
|
||||
&min_bps) != 3) {
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
if (min_bps <= 0)
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
|
||||
return rtc::Optional<int>(min_bps);
|
||||
return min_bps;
|
||||
}
|
||||
|
||||
int GetEncoderMinBitrateBps() {
|
||||
|
||||
@ -1964,7 +1964,7 @@ TEST_F(VideoSendStreamTest, VideoSendStreamStopSetEncoderRateToZero) {
|
||||
int32_t SetRateAllocation(const BitrateAllocation& bitrate,
|
||||
uint32_t framerate) override {
|
||||
rtc::CritScope lock(&crit_);
|
||||
bitrate_kbps_ = rtc::Optional<int>(bitrate.get_sum_kbps());
|
||||
bitrate_kbps_ = bitrate.get_sum_kbps();
|
||||
bitrate_changed_.Set();
|
||||
return FakeEncoder::SetRateAllocation(bitrate, framerate);
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ class VideoStreamEncoder::VideoSourceProxy {
|
||||
RTC_LOG(LS_INFO) << "Scaling down resolution, max pixels: "
|
||||
<< pixels_wanted;
|
||||
sink_wants_.max_pixel_count = pixels_wanted;
|
||||
sink_wants_.target_pixel_count = rtc::Optional<int>();
|
||||
sink_wants_.target_pixel_count = rtc::nullopt;
|
||||
source_->AddOrUpdateSink(video_stream_encoder_,
|
||||
GetActiveSinkWantsInternal());
|
||||
return true;
|
||||
@ -290,8 +290,7 @@ class VideoStreamEncoder::VideoSourceProxy {
|
||||
// count selected depends on the capabilities of the source. In order to
|
||||
// not take a too large step up, we cap the requested pixel count to be at
|
||||
// most four time the current number of pixels.
|
||||
sink_wants_.target_pixel_count =
|
||||
rtc::Optional<int>((pixel_count * 5) / 3);
|
||||
sink_wants_.target_pixel_count = (pixel_count * 5) / 3;
|
||||
}
|
||||
RTC_LOG(LS_INFO) << "Scaling up resolution, max pixels: "
|
||||
<< max_pixels_wanted;
|
||||
@ -558,8 +557,7 @@ void VideoStreamEncoder::ConfigureEncoderOnTaskQueue(
|
||||
if (last_frame_info_) {
|
||||
ReconfigureEncoder();
|
||||
} else if (settings_.internal_source) {
|
||||
last_frame_info_ =
|
||||
rtc::Optional<VideoFrameInfo>(VideoFrameInfo(176, 144, false));
|
||||
last_frame_info_ = VideoFrameInfo(176, 144, false);
|
||||
ReconfigureEncoder();
|
||||
}
|
||||
}
|
||||
@ -757,8 +755,8 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
|
||||
video_frame.height() != last_frame_info_->height ||
|
||||
video_frame.is_texture() != last_frame_info_->is_texture) {
|
||||
pending_encoder_reconfiguration_ = true;
|
||||
last_frame_info_ = rtc::Optional<VideoFrameInfo>(VideoFrameInfo(
|
||||
video_frame.width(), video_frame.height(), video_frame.is_texture()));
|
||||
last_frame_info_ = VideoFrameInfo(video_frame.width(), video_frame.height(),
|
||||
video_frame.is_texture());
|
||||
RTC_LOG(LS_INFO) << "Video frame parameters changed: dimensions="
|
||||
<< last_frame_info_->width << "x"
|
||||
<< last_frame_info_->height
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user