From 8e07c134ab997d7ba5360e1e57161424bb9d1bb0 Mon Sep 17 00:00:00 2001 From: Oskar Sundbom Date: Mon, 8 Jan 2018 16:45:42 +0100 Subject: [PATCH] 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 Commit-Queue: Oskar Sundbom Cr-Commit-Position: refs/heads/master@{#21535} --- video/end_to_end_tests.cc | 3 +- video/overuse_frame_detector.cc | 4 +- video/quality_threshold.cc | 13 ++-- video/receive_statistics_proxy.cc | 4 +- video/receive_statistics_proxy_unittest.cc | 91 +++++++++------------- video/send_statistics_proxy.cc | 4 +- video/send_statistics_proxy_unittest.cc | 11 ++- video/video_quality_test.cc | 18 ++--- video/video_receive_stream.cc | 6 +- video/video_send_stream.cc | 10 +-- video/video_send_stream_tests.cc | 2 +- video/video_stream_encoder.cc | 12 ++- 12 files changed, 78 insertions(+), 100 deletions(-) diff --git a/video/end_to_end_tests.cc b/video/end_to_end_tests.cc index 91eb1a3bfa..6df63eef8b 100644 --- a/video/end_to_end_tests.cc +++ b/video/end_to_end_tests.cc @@ -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(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_) { diff --git a/video/overuse_frame_detector.cc b/video/overuse_frame_detector.cc index b7747eb910..71e3bd68cd 100644 --- a/video/overuse_frame_detector.cc +++ b/video/overuse_frame_detector.cc @@ -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()); + 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(); + metrics_ = rtc::nullopt; OnTargetFramerateUpdated(max_framerate_); } diff --git a/video/quality_threshold.cc b/video/quality_threshold.cc index 8ee9fbb1ff..fc8787a3ff 100644 --- a/video/quality_threshold.cc +++ b/video/quality_threshold.cc @@ -59,9 +59,9 @@ void QualityThreshold::AddMeasurement(int measurement) { float sufficient_majority = fraction_ * max_measurements_; if (count_high_ >= sufficient_majority) { - is_high_ = rtc::Optional(true); + is_high_ = true; } else if (count_low_ >= sufficient_majority) { - is_high_ = rtc::Optional(false); + is_high_ = false; } if (until_full_ > 0) @@ -80,7 +80,7 @@ rtc::Optional QualityThreshold::IsHigh() const { rtc::Optional QualityThreshold::CalculateVariance() const { if (until_full_ > 0) { - return rtc::Optional(); + return rtc::nullopt; } double variance = 0; @@ -88,17 +88,16 @@ rtc::Optional QualityThreshold::CalculateVariance() const { for (int i = 0; i < max_measurements_; ++i) { variance += (buffer_[i] - mean) * (buffer_[i] - mean); } - return rtc::Optional(variance / (max_measurements_ - 1)); + return variance / (max_measurements_ - 1); } rtc::Optional QualityThreshold::FractionHigh( int min_required_samples) const { RTC_DCHECK_GT(min_required_samples, 0); if (num_certain_states_ < min_required_samples) - return rtc::Optional(); + return rtc::nullopt; - return rtc::Optional(static_cast(num_high_states_) / - num_certain_states_); + return static_cast(num_high_states_) / num_certain_states_; } } // namespace webrtc diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 0fc298a1bf..2e86b4ef62 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -645,14 +645,14 @@ void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional qp, << "Frames decoded was not 1 when first qp value was received."; stats_.frames_decoded = 1; } - stats_.qp_sum = rtc::Optional(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(); + stats_.qp_sum = rtc::nullopt; } last_content_type_ = content_type; decode_fps_estimator_.Update(1, now); diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index 1d844bc964..2a536907ec 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -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(), + 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(), + statistics_proxy_->OnDecodedFrame(rtc::nullopt, VideoContentType::UNSPECIFIED); EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); } - statistics_proxy_->OnDecodedFrame(rtc::Optional(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(), statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::Optional(3u), - VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::Optional(3u), statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::Optional(127u), - VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::Optional(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(3u), - VideoContentType::SCREENSHARE); + statistics_proxy_->OnDecodedFrame(3u, VideoContentType::SCREENSHARE); EXPECT_EQ(kScreenshareString, videocontenttypehelpers::ToString( statistics_proxy_->GetStats().content_type)); - statistics_proxy_->OnDecodedFrame(rtc::Optional(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(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(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(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(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(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(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(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(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(), statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::Optional(), + EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + statistics_proxy_->OnDecodedFrame(rtc::nullopt, VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::Optional(), statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { - EXPECT_EQ(rtc::Optional(), statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::Optional(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(3u), statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::Optional(), - VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::Optional(), 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(), + 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), content_type); + statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); - statistics_proxy_->OnDecodedFrame(rtc::Optional(), 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(), 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(), content_type); + statistics_proxy_->OnDecodedFrame(rtc::nullopt, content_type); } statistics_proxy_.reset(); diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 5325306b3c..0d2f8f665e 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -86,7 +86,7 @@ bool IsForcedFallbackPossible(const CodecSpecificInfo* codec_info) { rtc::Optional GetFallbackMaxPixels(const std::string& group) { if (group.empty()) - return rtc::Optional(); + 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(0); + stats_.qp_sum = 0; *stats_.qp_sum += encoded_image.qp_; if (codec_info) { diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc index 98ad5668a5..1d2edc6a78 100644 --- a/video/send_statistics_proxy_unittest.cc +++ b/video/send_statistics_proxy_unittest.cc @@ -344,23 +344,22 @@ TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesFramesEncoded) { TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesQpSum) { EncodedImage encoded_image; CodecSpecificInfo codec_info; - EXPECT_EQ(rtc::Optional(), 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(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(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(), 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(), statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); } TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) { diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 2f76ce9a27..ca4317c5ef 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -312,8 +312,7 @@ class VideoAnalyzer : public PacketReceiver, frames_.pop_front(); RTC_CHECK(!frames_.empty()); } - first_encoded_timestamp_ = - rtc::Optional(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(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(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( - {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_); diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index d284a7be93..17ddb4864f 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -376,7 +376,7 @@ rtc::Optional VideoReceiveStream::GetInfo() const { if (!rtp_receiver->GetLatestTimestamps( &info.latest_received_capture_timestamp, &info.latest_receive_time_ms)) - return rtc::Optional(); + return rtc::nullopt; RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp(); RTC_DCHECK(rtp_rtcp); @@ -385,11 +385,11 @@ rtc::Optional VideoReceiveStream::GetInfo() const { nullptr, nullptr, &info.capture_time_source_clock) != 0) { - return rtc::Optional(); + return rtc::nullopt; } info.current_delay_ms = video_receiver_.Delay(); - return rtc::Optional(info); + return info; } uint32_t VideoReceiveStream::GetPlayoutTimestamp() const { diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index e5a850f556..f1d6ba758a 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -158,25 +158,25 @@ const char kForcedFallbackFieldTrial[] = rtc::Optional GetFallbackMinBpsFromFieldTrial() { if (!webrtc::field_trial::IsEnabled(kForcedFallbackFieldTrial)) - return rtc::Optional(); + return rtc::nullopt; std::string group = webrtc::field_trial::FindFullName(kForcedFallbackFieldTrial); if (group.empty()) - return rtc::Optional(); + 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(); + return rtc::nullopt; } if (min_bps <= 0) - return rtc::Optional(); + return rtc::nullopt; - return rtc::Optional(min_bps); + return min_bps; } int GetEncoderMinBitrateBps() { diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 98a32cc858..b96b60f650 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -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(bitrate.get_sum_kbps()); + bitrate_kbps_ = bitrate.get_sum_kbps(); bitrate_changed_.Set(); return FakeEncoder::SetRateAllocation(bitrate, framerate); } diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 94360eb182..9d209dc3a1 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -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(); + 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((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(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( - 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