diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 75a62c2f75..709fd7fade 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -49,7 +49,6 @@ rtc_static_library("audio") { "../api:array_view", "../api:call_api", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/audio:aec3_factory", "../api/audio:audio_frame_api", @@ -87,6 +86,7 @@ rtc_static_library("audio") { "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", "utility:audio_frame_operations", + "//third_party/abseil-cpp/absl/types:optional", ] } if (rtc_include_tests) { diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 941439fae1..b52563bed1 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -257,7 +257,7 @@ int AudioReceiveStream::id() const { return config_.rtp.remote_ssrc; } -rtc::Optional AudioReceiveStream::GetInfo() const { +absl::optional AudioReceiveStream::GetInfo() const { RTC_DCHECK_RUN_ON(&module_process_thread_checker_); Syncable::Info info; @@ -270,14 +270,14 @@ rtc::Optional AudioReceiveStream::GetInfo() const { if (!rtp_receiver->GetLatestTimestamps( &info.latest_received_capture_timestamp, &info.latest_receive_time_ms)) { - return rtc::nullopt; + return absl::nullopt; } if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, &info.capture_time_ntp_frac, nullptr, nullptr, &info.capture_time_source_clock) != 0) { - return rtc::nullopt; + return absl::nullopt; } info.current_delay_ms = channel_proxy_->GetDelayEstimate(); diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index 09007f0497..64552e35c0 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -80,7 +80,7 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, // Syncable int id() const override; - rtc::Optional GetInfo() const override; + absl::optional GetInfo() const override; uint32_t GetPlayoutTimestamp() const override; void SetMinimumPlayoutDelay(int delay_ms) override; diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index fe955594ef..8ed78eb461 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -91,7 +91,7 @@ AudioSendStream::AudioSendStream( BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional& suspended_rtp_state, + const absl::optional& suspended_rtp_state, TimeInterval* overall_call_lifetime) : AudioSendStream(config, audio_state, @@ -115,7 +115,7 @@ AudioSendStream::AudioSendStream( BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional& suspended_rtp_state, + const absl::optional& suspended_rtp_state, TimeInterval* overall_call_lifetime, std::unique_ptr channel_proxy) : worker_queue_(worker_queue), @@ -445,8 +445,8 @@ void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) { void AudioSendStream::OnPacketFeedbackVector( const std::vector& packet_feedback_vector) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - rtc::Optional plr; - rtc::Optional rplr; + absl::optional plr; + absl::optional rplr; { rtc::CritScope lock(&packet_loss_tracker_cs_); packet_loss_tracker_.OnPacketFeedbackVector(packet_feedback_vector); @@ -584,7 +584,7 @@ bool AudioSendStream::ReconfigureSendCodec(AudioSendStream* stream, return SetupSendCodec(stream, new_config); } - const rtc::Optional& new_target_bitrate_bps = + const absl::optional& new_target_bitrate_bps = new_config.send_codec_spec->target_bitrate_bps; // If a bitrate has been specified for the codec, use it over the // codec's default. diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index c51c7a3b2f..efc9c0e8fe 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -49,7 +49,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional& suspended_rtp_state, + const absl::optional& suspended_rtp_state, TimeInterval* overall_call_lifetime); // For unit tests, which need to supply a mock channel proxy. AudioSendStream(const webrtc::AudioSendStream::Config& config, @@ -59,7 +59,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional& suspended_rtp_state, + const absl::optional& suspended_rtp_state, TimeInterval* overall_call_lifetime, std::unique_ptr channel_proxy); ~AudioSendStream() override; @@ -146,7 +146,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RTC_GUARDED_BY(&packet_loss_tracker_cs_); RtpRtcp* rtp_rtcp_module_; - rtc::Optional const suspended_rtp_state_; + absl::optional const suspended_rtp_state_; std::unique_ptr timed_send_transport_adapter_; TimeInterval active_lifetime_; diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index d39912000c..d0bc45f4f7 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -109,17 +109,17 @@ rtc::scoped_refptr SetupEncoderFactoryMock() { std::begin(kCodecSpecs), std::end(kCodecSpecs)))); ON_CALL(*factory.get(), QueryAudioEncoder(_)) .WillByDefault(Invoke( - [](const SdpAudioFormat& format) -> rtc::Optional { + [](const SdpAudioFormat& format) -> absl::optional { for (const auto& spec : kCodecSpecs) { if (format == spec.format) { return spec.info; } } - return rtc::nullopt; + return absl::nullopt; })); ON_CALL(*factory.get(), MakeAudioEncoderMock(_, _, _, _)) .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format, - rtc::Optional codec_pair_id, + absl::optional codec_pair_id, std::unique_ptr* return_value) { *return_value = SetupAudioEncoderMock(payload_type, format); })); @@ -166,7 +166,7 @@ struct ConfigHelper { return std::unique_ptr( new internal::AudioSendStream( stream_config_, audio_state_, &worker_queue_, &rtp_transport_, - &bitrate_allocator_, &event_log_, &rtcp_rtt_stats_, rtc::nullopt, + &bitrate_allocator_, &event_log_, &rtcp_rtt_stats_, absl::nullopt, &active_lifetime_, std::unique_ptr(channel_proxy_))); } @@ -424,7 +424,7 @@ TEST(AudioSendStreamTest, SendCodecAppliesAudioNetworkAdaptor) { EXPECT_CALL(helper.mock_encoder_factory(), MakeAudioEncoderMock(_, _, _, _)) .WillOnce(Invoke([&kAnaConfigString, &kAnaReconfigString]( int payload_type, const SdpAudioFormat& format, - rtc::Optional codec_pair_id, + absl::optional codec_pair_id, std::unique_ptr* return_value) { auto mock_encoder = SetupAudioEncoderMock(payload_type, format); EXPECT_CALL(*mock_encoder, diff --git a/audio/channel.cc b/audio/channel.cc index e5dc5c2814..ecde1725bd 100644 --- a/audio/channel.cc +++ b/audio/channel.cc @@ -509,7 +509,7 @@ Channel::Channel(rtc::TaskQueue* encoder_queue, 0, false, rtc::scoped_refptr(), - rtc::nullopt) { + absl::nullopt) { RTC_DCHECK(encoder_queue); encoder_queue_ = encoder_queue; } @@ -520,7 +520,7 @@ Channel::Channel(ProcessThread* module_process_thread, size_t jitter_buffer_max_packets, bool jitter_buffer_fast_playout, rtc::scoped_refptr decoder_factory, - rtc::Optional codec_pair_id) + absl::optional codec_pair_id) : event_log_proxy_(new RtcEventLogProxy()), rtp_payload_registry_(new RTPPayloadRegistry()), rtp_receive_statistics_( diff --git a/audio/channel.h b/audio/channel.h index 6f79868391..9830a2507d 100644 --- a/audio/channel.h +++ b/audio/channel.h @@ -16,11 +16,11 @@ #include #include +#include "absl/types/optional.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_encoder.h" #include "api/call/audio_sink.h" #include "api/call/transport.h" -#include "api/optional.h" #include "audio/audio_level.h" #include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/include/audio_coding_module.h" @@ -158,7 +158,7 @@ class Channel size_t jitter_buffer_max_packets, bool jitter_buffer_fast_playout, rtc::scoped_refptr decoder_factory, - rtc::Optional codec_pair_id); + absl::optional codec_pair_id); virtual ~Channel(); void SetSink(AudioSinkInterface* sink); @@ -353,7 +353,7 @@ class Channel RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(ts_stats_lock_); // Timestamp of the audio pulled from NetEq. - rtc::Optional jitter_buffer_playout_timestamp_; + absl::optional jitter_buffer_playout_timestamp_; rtc::CriticalSection video_sync_lock_; uint32_t playout_timestamp_rtp_ RTC_GUARDED_BY(video_sync_lock_); diff --git a/audio/time_interval.h b/audio/time_interval.h index 88b2f7dd4f..79fe29d9d5 100644 --- a/audio/time_interval.h +++ b/audio/time_interval.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -57,7 +57,7 @@ class TimeInterval { int64_t first, last; }; - rtc::Optional interval_; + absl::optional interval_; }; } // namespace webrtc diff --git a/audio/transport_feedback_packet_loss_tracker.cc b/audio/transport_feedback_packet_loss_tracker.cc index 101b6b4881..7e0c5c542f 100644 --- a/audio/transport_feedback_packet_loss_tracker.cc +++ b/audio/transport_feedback_packet_loss_tracker.cc @@ -116,12 +116,12 @@ void TransportFeedbackPacketLossTracker::OnPacketFeedbackVector( } } -rtc::Optional -TransportFeedbackPacketLossTracker::GetPacketLossRate() const { +absl::optional TransportFeedbackPacketLossTracker::GetPacketLossRate() + const { return plr_state_.GetMetric(); } -rtc::Optional +absl::optional TransportFeedbackPacketLossTracker::GetRecoverablePacketLossRate() const { return rplr_state_.GetMetric(); } @@ -344,20 +344,20 @@ void TransportFeedbackPacketLossTracker::Validate() const { // Testing only! RTC_CHECK_EQ(rplr_state_.num_recoverable_losses_, recoverable_losses); } -rtc::Optional -TransportFeedbackPacketLossTracker::PlrState::GetMetric() const { +absl::optional TransportFeedbackPacketLossTracker::PlrState::GetMetric() + const { const size_t total = num_lost_packets_ + num_received_packets_; if (total < min_num_acked_packets_) { - return rtc::nullopt; + return absl::nullopt; } else { return static_cast(num_lost_packets_) / total; } } -rtc::Optional -TransportFeedbackPacketLossTracker::RplrState::GetMetric() const { +absl::optional TransportFeedbackPacketLossTracker::RplrState::GetMetric() + const { if (num_acked_pairs_ < min_num_acked_pairs_) { - return rtc::nullopt; + return absl::nullopt; } else { return static_cast(num_recoverable_losses_) / num_acked_pairs_; } diff --git a/audio/transport_feedback_packet_loss_tracker.h b/audio/transport_feedback_packet_loss_tracker.h index 4ad49024a8..7d58d6c4bd 100644 --- a/audio/transport_feedback_packet_loss_tracker.h +++ b/audio/transport_feedback_packet_loss_tracker.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -43,11 +43,11 @@ class TransportFeedbackPacketLossTracker final { // Returns the packet loss rate, if the window has enough packet statuses to // reliably compute it. Otherwise, returns empty. - rtc::Optional GetPacketLossRate() const; + absl::optional GetPacketLossRate() const; // Returns the first-order-FEC recoverable packet loss rate, if the window has // enough status pairs to reliably compute it. Otherwise, returns empty. - rtc::Optional GetRecoverablePacketLossRate() const; + absl::optional GetRecoverablePacketLossRate() const; // Verifies that the internal states are correct. Only used for tests. void Validate() const; @@ -108,7 +108,7 @@ class TransportFeedbackPacketLossTracker final { num_received_packets_ = 0; num_lost_packets_ = 0; } - rtc::Optional GetMetric() const; + absl::optional GetMetric() const; const size_t min_num_acked_packets_; size_t num_received_packets_; size_t num_lost_packets_; @@ -124,7 +124,7 @@ class TransportFeedbackPacketLossTracker final { num_acked_pairs_ = 0; num_recoverable_losses_ = 0; } - rtc::Optional GetMetric() const; + absl::optional GetMetric() const; // Recoverable packets are those which were lost, but immediately followed // by a properly received packet. If that second packet carried FEC, // the data from the former (lost) packet could be recovered. diff --git a/audio/transport_feedback_packet_loss_tracker_unittest.cc b/audio/transport_feedback_packet_loss_tracker_unittest.cc index 8f8fe05d7a..b190c62c05 100644 --- a/audio/transport_feedback_packet_loss_tracker_unittest.cc +++ b/audio/transport_feedback_packet_loss_tracker_unittest.cc @@ -94,18 +94,18 @@ class TransportFeedbackPacketLossTrackerTest // value is as expected. void ValidatePacketLossStatistics( const TransportFeedbackPacketLossTracker& tracker, - rtc::Optional expected_plr, - rtc::Optional expected_rplr) { - // TODO(eladalon): Comparing the rtc::Optional directly would have + absl::optional expected_plr, + absl::optional expected_rplr) { + // TODO(eladalon): Comparing the absl::optional directly would have // given concise code, but less readable error messages. If we modify - // the way rtc::Optional is printed, we can get rid of this. - rtc::Optional plr = tracker.GetPacketLossRate(); + // the way absl::optional is printed, we can get rid of this. + absl::optional plr = tracker.GetPacketLossRate(); EXPECT_EQ(static_cast(expected_plr), static_cast(plr)); if (expected_plr && plr) { EXPECT_EQ(*expected_plr, *plr); } - rtc::Optional rplr = tracker.GetRecoverablePacketLossRate(); + absl::optional rplr = tracker.GetRecoverablePacketLossRate(); EXPECT_EQ(static_cast(expected_rplr), static_cast(rplr)); if (expected_rplr && rplr) { EXPECT_EQ(*expected_rplr, *rplr); @@ -127,7 +127,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, EmptyWindow) { TransportFeedbackPacketLossTracker tracker(kDefaultMaxWindowSizeMs, 5, 5); // PLR and RPLR reported as unknown before reception of first feedback. - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // A feedback received for an empty window has no effect. @@ -136,7 +136,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, EmptyWindowFeedback) { // Feedback doesn't correspond to any packets - ignored. AddTransportFeedbackAndValidate(&tracker, base_, {true, false, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); // After the packets are transmitted, acking them would have an effect. SendPackets(&tracker, base_, 3, kDefaultSendIntervalMs); @@ -153,7 +153,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, PartiallyFilledWindow) { // Expected window contents: [] -> [1001]. SendPackets(&tracker, base_, 3, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // Sanity check on minimum filled window - PLR known, RPLR unknown. @@ -166,7 +166,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, PlrMinimumFilledWindow) { SendPackets(&tracker, base_, 5, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, rtc::nullopt); + ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, absl::nullopt); } // Sanity check on minimum filled window - PLR unknown, RPLR known. @@ -179,7 +179,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, RplrMinimumFilledWindow) { SendPackets(&tracker, base_, 5, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, 1.0f / 4.0f); + ValidatePacketLossStatistics(tracker, absl::nullopt, 1.0f / 4.0f); } // If packets are sent close enough together that the clock reading for both @@ -203,7 +203,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, ExtendWindow) { // Expected window contents: [] -> [10011]. AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, rtc::nullopt); + ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, absl::nullopt); // Expected window contents: [10011] -> [1001110101]. AddTransportFeedbackAndValidate(&tracker, base_ + 5, @@ -520,7 +520,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, RepeatedSeqNumResetsWindow) { // A reset occurs. SendPackets(&tracker, {static_cast(base_ + 2)}, kDefaultSendIntervalMs); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // The window is reset by the sending of a packet which is 0x8000 or more @@ -539,7 +539,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, // A reset occurs. SendPackets(&tracker, {static_cast(base_ + 5 + 0x8000)}, kDefaultSendIntervalMs); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) diff --git a/call/BUILD.gn b/call/BUILD.gn index d994eddffa..ff72fd96b0 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -33,7 +33,6 @@ rtc_source_set("call_interfaces") { "../:typedefs", "../api:fec_controller_api", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/audio:audio_mixer_api", "../api/audio_codecs:audio_codecs_api", @@ -44,6 +43,7 @@ rtc_source_set("call_interfaces") { "../rtc_base:audio_format_to_string", "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -61,9 +61,9 @@ rtc_source_set("rtp_interfaces") { ] deps = [ "../api:array_view", - "../api:optional", "../api/transport:bitrate_settings", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -87,11 +87,11 @@ rtc_source_set("rtp_receiver") { "..:webrtc_common", "../api:array_view", "../api:libjingle_peerconnection_api", - "../api:optional", "../modules/rtp_rtcp", "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:checks", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -177,7 +177,6 @@ rtc_static_library("call") { ":video_stream_api", "..:webrtc_common", "../api:callfactory_api", - "../api:optional", "../api:transport_api", "../api/transport:network_control", "../audio", @@ -204,6 +203,7 @@ rtc_static_library("call") { "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", "../video", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -220,7 +220,6 @@ rtc_source_set("video_stream_api") { "../:typedefs", "../:webrtc_common", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/video:video_frame", "../api/video_codecs:video_codecs_api", @@ -228,6 +227,7 @@ rtc_source_set("video_stream_api") { "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:checks", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index 3c0e58d899..56c900b03c 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h @@ -16,9 +16,9 @@ #include #include +#include "absl/types/optional.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/call/transport.h" -#include "api/optional.h" #include "api/rtpparameters.h" #include "api/rtpreceiverinterface.h" #include "call/rtp_config.h" @@ -40,7 +40,7 @@ class AudioReceiveStream { uint32_t packets_lost = 0; float fraction_lost = 0.0f; std::string codec_name; - rtc::Optional codec_payload_type; + absl::optional codec_payload_type; uint32_t ext_seqnum = 0; uint32_t jitter_ms = 0; uint32_t jitter_buffer_ms = 0; @@ -120,7 +120,7 @@ class AudioReceiveStream { rtc::scoped_refptr decoder_factory; - rtc::Optional codec_pair_id; + absl::optional codec_pair_id; }; // Reconfigure the stream according to the Configuration. diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 3bfff120f1..9119545ab9 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -15,12 +15,12 @@ #include #include +#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_codecs/audio_format.h" #include "api/call/transport.h" -#include "api/optional.h" #include "api/rtpparameters.h" #include "call/rtp_config.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -44,7 +44,7 @@ class AudioSendStream { int32_t packets_lost = -1; float fraction_lost = -1.0f; std::string codec_name; - rtc::Optional codec_payload_type; + absl::optional codec_payload_type; int32_t ext_seqnum = -1; int32_t jitter_ms = -1; int64_t rtt_ms = -1; @@ -102,7 +102,7 @@ class AudioSendStream { // Defines whether to turn on audio network adaptor, and defines its config // string. - rtc::Optional audio_network_adaptor_config; + absl::optional audio_network_adaptor_config; struct SendCodecSpec { SendCodecSpec(int payload_type, const SdpAudioFormat& format); @@ -118,14 +118,14 @@ class AudioSendStream { SdpAudioFormat format; bool nack_enabled = false; bool transport_cc_enabled = false; - rtc::Optional cng_payload_type; + absl::optional cng_payload_type; // If unset, use the encoder's default target bitrate. - rtc::Optional target_bitrate_bps; + absl::optional target_bitrate_bps; }; - rtc::Optional send_codec_spec; + absl::optional send_codec_spec; rtc::scoped_refptr encoder_factory; - rtc::Optional codec_pair_id; + absl::optional codec_pair_id; // Track ID as specified during track creation. std::string track_id; diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc index 6b69bc069b..9e3128cfb2 100644 --- a/call/bitrate_estimator_tests.cc +++ b/call/bitrate_estimator_tests.cc @@ -167,7 +167,7 @@ class BitrateEstimatorTest : public test::CallTest { test_->video_encoder_config_.Copy()); RTC_DCHECK_EQ(1, test_->video_encoder_config_.number_of_streams); frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( - kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt, + kDefaultWidth, kDefaultHeight, absl::nullopt, absl::nullopt, kDefaultFramerate, Clock::GetRealTimeClock())); send_stream_->SetSource(frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE); diff --git a/call/call.cc b/call/call.cc index e0105aba63..be94f6ab20 100644 --- a/call/call.cc +++ b/call/call.cc @@ -16,7 +16,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/transport/network_control.h" #include "audio/audio_receive_stream.h" #include "audio/audio_send_stream.h" @@ -343,10 +343,10 @@ class Call final : public webrtc::Call, RateCounter received_audio_bytes_per_second_counter_; RateCounter received_video_bytes_per_second_counter_; RateCounter received_rtcp_bytes_per_second_counter_; - rtc::Optional first_received_rtp_audio_ms_; - rtc::Optional last_received_rtp_audio_ms_; - rtc::Optional first_received_rtp_video_ms_; - rtc::Optional last_received_rtp_video_ms_; + absl::optional first_received_rtp_audio_ms_; + absl::optional last_received_rtp_audio_ms_; + absl::optional first_received_rtp_video_ms_; + absl::optional last_received_rtp_video_ms_; TimeInterval sent_rtp_audio_timer_ms_; rtc::CriticalSection last_bandwidth_bps_crit_; @@ -584,7 +584,7 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( event_log_->Log(rtc::MakeUnique( CreateRtcLogStreamConfig(config))); - rtc::Optional suspended_rtp_state; + absl::optional suspended_rtp_state; { const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc); if (iter != suspended_audio_send_ssrcs_.end()) { diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 3b4264f9d4..204134dd19 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -914,7 +914,7 @@ void CallPerfTest::TestMinAudioVideoBitrate( send_config->max_bitrate_bps = kOpusBitrateFbBps; } else { send_config->send_codec_spec->target_bitrate_bps = - rtc::Optional(kOpusBitrateFbBps); + absl::optional(kOpusBitrateFbBps); } } diff --git a/call/callfactory.cc b/call/callfactory.cc index 4ab5b89d6d..b5c28d2e45 100644 --- a/call/callfactory.cc +++ b/call/callfactory.cc @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "call/call.h" #include "call/degraded_call.h" #include "call/fake_network_pipe.h" @@ -30,7 +30,7 @@ bool ParseConfigParam(std::string exp_name, int* field) { return (sscanf(group.c_str(), "%d", field) == 1); } -rtc::Optional ParseDegradationConfig( +absl::optional ParseDegradationConfig( bool send) { std::string exp_prefix = "WebRTCFakeNetwork"; if (send) { @@ -62,15 +62,15 @@ rtc::Optional ParseDegradationConfig( } configured |= ParseConfigParam(exp_prefix + "AvgBurstLossLength", &config.avg_burst_loss_length); - return configured ? rtc::Optional(config) - : rtc::nullopt; + return configured ? absl::optional(config) + : absl::nullopt; } } // namespace Call* CallFactory::CreateCall(const Call::Config& config) { - rtc::Optional send_degradation_config = + absl::optional send_degradation_config = ParseDegradationConfig(true); - rtc::Optional receive_degradation_config = + absl::optional receive_degradation_config = ParseDegradationConfig(false); if (send_degradation_config || receive_degradation_config) { diff --git a/call/degraded_call.cc b/call/degraded_call.cc index 6515b65b9e..697c5f4120 100644 --- a/call/degraded_call.cc +++ b/call/degraded_call.cc @@ -17,8 +17,8 @@ namespace webrtc { DegradedCall::DegradedCall( std::unique_ptr call, - rtc::Optional send_config, - rtc::Optional receive_config) + absl::optional send_config, + absl::optional receive_config) : clock_(Clock::GetRealTimeClock()), call_(std::move(call)), send_config_(send_config), diff --git a/call/degraded_call.h b/call/degraded_call.h index 5658873922..4510578abb 100644 --- a/call/degraded_call.h +++ b/call/degraded_call.h @@ -13,8 +13,8 @@ #include +#include "absl/types/optional.h" #include "api/call/transport.h" -#include "api/optional.h" #include "call/call.h" #include "call/fake_network_pipe.h" #include "modules/utility/include/process_thread.h" @@ -25,8 +25,8 @@ namespace webrtc { class DegradedCall : public Call, private Transport, private PacketReceiver { public: explicit DegradedCall(std::unique_ptr call, - rtc::Optional send_config, - rtc::Optional receive_config); + absl::optional send_config, + absl::optional receive_config); ~DegradedCall() override; // Implements Call. @@ -90,12 +90,12 @@ class DegradedCall : public Call, private Transport, private PacketReceiver { Clock* const clock_; const std::unique_ptr call_; - const rtc::Optional send_config_; + const absl::optional send_config_; const std::unique_ptr send_process_thread_; std::unique_ptr send_pipe_; size_t num_send_streams_; - const rtc::Optional receive_config_; + const absl::optional receive_config_; std::unique_ptr receive_pipe_; }; diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 00b6f0e74f..ebe551a409 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -32,10 +32,10 @@ constexpr int64_t kLogIntervalMs = 5000; NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet, int64_t send_time, int64_t arrival_time, - rtc::Optional packet_options, + absl::optional packet_options, bool is_rtcp, MediaType media_type, - rtc::Optional packet_time) + absl::optional packet_time) : packet_(std::move(packet)), send_time_(send_time), arrival_time_(arrival_time), @@ -115,14 +115,14 @@ bool FakeNetworkPipe::SendRtp(const uint8_t* packet, const PacketOptions& options) { RTC_DCHECK(HasTransport()); EnqueuePacket(rtc::CopyOnWriteBuffer(packet, length), options, false, - MediaType::ANY, rtc::nullopt); + MediaType::ANY, absl::nullopt); return true; } bool FakeNetworkPipe::SendRtcp(const uint8_t* packet, size_t length) { RTC_DCHECK(HasTransport()); - EnqueuePacket(rtc::CopyOnWriteBuffer(packet, length), rtc::nullopt, true, - MediaType::ANY, rtc::nullopt); + EnqueuePacket(rtc::CopyOnWriteBuffer(packet, length), absl::nullopt, true, + MediaType::ANY, absl::nullopt); return true; } @@ -130,7 +130,7 @@ PacketReceiver::DeliveryStatus FakeNetworkPipe::DeliverPacket( MediaType media_type, rtc::CopyOnWriteBuffer packet, const PacketTime& packet_time) { - return EnqueuePacket(std::move(packet), rtc::nullopt, false, media_type, + return EnqueuePacket(std::move(packet), absl::nullopt, false, media_type, packet_time) ? PacketReceiver::DELIVERY_OK : PacketReceiver::DELIVERY_PACKET_ERROR; @@ -213,20 +213,20 @@ bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { return true; } -rtc::Optional SimulatedNetwork::NextDeliveryTimeUs() const { +absl::optional SimulatedNetwork::NextDeliveryTimeUs() const { if (!delay_link_.empty()) return delay_link_.begin()->arrival_time_us; - return rtc::nullopt; + return absl::nullopt; } FakeNetworkPipe::StoredPacket::StoredPacket(NetworkPacket&& packet) : packet(std::move(packet)) {} bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, - rtc::Optional options, + absl::optional options, bool is_rtcp, MediaType media_type, - rtc::Optional packet_time) { + absl::optional packet_time) { int64_t time_now_us = clock_->TimeInMicroseconds(); rtc::CritScope crit(&process_lock_); size_t packet_size = packet.size(); @@ -413,7 +413,7 @@ void FakeNetworkPipe::Process() { packets_to_deliver.pop(); DeliverPacket(&packet); } - rtc::Optional delivery_us = + absl::optional delivery_us = network_simulation_->NextDeliveryTimeUs(); next_process_time_us_ = delivery_us ? *delivery_us diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 799970b987..c587973c71 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -40,10 +40,10 @@ class NetworkPacket { NetworkPacket(rtc::CopyOnWriteBuffer packet, int64_t send_time, int64_t arrival_time, - rtc::Optional packet_options, + absl::optional packet_options, bool is_rtcp, MediaType media_type_, - rtc::Optional packet_time_); + absl::optional packet_time_); // Disallow copy constructor and copy assignment (no deep copies of |data_|). NetworkPacket(const NetworkPacket&) = delete; NetworkPacket& operator=(const NetworkPacket&) = delete; @@ -74,14 +74,14 @@ class NetworkPacket { int64_t arrival_time_; // If using a Transport for outgoing degradation, populate with // PacketOptions (transport-wide sequence number) for RTP. - rtc::Optional packet_options_; + absl::optional packet_options_; bool is_rtcp_; // If using a PacketReceiver for incoming degradation, populate with // appropriate MediaType and PacketTime. This type/timing will be kept and // forwarded. The PacketTime might be altered to reflect time spent in fake // network pipe. MediaType media_type_; - rtc::Optional packet_time_; + absl::optional packet_time_; }; struct PacketInFlightInfo { @@ -108,7 +108,7 @@ class NetworkSimulationInterface { // Retrieves all packets that should be delivered by the given receive time. virtual std::vector DequeueDeliverablePackets( int64_t receive_time_us) = 0; - virtual rtc::Optional NextDeliveryTimeUs() const = 0; + virtual absl::optional NextDeliveryTimeUs() const = 0; virtual ~NetworkSimulationInterface() = default; }; @@ -144,7 +144,7 @@ class SimulatedNetwork : public NetworkSimulationInterface { std::vector DequeueDeliverablePackets( int64_t receive_time_us) override; - rtc::Optional NextDeliveryTimeUs() const override; + absl::optional NextDeliveryTimeUs() const override; private: struct PacketInfo { @@ -260,10 +260,10 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { // Returns true if enqueued, or false if packet was dropped. virtual bool EnqueuePacket(rtc::CopyOnWriteBuffer packet, - rtc::Optional options, - bool is_rtcp, - MediaType media_type, - rtc::Optional packet_time); + absl::optional options, + bool is_rtcp, + MediaType media_type, + absl::optional packet_time); void DeliverPacket(NetworkPacket* packet) RTC_EXCLUSIVE_LOCKS_REQUIRED(config_lock_); bool HasTransport() const; diff --git a/call/receive_time_calculator.h b/call/receive_time_calculator.h index b2dc00375d..a8217cd101 100644 --- a/call/receive_time_calculator.h +++ b/call/receive_time_calculator.h @@ -13,7 +13,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -39,7 +39,7 @@ class ReceiveTimeCalculator { private: const int64_t min_delta_us_; const int64_t max_delta_diff_us_; - rtc::Optional receive_time_offset_us_; + absl::optional receive_time_offset_us_; int64_t last_packet_time_us_ = 0; int64_t last_safe_time_us_ = 0; }; diff --git a/call/rtcp_demuxer.cc b/call/rtcp_demuxer.cc index 0e78ddea18..40c9163203 100644 --- a/call/rtcp_demuxer.cc +++ b/call/rtcp_demuxer.cc @@ -66,7 +66,7 @@ void RtcpDemuxer::RemoveBroadcastSink(const RtcpPacketSinkInterface* sink) { void RtcpDemuxer::OnRtcpPacket(rtc::ArrayView packet) { // Perform sender-SSRC-based demuxing for packets with a sender-SSRC. - rtc::Optional sender_ssrc = ParseRtcpPacketSenderSsrc(packet); + absl::optional sender_ssrc = ParseRtcpPacketSenderSsrc(packet); if (sender_ssrc) { auto it_range = ssrc_sinks_.equal_range(*sender_ssrc); for (auto it = it_range.first; it != it_range.second; ++it) { diff --git a/call/rtp_bitrate_configurator.cc b/call/rtp_bitrate_configurator.cc index b3bc183816..fafd8ec997 100644 --- a/call/rtp_bitrate_configurator.cc +++ b/call/rtp_bitrate_configurator.cc @@ -33,7 +33,7 @@ BitrateConstraints RtpBitrateConfigurator::GetConfig() const { return bitrate_config_; } -rtc::Optional +absl::optional RtpBitrateConfigurator::UpdateWithSdpParameters( const BitrateConstraints& bitrate_config) { RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); @@ -42,7 +42,7 @@ RtpBitrateConfigurator::UpdateWithSdpParameters( RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0); } - rtc::Optional new_start; + absl::optional new_start; // Only update the "start" bitrate if it's set, and different from the old // value. In practice, this value comes from the x-google-start-bitrate codec // parameter in SDP, and setting the same remote description twice shouldn't @@ -56,15 +56,15 @@ RtpBitrateConfigurator::UpdateWithSdpParameters( return UpdateConstraints(new_start); } -rtc::Optional +absl::optional RtpBitrateConfigurator::UpdateWithClientPreferences( const BitrateSettings& bitrate_mask) { bitrate_config_mask_ = bitrate_mask; return UpdateConstraints(bitrate_mask.start_bitrate_bps); } -rtc::Optional RtpBitrateConfigurator::UpdateConstraints( - const rtc::Optional& new_start) { +absl::optional RtpBitrateConfigurator::UpdateConstraints( + const absl::optional& new_start) { BitrateConstraints updated; updated.min_bitrate_bps = std::max(bitrate_config_mask_.min_bitrate_bps.value_or(0), @@ -86,7 +86,7 @@ rtc::Optional RtpBitrateConfigurator::UpdateConstraints( if (updated.min_bitrate_bps == bitrate_config_.min_bitrate_bps && updated.max_bitrate_bps == bitrate_config_.max_bitrate_bps && !new_start) { - return rtc::nullopt; + return absl::nullopt; } if (new_start) { diff --git a/call/rtp_bitrate_configurator.h b/call/rtp_bitrate_configurator.h index 14f312bbb4..a311774ecf 100644 --- a/call/rtp_bitrate_configurator.h +++ b/call/rtp_bitrate_configurator.h @@ -32,7 +32,7 @@ class RtpBitrateConfigurator { // implemented. Passing -1 leaves the start bitrate unchanged. Behavior is not // guaranteed for other negative values or 0. // The optional return value is set with new configuration if it was updated. - rtc::Optional UpdateWithSdpParameters( + absl::optional UpdateWithSdpParameters( const BitrateConstraints& bitrate_config_); // The greater min and smaller max set by this and SetSdpBitrateParameters @@ -41,14 +41,14 @@ class RtpBitrateConfigurator { // Assumes 0 <= min <= start <= max holds for set parameters. // Update the bitrate configuration // The optional return value is set with new configuration if it was updated. - rtc::Optional UpdateWithClientPreferences( + absl::optional UpdateWithClientPreferences( const BitrateSettings& bitrate_mask); private: // Applies update to the BitrateConstraints cached in |config_|, resetting // with |new_start| if set. - rtc::Optional UpdateConstraints( - const rtc::Optional& new_start); + absl::optional UpdateConstraints( + const absl::optional& new_start); // Bitrate config used until valid bitrate estimates are calculated. Also // used to cap total bitrate used. This comes from the remote connection. diff --git a/call/rtp_bitrate_configurator_unittest.cc b/call/rtp_bitrate_configurator_unittest.cc index d5eed23d3d..b177db7a8f 100644 --- a/call/rtp_bitrate_configurator_unittest.cc +++ b/call/rtp_bitrate_configurator_unittest.cc @@ -13,7 +13,7 @@ #include "test/gtest.h" namespace webrtc { -using rtc::nullopt; +using absl::nullopt; class RtpBitrateConfiguratorTest : public testing::Test { public: @@ -21,10 +21,10 @@ class RtpBitrateConfiguratorTest : public testing::Test { : configurator_(new RtpBitrateConfigurator(BitrateConstraints())) {} std::unique_ptr configurator_; void UpdateConfigMatches(BitrateConstraints bitrate_config, - rtc::Optional min_bitrate_bps, - rtc::Optional start_bitrate_bps, - rtc::Optional max_bitrate_bps) { - rtc::Optional result = + absl::optional min_bitrate_bps, + absl::optional start_bitrate_bps, + absl::optional max_bitrate_bps) { + absl::optional result = configurator_->UpdateWithSdpParameters(bitrate_config); EXPECT_TRUE(result.has_value()); if (start_bitrate_bps.has_value()) @@ -36,10 +36,10 @@ class RtpBitrateConfiguratorTest : public testing::Test { } void UpdateMaskMatches(BitrateSettings bitrate_mask, - rtc::Optional min_bitrate_bps, - rtc::Optional start_bitrate_bps, - rtc::Optional max_bitrate_bps) { - rtc::Optional result = + absl::optional min_bitrate_bps, + absl::optional start_bitrate_bps, + absl::optional max_bitrate_bps) { + absl::optional result = configurator_->UpdateWithClientPreferences(bitrate_mask); EXPECT_TRUE(result.has_value()); if (start_bitrate_bps.has_value()) diff --git a/call/rtp_rtcp_demuxer_helper.cc b/call/rtp_rtcp_demuxer_helper.cc index deabe73842..125169b077 100644 --- a/call/rtp_rtcp_demuxer_helper.cc +++ b/call/rtp_rtcp_demuxer_helper.cc @@ -21,13 +21,13 @@ namespace webrtc { -rtc::Optional ParseRtcpPacketSenderSsrc( +absl::optional ParseRtcpPacketSenderSsrc( rtc::ArrayView packet) { rtcp::CommonHeader header; for (const uint8_t* next_packet = packet.begin(); next_packet < packet.end(); next_packet = header.NextPacket()) { if (!header.Parse(next_packet, packet.end() - next_packet)) { - return rtc::nullopt; + return absl::nullopt; } switch (header.type()) { @@ -43,13 +43,13 @@ rtc::Optional ParseRtcpPacketSenderSsrc( ByteReader::ReadBigEndian(header.payload()); return ssrc_sender; } else { - return rtc::nullopt; + return absl::nullopt; } } } } - return rtc::nullopt; + return absl::nullopt; } } // namespace webrtc diff --git a/call/rtp_rtcp_demuxer_helper.h b/call/rtp_rtcp_demuxer_helper.h index fef7255c8a..4b66713538 100644 --- a/call/rtp_rtcp_demuxer_helper.h +++ b/call/rtp_rtcp_demuxer_helper.h @@ -15,8 +15,8 @@ #include #include +#include "absl/types/optional.h" #include "api/array_view.h" -#include "api/optional.h" namespace webrtc { @@ -89,7 +89,7 @@ bool MultimapHasKey(const Container& c, return it_range.first != it_range.second; } -rtc::Optional ParseRtcpPacketSenderSsrc( +absl::optional ParseRtcpPacketSenderSsrc( rtc::ArrayView packet); } // namespace webrtc diff --git a/call/rtp_rtcp_demuxer_helper_unittest.cc b/call/rtp_rtcp_demuxer_helper_unittest.cc index 5fe827494b..9f378864a1 100644 --- a/call/rtp_rtcp_demuxer_helper_unittest.cc +++ b/call/rtp_rtcp_demuxer_helper_unittest.cc @@ -34,7 +34,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ByePacket) { rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -44,7 +44,7 @@ TEST(RtpRtcpDemuxerHelperTest, rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -53,7 +53,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_PsfbPacket) { rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -62,7 +62,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ReceiverReportPacket) { rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -72,7 +72,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_RtpfbPacket) { rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -81,7 +81,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_SenderReportPacket) { rtcp_packet.SetSenderSsrc(kSsrc); rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_EQ(ssrc, kSsrc); } @@ -89,7 +89,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_MalformedRtcpPacket) { uint8_t garbage[100]; memset(&garbage[0], 0, arraysize(garbage)); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(garbage); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(garbage); EXPECT_FALSE(ssrc); } @@ -98,7 +98,7 @@ TEST(RtpRtcpDemuxerHelperTest, webrtc::rtcp::ExtendedJitterReport rtcp_packet; // Has no sender SSRC. rtc::Buffer raw_packet = rtcp_packet.Build(); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); + absl::optional ssrc = ParseRtcpPacketSenderSsrc(raw_packet); EXPECT_FALSE(ssrc); } @@ -110,7 +110,7 @@ TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_TruncatedRtcpMessage) { constexpr size_t rtcp_length_bytes = 8; ASSERT_EQ(rtcp_length_bytes, raw_packet.size()); - rtc::Optional ssrc = ParseRtcpPacketSenderSsrc( + absl::optional ssrc = ParseRtcpPacketSenderSsrc( rtc::ArrayView(raw_packet.data(), rtcp_length_bytes - 1)); EXPECT_FALSE(ssrc); } diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 76ba7f654f..a0e47b5dc1 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -237,7 +237,7 @@ void RtpTransportControllerSend::OnSentPacket( void RtpTransportControllerSend::SetSdpBitrateParameters( const BitrateConstraints& constraints) { - rtc::Optional updated = + absl::optional updated = bitrate_configurator_.UpdateWithSdpParameters(constraints); if (updated.has_value()) { send_side_cc_->SetBweBitrates(updated->min_bitrate_bps, @@ -252,7 +252,7 @@ void RtpTransportControllerSend::SetSdpBitrateParameters( void RtpTransportControllerSend::SetClientBitratePreferences( const BitrateSettings& preferences) { - rtc::Optional updated = + absl::optional updated = bitrate_configurator_.UpdateWithClientPreferences(preferences); if (updated.has_value()) { send_side_cc_->SetBweBitrates(updated->min_bitrate_bps, diff --git a/call/rtp_transport_controller_send_interface.h b/call/rtp_transport_controller_send_interface.h index ad3aa2b75d..0269b13ad4 100644 --- a/call/rtp_transport_controller_send_interface.h +++ b/call/rtp_transport_controller_send_interface.h @@ -15,7 +15,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/transport/bitrate_settings.h" #include "call/bitrate_constraints.h" diff --git a/call/syncable.h b/call/syncable.h index a97990b2be..a914793d78 100644 --- a/call/syncable.h +++ b/call/syncable.h @@ -16,7 +16,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -34,7 +34,7 @@ class Syncable { virtual ~Syncable(); virtual int id() const = 0; - virtual rtc::Optional GetInfo() const = 0; + virtual absl::optional GetInfo() const = 0; virtual uint32_t GetPlayoutTimestamp() const = 0; virtual void SetMinimumPlayoutDelay(int delay_ms) = 0; }; diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 3f017968e4..a5cd11a837 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -82,7 +82,7 @@ class VideoReceiveStream { int render_delay_ms = 10; int64_t interframe_delay_max_ms = -1; uint32_t frames_decoded = 0; - rtc::Optional qp_sum; + absl::optional qp_sum; int current_payload_type = -1; @@ -104,7 +104,7 @@ class VideoReceiveStream { // Timing frame info: all important timestamps for a full lifetime of a // single 'timing frame'. - rtc::Optional timing_frame_info; + absl::optional timing_frame_info; }; struct Config { diff --git a/call/video_send_stream.h b/call/video_send_stream.h index d5be08637b..b5bd199410 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -68,7 +68,7 @@ class VideoSendStream { uint32_t frames_dropped_by_encoder_queue = 0; uint32_t frames_dropped_by_rate_limiter = 0; uint32_t frames_dropped_by_encoder = 0; - rtc::Optional qp_sum; + absl::optional qp_sum; // Bitrate the encoder is currently configured to use due to bandwidth // limitations. int target_media_bitrate_bps = 0; diff --git a/video/BUILD.gn b/video/BUILD.gn index f56a71dd6d..df50d90687 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -62,7 +62,6 @@ rtc_static_library("video") { "../:typedefs", "../api:fec_controller_api", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/video:video_frame", "../api/video:video_frame_i420", @@ -84,6 +83,7 @@ rtc_static_library("video") { "../rtc_base/system:fallthrough", "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", + "//third_party/abseil-cpp/absl/types:optional", # For RtxReceiveStream. "../call:rtp_receiver", @@ -121,7 +121,6 @@ rtc_source_set("video_stream_decoder_impl") { ] deps = [ - "../api:optional", "../api/video:encoded_frame", "../api/video:video_frame", "../api/video:video_stream_decoder", @@ -130,6 +129,7 @@ rtc_source_set("video_stream_decoder_impl") { "../rtc_base:rtc_base_approved", "../rtc_base:rtc_task_queue_api", "../system_wrappers:system_wrappers", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -364,7 +364,6 @@ if (rtc_include_tests) { deps = [ ":video", ":video_mocks", - "../api:optional", "../api/video:video_frame", "../api/video:video_frame_i420", "../api/video_codecs:video_codecs_api", @@ -417,6 +416,7 @@ if (rtc_include_tests) { "../test:test_support", "../test:video_test_common", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] if (!build_with_chromium && is_clang) { # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). diff --git a/video/end_to_end_tests/call_operation_tests.cc b/video/end_to_end_tests/call_operation_tests.cc index ed06aa887d..2c45665535 100644 --- a/video/end_to_end_tests/call_operation_tests.cc +++ b/video/end_to_end_tests/call_operation_tests.cc @@ -134,7 +134,7 @@ TEST_P(CallOperationEndToEndTest, RendersSingleDelayedFrame) { // to check that the callbacks are done after processing video. std::unique_ptr frame_generator( test::FrameGenerator::CreateSquareGenerator( - kWidth, kHeight, rtc::nullopt, rtc::nullopt)); + kWidth, kHeight, absl::nullopt, absl::nullopt)); video_send_stream_->SetSource(&frame_forwarder, DegradationPreference::MAINTAIN_FRAMERATE); @@ -190,7 +190,7 @@ TEST_P(CallOperationEndToEndTest, TransmitsFirstFrame) { Start(); frame_generator = test::FrameGenerator::CreateSquareGenerator( - kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt); + kDefaultWidth, kDefaultHeight, absl::nullopt, absl::nullopt); video_send_stream_->SetSource(&frame_forwarder, DegradationPreference::MAINTAIN_FRAMERATE); frame_forwarder.IncomingCapturedFrame(*frame_generator->NextFrame()); @@ -268,7 +268,7 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) { Start(); frame_generator = test::FrameGenerator::CreateSquareGenerator( - kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt); + kDefaultWidth, kDefaultHeight, absl::nullopt, absl::nullopt); video_send_stream_->SetSource(&forwarder, DegradationPreference::MAINTAIN_FRAMERATE); forwarder.IncomingCapturedFrame(*frame_generator->NextFrame()); diff --git a/video/end_to_end_tests/histogram_tests.cc b/video/end_to_end_tests/histogram_tests.cc index c3a86b47f9..04255a826c 100644 --- a/video/end_to_end_tests/histogram_tests.cc +++ b/video/end_to_end_tests/histogram_tests.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics_default.h" @@ -123,7 +123,7 @@ void HistogramTest::VerifyHistogramStats(bool use_rtx, const bool use_fec_; const bool screenshare_; test::FunctionVideoEncoderFactory encoder_factory_; - rtc::Optional start_runtime_ms_; + absl::optional start_runtime_ms_; int num_frames_received_ RTC_GUARDED_BY(&crit_); } test(use_rtx, use_fec, screenshare); diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc index 5afb1471d5..ffbf8fba0f 100644 --- a/video/end_to_end_tests/multi_codec_receive_tests.cc +++ b/video/end_to_end_tests/multi_codec_receive_tests.cc @@ -132,8 +132,8 @@ class FrameObserver : public test::RtpRtcpObserver, } rtc::CriticalSection crit_; - rtc::Optional last_timestamp_; - rtc::Optional last_payload_type_; + absl::optional last_timestamp_; + absl::optional last_payload_type_; int num_sent_frames_ RTC_GUARDED_BY(crit_) = 0; int num_rendered_frames_ RTC_GUARDED_BY(crit_) = 0; std::vector sent_timestamps_ RTC_GUARDED_BY(crit_); diff --git a/video/end_to_end_tests/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc index 4ed3af610e..92fa938832 100644 --- a/video/end_to_end_tests/multi_stream_tester.cc +++ b/video/end_to_end_tests/multi_stream_tester.cc @@ -99,7 +99,7 @@ void MultiStreamTester::RunTest() { receive_streams[i]->Start(); frame_generators[i] = test::FrameGeneratorCapturer::Create( - width, height, rtc::nullopt, rtc::nullopt, 30, + width, height, absl::nullopt, absl::nullopt, 30, Clock::GetRealTimeClock()); send_streams[i]->SetSource(frame_generators[i], DegradationPreference::MAINTAIN_FRAMERATE); diff --git a/video/end_to_end_tests/retransmission_tests.cc b/video/end_to_end_tests/retransmission_tests.cc index 425c0c279a..fc0914171a 100644 --- a/video/end_to_end_tests/retransmission_tests.cc +++ b/video/end_to_end_tests/retransmission_tests.cc @@ -190,7 +190,7 @@ TEST_P(RetransmissionEndToEndTest, ReceivesNackAndRetransmitsAudio) { uint32_t local_ssrc_; uint32_t remote_ssrc_; Transport* receive_transport_; - rtc::Optional sequence_number_to_retransmit_; + absl::optional sequence_number_to_retransmit_; } test; RunBaseTest(&test); diff --git a/video/end_to_end_tests/rtp_rtcp_tests.cc b/video/end_to_end_tests/rtp_rtcp_tests.cc index 53172420e1..1c953acca2 100644 --- a/video/end_to_end_tests/rtp_rtcp_tests.cc +++ b/video/end_to_end_tests/rtp_rtcp_tests.cc @@ -453,9 +453,9 @@ TEST_F(RtpRtcpEndToEndTest, TestFlexfecRtpStatePreservation) { return SEND_PACKET; } - rtc::Optional last_observed_sequence_number_ + absl::optional last_observed_sequence_number_ RTC_GUARDED_BY(crit_); - rtc::Optional last_observed_timestamp_ RTC_GUARDED_BY(crit_); + absl::optional last_observed_timestamp_ RTC_GUARDED_BY(crit_); size_t num_flexfec_packets_sent_ RTC_GUARDED_BY(crit_); rtc::CriticalSection crit_; } observer; diff --git a/video/overuse_frame_detector.cc b/video/overuse_frame_detector.cc index 4bccdf3cbd..0c56be80a9 100644 --- a/video/overuse_frame_detector.cc +++ b/video/overuse_frame_detector.cc @@ -110,12 +110,12 @@ class SendProcessingUsage1 : public OveruseFrameDetector::ProcessingUsage { time_when_first_seen_us)); } - rtc::Optional FrameSent( + absl::optional FrameSent( uint32_t timestamp, int64_t time_sent_in_us, int64_t /* capture_time_us */, - rtc::Optional /* encode_duration_us */) override { - rtc::Optional encode_duration_us; + absl::optional /* encode_duration_us */) override { + absl::optional encode_duration_us; // Delay before reporting actual encoding time, used to have the ability to // detect total encoding time when encoding more than one layer. Encoding is // here assumed to finish within a second (or that we get enough long-time @@ -241,10 +241,11 @@ class SendProcessingUsage2 : public OveruseFrameDetector::ProcessingUsage { int64_t time_when_first_seen_us, int64_t last_capture_time_us) override {} - rtc::Optional FrameSent(uint32_t timestamp, - int64_t time_sent_in_us, - int64_t capture_time_us, - rtc::Optional encode_duration_us) override { + absl::optional FrameSent( + uint32_t timestamp, + int64_t time_sent_in_us, + int64_t capture_time_us, + absl::optional encode_duration_us) override { if (encode_duration_us) { if (prev_time_us_ != -1) { AddSample(1e-6 * (*encode_duration_us), @@ -321,13 +322,13 @@ class OverdoseInjector : public OveruseFrameDetector::ProcessingUsage { usage_->FrameCaptured(frame, time_when_first_seen_us, last_capture_time_us); } - rtc::Optional FrameSent( + absl::optional FrameSent( // These two argument used by old estimator. uint32_t timestamp, int64_t time_sent_in_us, // And these two by the new estimator. int64_t capture_time_us, - rtc::Optional encode_duration_us) override { + absl::optional encode_duration_us) override { return usage_->FrameSent(timestamp, time_sent_in_us, capture_time_us, encode_duration_us); } @@ -362,7 +363,7 @@ class OverdoseInjector : public OveruseFrameDetector::ProcessingUsage { } } - rtc::Optional overried_usage_value; + absl::optional overried_usage_value; switch (state_) { case State::kNormal: break; @@ -514,7 +515,7 @@ OveruseFrameDetector::OveruseFrameDetector( : check_overuse_task_(nullptr), metrics_observer_(metrics_observer), num_process_times_(0), - // TODO(nisse): Use rtc::Optional + // TODO(nisse): Use absl::optional last_capture_time_us_(-1), num_pixels_(0), max_framerate_(kDefaultFrameRate), @@ -582,7 +583,7 @@ void OveruseFrameDetector::ResetAll(int num_pixels) { usage_->Reset(); last_capture_time_us_ = -1; num_process_times_ = 0; - metrics_ = rtc::nullopt; + metrics_ = absl::nullopt; OnTargetFramerateUpdated(max_framerate_); } @@ -610,7 +611,7 @@ void OveruseFrameDetector::FrameCaptured(const VideoFrame& frame, void OveruseFrameDetector::FrameSent(uint32_t timestamp, int64_t time_sent_in_us, int64_t capture_time_us, - rtc::Optional encode_duration_us) { + absl::optional encode_duration_us) { RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); encode_duration_us = usage_->FrameSent(timestamp, time_sent_in_us, capture_time_us, encode_duration_us); diff --git a/video/overuse_frame_detector.h b/video/overuse_frame_detector.h index 3525a976ab..800e53f3a3 100644 --- a/video/overuse_frame_detector.h +++ b/video/overuse_frame_detector.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/video_coding/utility/quality_scaler.h" #include "rtc_base/constructormagic.h" #include "rtc_base/numerics/exp_filter.h" @@ -90,7 +90,7 @@ class OveruseFrameDetector { void FrameSent(uint32_t timestamp, int64_t time_sent_in_us, int64_t capture_time_us, - rtc::Optional encode_duration_us); + absl::optional encode_duration_us); // Interface for cpu load estimation. Intended for internal use only. class ProcessingUsage { @@ -101,13 +101,13 @@ class OveruseFrameDetector { int64_t time_when_first_seen_us, int64_t last_capture_time_us) = 0; // Returns encode_time in us, if there's a new measurement. - virtual rtc::Optional FrameSent( + virtual absl::optional FrameSent( // These two argument used by old estimator. uint32_t timestamp, int64_t time_sent_in_us, // And these two by the new estimator. int64_t capture_time_us, - rtc::Optional encode_duration_us) = 0; + absl::optional encode_duration_us) = 0; virtual int Value() = 0; virtual ~ProcessingUsage() = default; @@ -141,7 +141,7 @@ class OveruseFrameDetector { // Stats metrics. CpuOveruseMetricsObserver* const metrics_observer_; - rtc::Optional metrics_ RTC_GUARDED_BY(task_checker_); + absl::optional metrics_ RTC_GUARDED_BY(task_checker_); int64_t num_process_times_ RTC_GUARDED_BY(task_checker_); diff --git a/video/overuse_frame_detector_unittest.cc b/video/overuse_frame_detector_unittest.cc index 487b36f36a..bce5642c18 100644 --- a/video/overuse_frame_detector_unittest.cc +++ b/video/overuse_frame_detector_unittest.cc @@ -127,7 +127,7 @@ class OveruseFrameDetectorTest : public ::testing::Test, clock_.AdvanceTimeMicros(delay_us); overuse_detector_->FrameSent(timestamp, rtc::TimeMicros(), capture_time_us, - rtc::Optional(delay_us)); + absl::optional(delay_us)); overuse_detector_->CheckForOveruse(observer_); // Avoid turning clock backwards. diff --git a/video/quality_threshold.cc b/video/quality_threshold.cc index fc8787a3ff..2b2999280c 100644 --- a/video/quality_threshold.cc +++ b/video/quality_threshold.cc @@ -74,13 +74,13 @@ void QualityThreshold::AddMeasurement(int measurement) { } } -rtc::Optional QualityThreshold::IsHigh() const { +absl::optional QualityThreshold::IsHigh() const { return is_high_; } -rtc::Optional QualityThreshold::CalculateVariance() const { +absl::optional QualityThreshold::CalculateVariance() const { if (until_full_ > 0) { - return rtc::nullopt; + return absl::nullopt; } double variance = 0; @@ -91,11 +91,11 @@ rtc::Optional QualityThreshold::CalculateVariance() const { return variance / (max_measurements_ - 1); } -rtc::Optional QualityThreshold::FractionHigh( +absl::optional QualityThreshold::FractionHigh( int min_required_samples) const { RTC_DCHECK_GT(min_required_samples, 0); if (num_certain_states_ < min_required_samples) - return rtc::nullopt; + return absl::nullopt; return static_cast(num_high_states_) / num_certain_states_; } diff --git a/video/quality_threshold.h b/video/quality_threshold.h index 519e2c33de..4fad555ce6 100644 --- a/video/quality_threshold.h +++ b/video/quality_threshold.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -27,9 +27,9 @@ class QualityThreshold { int max_measurements); void AddMeasurement(int measurement); - rtc::Optional IsHigh() const; - rtc::Optional CalculateVariance() const; - rtc::Optional FractionHigh(int min_required_samples) const; + absl::optional IsHigh() const; + absl::optional CalculateVariance() const; + absl::optional FractionHigh(int min_required_samples) const; private: const std::unique_ptr buffer_; @@ -39,7 +39,7 @@ class QualityThreshold { const int high_threshold_; int until_full_; int next_index_; - rtc::Optional is_high_; + absl::optional is_high_; int sum_; int count_low_; int count_high_; diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 0fe366aa77..53903cf306 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -209,7 +209,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { round(render_pixel_tracker_.ComputeTotalRate())); } - rtc::Optional sync_offset_ms = + absl::optional sync_offset_ms = sync_offset_counter_.Avg(kMinRequiredSamples); if (sync_offset_ms) { RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.AVSyncOffsetInMs", @@ -236,17 +236,17 @@ void ReceiveStatisticsProxy::UpdateHistograms() { << key_frames_permille << '\n'; } - rtc::Optional qp = qp_counters_.vp8.Avg(kMinRequiredSamples); + absl::optional qp = qp_counters_.vp8.Avg(kMinRequiredSamples); if (qp) { RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", *qp); log_stream << "WebRTC.Video.Decoded.Vp8.Qp " << *qp << '\n'; } - rtc::Optional decode_ms = decode_time_counter_.Avg(kMinRequiredSamples); + absl::optional decode_ms = decode_time_counter_.Avg(kMinRequiredSamples); if (decode_ms) { RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", *decode_ms); log_stream << "WebRTC.Video.DecodeTimeInMs " << *decode_ms << '\n'; } - rtc::Optional jb_delay_ms = + absl::optional jb_delay_ms = jitter_buffer_delay_counter_.Avg(kMinRequiredSamples); if (jb_delay_ms) { RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", @@ -254,21 +254,21 @@ void ReceiveStatisticsProxy::UpdateHistograms() { log_stream << "WebRTC.Video.JitterBufferDelayInMs " << *jb_delay_ms << '\n'; } - rtc::Optional target_delay_ms = + absl::optional target_delay_ms = target_delay_counter_.Avg(kMinRequiredSamples); if (target_delay_ms) { RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", *target_delay_ms); log_stream << "WebRTC.Video.TargetDelayInMs " << *target_delay_ms << '\n'; } - rtc::Optional current_delay_ms = + absl::optional current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples); if (current_delay_ms) { RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", *current_delay_ms); log_stream << "WebRTC.Video.CurrentDelayInMs " << *current_delay_ms << '\n'; } - rtc::Optional delay_ms = delay_counter_.Avg(kMinRequiredSamples); + absl::optional delay_ms = delay_counter_.Avg(kMinRequiredSamples); if (delay_ms) RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", *delay_ms); @@ -314,7 +314,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { RTC_DCHECK(videocontenttypehelpers::GetExperimentId(content_type) == 0 || videocontenttypehelpers::GetSimulcastId(content_type) == 0); - rtc::Optional e2e_delay_ms = + absl::optional e2e_delay_ms = stats.e2e_delay_counter.Avg(kMinRequiredSamples); if (e2e_delay_ms) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( @@ -322,14 +322,14 @@ void ReceiveStatisticsProxy::UpdateHistograms() { log_stream << uma_prefix << ".EndToEndDelayInMs" << uma_suffix << " " << *e2e_delay_ms << '\n'; } - rtc::Optional e2e_delay_max_ms = stats.e2e_delay_counter.Max(); + absl::optional e2e_delay_max_ms = stats.e2e_delay_counter.Max(); if (e2e_delay_max_ms && e2e_delay_ms) { RTC_HISTOGRAM_COUNTS_SPARSE_100000( uma_prefix + ".EndToEndDelayMaxInMs" + uma_suffix, *e2e_delay_max_ms); log_stream << uma_prefix << ".EndToEndDelayMaxInMs" << uma_suffix << " " << *e2e_delay_max_ms << '\n'; } - rtc::Optional interframe_delay_ms = + absl::optional interframe_delay_ms = stats.interframe_delay_counter.Avg(kMinRequiredSamples); if (interframe_delay_ms) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( @@ -338,7 +338,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { log_stream << uma_prefix << ".InterframeDelayInMs" << uma_suffix << " " << *interframe_delay_ms << '\n'; } - rtc::Optional interframe_delay_max_ms = + absl::optional interframe_delay_max_ms = stats.interframe_delay_counter.Max(); if (interframe_delay_max_ms && interframe_delay_ms) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( @@ -348,7 +348,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { << *interframe_delay_max_ms << '\n'; } - rtc::Optional interframe_delay_95p_ms = + absl::optional interframe_delay_95p_ms = stats.interframe_delay_percentiles.GetPercentile(0.95f); if (interframe_delay_95p_ms && interframe_delay_ms != -1) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( @@ -358,7 +358,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { << uma_suffix << " " << *interframe_delay_95p_ms << '\n'; } - rtc::Optional width = stats.received_width.Avg(kMinRequiredSamples); + absl::optional width = stats.received_width.Avg(kMinRequiredSamples); if (width) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( uma_prefix + ".ReceivedWidthInPixels" + uma_suffix, *width); @@ -366,7 +366,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { << *width << '\n'; } - rtc::Optional height = stats.received_height.Avg(kMinRequiredSamples); + absl::optional height = stats.received_height.Avg(kMinRequiredSamples); if (height) { RTC_HISTOGRAM_COUNTS_SPARSE_10000( uma_prefix + ".ReceivedHeightInPixels" + uma_suffix, *height); @@ -401,7 +401,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() { << " " << key_frames_permille << '\n'; } - rtc::Optional qp = stats.qp_counter.Avg(kMinRequiredSamples); + absl::optional qp = stats.qp_counter.Avg(kMinRequiredSamples); if (qp) { RTC_HISTOGRAM_COUNTS_SPARSE_200( uma_prefix + ".Decoded.Vp8.Qp" + uma_suffix, *qp); @@ -465,19 +465,19 @@ void ReceiveStatisticsProxy::UpdateHistograms() { RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.Any", 100 * num_bad_states_ / num_certain_states_); } - rtc::Optional fps_fraction = + absl::optional fps_fraction = fps_threshold_.FractionHigh(kBadCallMinRequiredSamples); if (fps_fraction) { RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.FrameRate", static_cast(100 * (1 - *fps_fraction))); } - rtc::Optional variance_fraction = + absl::optional variance_fraction = variance_threshold_.FractionHigh(kBadCallMinRequiredSamples); if (variance_fraction) { RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.FrameRateVariance", static_cast(100 * *variance_fraction)); } - rtc::Optional qp_fraction = + absl::optional qp_fraction = qp_threshold_.FractionHigh(kBadCallMinRequiredSamples); if (qp_fraction) { RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.Qp", @@ -496,7 +496,7 @@ void ReceiveStatisticsProxy::QualitySample() { double fps = render_fps_tracker_.ComputeRateForInterval(now - last_sample_time_); - rtc::Optional qp = qp_sample_.Avg(1); + absl::optional qp = qp_sample_.Avg(1); bool prev_fps_bad = !fps_threshold_.IsHigh().value_or(true); bool prev_qp_bad = qp_threshold_.IsHigh().value_or(false); @@ -506,7 +506,7 @@ void ReceiveStatisticsProxy::QualitySample() { fps_threshold_.AddMeasurement(static_cast(fps)); if (qp) qp_threshold_.AddMeasurement(*qp); - rtc::Optional fps_variance_opt = fps_threshold_.CalculateVariance(); + absl::optional fps_variance_opt = fps_threshold_.CalculateVariance(); double fps_variance = fps_variance_opt.value_or(0); if (fps_variance_opt) { variance_threshold_.AddMeasurement(static_cast(fps_variance)); @@ -699,7 +699,7 @@ void ReceiveStatisticsProxy::DataCountersUpdated( total_byte_tracker_.AddSamples(total_bytes - last_total_bytes); } -void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional qp, +void ReceiveStatisticsProxy::OnDecodedFrame(absl::optional qp, int width, int height, VideoContentType content_type) { @@ -734,7 +734,7 @@ void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional 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::nullopt; + stats_.qp_sum = absl::nullopt; } last_content_type_ = content_type; decode_fps_estimator_.Update(1, now); diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h index 1ec0039904..2ccfc938d1 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h @@ -16,7 +16,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "call/video_receive_stream.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/include/frame_callback.h" @@ -52,7 +52,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, VideoReceiveStream::Stats GetStats() const; - void OnDecodedFrame(rtc::Optional qp, + void OnDecodedFrame(absl::optional qp, int width, int height, VideoContentType content_type); @@ -183,15 +183,15 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, mutable std::map frame_window_ RTC_GUARDED_BY(&crit_); VideoContentType last_content_type_ RTC_GUARDED_BY(&crit_); VideoCodecType last_codec_type_ RTC_GUARDED_BY(&crit_); - rtc::Optional first_decoded_frame_time_ms_ RTC_GUARDED_BY(&crit_); - rtc::Optional last_decoded_frame_time_ms_ RTC_GUARDED_BY(&crit_); + absl::optional first_decoded_frame_time_ms_ RTC_GUARDED_BY(&crit_); + absl::optional last_decoded_frame_time_ms_ RTC_GUARDED_BY(&crit_); size_t num_delayed_frames_rendered_ RTC_GUARDED_BY(&crit_); int64_t sum_missed_render_deadline_ms_ RTC_GUARDED_BY(&crit_); // Mutable because calling Max() on MovingMaxCounter is not const. Yet it is // called from const GetStats(). mutable rtc::MovingMaxCounter timing_frame_info_counter_ RTC_GUARDED_BY(&crit_); - rtc::Optional num_unique_frames_ RTC_GUARDED_BY(crit_); + absl::optional num_unique_frames_ RTC_GUARDED_BY(crit_); rtc::ThreadChecker decode_thread_; rtc::ThreadChecker network_thread_; rtc::ThreadChecker main_thread_; diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index 149c8098f8..c3b9ae752c 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -82,7 +82,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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); } @@ -92,8 +92,8 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReported) { const int kFps = 20; const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps; for (int i = 0; i < kRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::Optional(), kWidth, kHeight, - VideoContentType::UNSPECIFIED); + statistics_proxy_->OnDecodedFrame(absl::optional(), kWidth, + kHeight, VideoContentType::UNSPECIFIED); fake_clock_.AdvanceTimeMilliseconds(1000 / kFps); } statistics_proxy_.reset(); @@ -105,8 +105,8 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { const int kFps = 20; const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps; for (int i = 0; i < kRequiredSamples - 1; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::Optional(), kWidth, kHeight, - VideoContentType::UNSPECIFIED); + statistics_proxy_->OnDecodedFrame(absl::optional(), kWidth, + kHeight, VideoContentType::UNSPECIFIED); fake_clock_.AdvanceTimeMilliseconds(1000 / kFps); } statistics_proxy_.reset(); @@ -116,14 +116,14 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReportedWithQpReset) { const int kFps1 = 10; for (int i = 0; i < metrics::kMinRunTimeInSeconds * kFps1; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::Optional(), kWidth, kHeight, - VideoContentType::UNSPECIFIED); + statistics_proxy_->OnDecodedFrame(absl::optional(), kWidth, + kHeight, VideoContentType::UNSPECIFIED); fake_clock_.AdvanceTimeMilliseconds(1000 / kFps1); } // First QP value received, resets frames decoded. const int kFps2 = 20; for (int i = 0; i < metrics::kMinRunTimeInSeconds * kFps2; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::Optional(1u), kWidth, + statistics_proxy_->OnDecodedFrame(absl::optional(1u), kWidth, kHeight, VideoContentType::UNSPECIFIED); fake_clock_.AdvanceTimeMilliseconds(1000 / kFps2); } @@ -136,7 +136,7 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReportedWithQpReset) { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) { EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); for (uint32_t i = 1; i <= 3; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); } @@ -146,7 +146,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) { } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) { - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, VideoContentType::UNSPECIFIED); EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum); @@ -230,20 +230,20 @@ TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) { } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) { - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, VideoContentType::UNSPECIFIED); EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); } TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) { @@ -387,7 +387,7 @@ TEST_F(ReceiveStatisticsProxyTest, const int64_t kLongEndToEndDelay = 100; const uint32_t kExpectedRtpTimestamp = 2; TimingFrameInfo info; - rtc::Optional result; + absl::optional result; info.rtp_timestamp = kExpectedRtpTimestamp - 1; info.capture_time_ms = 0; info.decode_finish_ms = kShortEndToEndDelay; @@ -412,7 +412,7 @@ TEST_F(ReceiveStatisticsProxyTest, RespectsReportingIntervalForTimingFrames) { const uint32_t kExpectedRtpTimestamp = 2; const int64_t kShortDelayMs = 1000; const int64_t kLongDelayMs = 10000; - rtc::Optional result; + absl::optional result; info.rtp_timestamp = kExpectedRtpTimestamp; info.capture_time_ms = 0; info.decode_finish_ms = kShortEndToEndDelay; @@ -741,7 +741,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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); statistics_proxy_->OnRenderedFrame(frame); fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps); @@ -796,7 +796,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReceivedFrameHistogramsAreUpdated) { } TEST_F(ReceiveStatisticsProxyTest, ZeroDelayReportedIfFrameNotDelayed) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); // Frame not delayed, delayed frames to render: 0%. @@ -814,7 +814,7 @@ TEST_F(ReceiveStatisticsProxyTest, ZeroDelayReportedIfFrameNotDelayed) { TEST_F(ReceiveStatisticsProxyTest, DelayedFrameHistogramsAreNotUpdatedIfMinRuntimeHasNotPassed) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); // Frame not delayed, delayed frames to render: 0%. @@ -832,7 +832,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, DelayedFramesHistogramsAreNotUpdatedIfNoRenderedFrames) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); // Min run time has passed. No rendered frames. @@ -844,7 +844,7 @@ TEST_F(ReceiveStatisticsProxyTest, } TEST_F(ReceiveStatisticsProxyTest, DelayReportedIfFrameIsDelayed) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); // Frame delayed 1 ms, delayed frames to render: 100%. @@ -863,7 +863,7 @@ TEST_F(ReceiveStatisticsProxyTest, DelayReportedIfFrameIsDelayed) { } TEST_F(ReceiveStatisticsProxyTest, AverageDelayOfDelayedFramesIsReported) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, VideoContentType::UNSPECIFIED); // Two frames delayed (6 ms, 10 ms), delayed frames to render: 50%. @@ -937,13 +937,13 @@ TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) { const VideoContentType content_type = GetParam(); const int kInterFrameDelayMs = 33; for (int i = 0; i < kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } // One extra with double the interval. fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); statistics_proxy_.reset(); @@ -972,18 +972,18 @@ 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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, 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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); } // Final sample is outlier and 10 times as big. fake_clock_.AdvanceTimeMilliseconds(10 * kInterFrameDelayMs); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); statistics_proxy_.reset(); @@ -1003,7 +1003,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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } @@ -1023,7 +1023,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::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } @@ -1035,10 +1035,10 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) { // Insert two more frames. The interval during the pause should be disregarded // in the stats. - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); statistics_proxy_.reset(); @@ -1068,13 +1068,13 @@ TEST_P(ReceiveStatisticsProxyTest, FreezesAreReported) { const int kInterFrameDelayMs = 33; const int kFreezeDelayMs = 200; for (int i = 0; i < kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } // Add extra freeze. fake_clock_.AdvanceTimeMilliseconds(kFreezeDelayMs); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); statistics_proxy_.reset(); @@ -1100,7 +1100,7 @@ TEST_P(ReceiveStatisticsProxyTest, PausesAreIgnored) { const int kInterFrameDelayMs = 33; const int kPauseDurationMs = 10000; for (int i = 0; i <= kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } @@ -1110,7 +1110,7 @@ TEST_P(ReceiveStatisticsProxyTest, PausesAreIgnored) { // Second playback interval with triple the length. for (int i = 0; i <= kMinRequiredSamples * 3; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } @@ -1137,15 +1137,15 @@ TEST_P(ReceiveStatisticsProxyTest, ManyPausesAtTheBeginning) { const int kInterFrameDelayMs = 33; const int kPauseDurationMs = 10000; for (int i = 0; i <= kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); statistics_proxy_->OnStreamInactive(); fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, - content_type); + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, + content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } @@ -1164,18 +1164,18 @@ TEST_P(ReceiveStatisticsProxyTest, TimeInHdReported) { const int kInterFrameDelayMs = 20; // HD frames. for (int i = 0; i < kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } // SD frames. for (int i = 0; i < 2 * kMinRequiredSamples; ++i) { - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth / 2, kHeight / 2, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth / 2, kHeight / 2, content_type); fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); } // Extra last frame. - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth / 2, kHeight / 2, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth / 2, kHeight / 2, content_type); statistics_proxy_.reset(); const int kExpectedTimeInHdPercents = 33; @@ -1268,14 +1268,14 @@ TEST_P(ReceiveStatisticsProxyTest, StatsAreSlicedOnSimulcastAndExperiment) { videocontenttypehelpers::SetSimulcastId(&content_type, 1); for (int i = 0; i <= kMinRequiredSamples; ++i) { fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); } videocontenttypehelpers::SetSimulcastId(&content_type, 2); for (int i = 0; i <= kMinRequiredSamples; ++i) { fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2); - statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, + statistics_proxy_->OnDecodedFrame(absl::nullopt, kWidth, kHeight, content_type); } statistics_proxy_.reset(); diff --git a/video/rtp_streams_synchronizer.cc b/video/rtp_streams_synchronizer.cc index c330a4434a..cc7f89308c 100644 --- a/video/rtp_streams_synchronizer.cc +++ b/video/rtp_streams_synchronizer.cc @@ -76,13 +76,13 @@ void RtpStreamsSynchronizer::Process() { } RTC_DCHECK(sync_.get()); - rtc::Optional audio_info = syncable_audio_->GetInfo(); + absl::optional audio_info = syncable_audio_->GetInfo(); if (!audio_info || !UpdateMeasurements(&audio_measurement_, *audio_info)) { return; } int64_t last_video_receive_ms = video_measurement_.latest_receive_time_ms; - rtc::Optional video_info = syncable_video_->GetInfo(); + absl::optional video_info = syncable_video_->GetInfo(); if (!video_info || !UpdateMeasurements(&video_measurement_, *video_info)) { return; } diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 996154f628..271c56f8fc 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -354,11 +354,11 @@ void RtpVideoStreamReceiver::UpdateRtt(int64_t max_rtt_ms) { nack_module_->UpdateRtt(max_rtt_ms); } -rtc::Optional RtpVideoStreamReceiver::LastReceivedPacketMs() const { +absl::optional RtpVideoStreamReceiver::LastReceivedPacketMs() const { return packet_buffer_->LastReceivedPacketMs(); } -rtc::Optional RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() +absl::optional RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() const { return packet_buffer_->LastReceivedKeyframePacketMs(); } diff --git a/video/rtp_video_stream_receiver.h b/video/rtp_video_stream_receiver.h index 4c8a4f2595..75dcea5bca 100644 --- a/video/rtp_video_stream_receiver.h +++ b/video/rtp_video_stream_receiver.h @@ -129,8 +129,8 @@ class RtpVideoStreamReceiver : public RtpData, // Called by VideoReceiveStream when stats are updated. void UpdateRtt(int64_t max_rtt_ms); - rtc::Optional LastReceivedPacketMs() const; - rtc::Optional LastReceivedKeyframePacketMs() const; + absl::optional LastReceivedPacketMs() const; + absl::optional LastReceivedKeyframePacketMs() const; // RtpDemuxer only forwards a given RTP packet to one sink. However, some // sinks, such as FlexFEC, might wish to be informed of all of the packets diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 6c86c63757..85afbc9368 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -85,36 +85,36 @@ bool IsForcedFallbackPossible(const CodecSpecificInfo* codec_info) { codec_info->codecSpecific.VP8.temporalIdx == kNoTemporalIdx); } -rtc::Optional GetFallbackMaxPixels(const std::string& group) { +absl::optional GetFallbackMaxPixels(const std::string& group) { if (group.empty()) - return rtc::nullopt; + return absl::nullopt; int min_pixels; int max_pixels; int min_bps; if (sscanf(group.c_str(), "-%d,%d,%d", &min_pixels, &max_pixels, &min_bps) != 3) { - return rtc::Optional(); + return absl::optional(); } if (min_pixels <= 0 || max_pixels <= 0 || max_pixels < min_pixels) - return rtc::Optional(); + return absl::optional(); - return rtc::Optional(max_pixels); + return absl::optional(max_pixels); } -rtc::Optional GetFallbackMaxPixelsIfFieldTrialEnabled() { +absl::optional GetFallbackMaxPixelsIfFieldTrialEnabled() { std::string group = webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); return (group.find("Enabled") == 0) ? GetFallbackMaxPixels(group.substr(7)) - : rtc::Optional(); + : absl::optional(); } -rtc::Optional GetFallbackMaxPixelsIfFieldTrialDisabled() { +absl::optional GetFallbackMaxPixelsIfFieldTrialDisabled() { std::string group = webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); return (group.find("Disabled") == 0) ? GetFallbackMaxPixels(group.substr(8)) - : rtc::Optional(); + : absl::optional(); } } // namespace diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h index bef3b28c85..7239e7f540 100644 --- a/video/send_statistics_proxy.h +++ b/video/send_statistics_proxy.h @@ -162,7 +162,7 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver, bool is_active = false; int on_off_events = 0; int64_t elapsed_ms = 0; - rtc::Optional last_update_ms; + absl::optional last_update_ms; const int max_frame_diff_ms = 2000; }; struct FallbackEncoderInfoDisabled { @@ -235,8 +235,8 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver, Clock* const clock_; const std::string payload_name_; const VideoSendStream::Config::Rtp rtp_config_; - const rtc::Optional fallback_max_pixels_; - const rtc::Optional fallback_max_pixels_disabled_; + const absl::optional fallback_max_pixels_; + const absl::optional fallback_max_pixels_disabled_; rtc::CriticalSection crit_; VideoEncoderConfig::ContentType content_type_ RTC_GUARDED_BY(crit_); const int64_t start_ms_; @@ -248,7 +248,7 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver, rtc::RateTracker media_byte_rate_tracker_ RTC_GUARDED_BY(crit_); rtc::RateTracker encoded_frame_rate_tracker_ RTC_GUARDED_BY(crit_); - rtc::Optional last_outlier_timestamp_ RTC_GUARDED_BY(crit_); + absl::optional last_outlier_timestamp_ RTC_GUARDED_BY(crit_); // Contains stats used for UMA histograms. These stats will be reset if // content type changes between real-time video and screenshare, since these diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc index d9e8343754..573031799e 100644 --- a/video/send_statistics_proxy_unittest.cc +++ b/video/send_statistics_proxy_unittest.cc @@ -331,7 +331,7 @@ TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesFramesEncoded) { TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesQpSum) { EncodedImage encoded_image; CodecSpecificInfo codec_info; - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); encoded_image.qp_ = 3; statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum); @@ -344,9 +344,9 @@ TEST_F(SendStatisticsProxyTest, OnSendEncodedImageWithoutQpQpSumWontExist) { EncodedImage encoded_image; CodecSpecificInfo codec_info; encoded_image.qp_ = -1; - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); - EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); + EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum); } TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) { diff --git a/video/video_quality_observer.cc b/video/video_quality_observer.cc index c6663fa8c4..b35a8c8164 100644 --- a/video/video_quality_observer.cc +++ b/video/video_quality_observer.cc @@ -109,7 +109,7 @@ void VideoQualityObserver::UpdateHistograms() { RTC_LOG(LS_INFO) << log_stream.str(); } -void VideoQualityObserver::OnDecodedFrame(rtc::Optional qp, +void VideoQualityObserver::OnDecodedFrame(absl::optional qp, int width, int height, int64_t now_ms, @@ -125,7 +125,7 @@ void VideoQualityObserver::OnDecodedFrame(rtc::Optional qp, // Process inter-frame delay. int64_t interframe_delay_ms = now_ms - last_frame_decoded_ms_; interframe_delays_.Add(interframe_delay_ms); - rtc::Optional avg_interframe_delay = + absl::optional avg_interframe_delay = interframe_delays_.Avg(kMinFrameSamplesToDetectFreeze); // Check if it was a freeze. if (avg_interframe_delay && @@ -140,7 +140,7 @@ void VideoQualityObserver::OnDecodedFrame(rtc::Optional qp, // Only count inter-frame delay as playback time if there // was no freeze. time_in_resolution_ms_[current_resolution_] += interframe_delay_ms; - rtc::Optional qp_blocky_threshold; + absl::optional qp_blocky_threshold; // TODO(ilnik): add other codec types when we have QP for them. switch (codec) { case kVideoCodecVP8: @@ -150,7 +150,7 @@ void VideoQualityObserver::OnDecodedFrame(rtc::Optional qp, qp_blocky_threshold = kBlockyQpThresholdVp9; break; default: - qp_blocky_threshold = rtc::nullopt; + qp_blocky_threshold = absl::nullopt; } if (qp_blocky_threshold && qp.value_or(0) > *qp_blocky_threshold) { time_in_blocky_video_ms_ += interframe_delay_ms; diff --git a/video/video_quality_observer.h b/video/video_quality_observer.h index cbeab4339e..8ba4af3984 100644 --- a/video/video_quality_observer.h +++ b/video/video_quality_observer.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/video/video_content_type.h" #include "common_types.h" // NOLINT(build/include) #include "rtc_base/numerics/sample_counter.h" @@ -30,7 +30,7 @@ class VideoQualityObserver { explicit VideoQualityObserver(VideoContentType content_type); ~VideoQualityObserver(); - void OnDecodedFrame(rtc::Optional qp, + void OnDecodedFrame(absl::optional qp, int width, int height, int64_t now_ms, diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index f6c48c0d85..3a174c4b17 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -491,8 +491,8 @@ class VideoAnalyzer : public PacketReceiver, render_time_ms(render_time_ms), encoded_frame_size(encoded_frame_size) {} - rtc::Optional reference; - rtc::Optional render; + absl::optional reference; + absl::optional render; bool dropped; int64_t input_time_ms; int64_t send_time_ms; @@ -1028,7 +1028,7 @@ class VideoAnalyzer : public PacketReceiver, }; // Rendered frame with worst PSNR is saved for further analysis. - rtc::Optional worst_frame_ RTC_GUARDED_BY(comparison_lock_); + absl::optional worst_frame_ RTC_GUARDED_BY(comparison_lock_); size_t last_fec_bytes_; @@ -1052,13 +1052,13 @@ class VideoAnalyzer : public PacketReceiver, rtc::CriticalSection crit_; std::deque frames_ RTC_GUARDED_BY(crit_); - rtc::Optional last_rendered_frame_ RTC_GUARDED_BY(crit_); + absl::optional last_rendered_frame_ RTC_GUARDED_BY(crit_); rtc::TimestampWrapAroundHandler wrap_handler_ RTC_GUARDED_BY(crit_); std::map send_times_ RTC_GUARDED_BY(crit_); std::map recv_times_ RTC_GUARDED_BY(crit_); std::map encoded_frame_sizes_ RTC_GUARDED_BY(crit_); - rtc::Optional first_encoded_timestamp_ RTC_GUARDED_BY(crit_); - rtc::Optional first_sent_timestamp_ RTC_GUARDED_BY(crit_); + absl::optional first_encoded_timestamp_ RTC_GUARDED_BY(crit_); + absl::optional first_sent_timestamp_ RTC_GUARDED_BY(crit_); const double avg_psnr_threshold_; const double avg_ssim_threshold_; bool is_quick_test_enabled_; @@ -1751,7 +1751,7 @@ void VideoQualityTest::SetupThumbnailCapturers(size_t num_thumbnail_streams) { for (size_t i = 0; i < num_thumbnail_streams; ++i) { thumbnail_capturers_.emplace_back(test::FrameGeneratorCapturer::Create( static_cast(thumbnail.width), static_cast(thumbnail.height), - rtc::nullopt, rtc::nullopt, thumbnail.max_framerate, clock_)); + absl::nullopt, absl::nullopt, thumbnail.max_framerate, clock_)); RTC_DCHECK(thumbnail_capturers_.back()); } } @@ -1817,13 +1817,13 @@ void VideoQualityTest::CreateCapturers() { if (params_.video[video_idx].clip_name == "Generator") { video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), - static_cast(params_.video[video_idx].height), rtc::nullopt, - rtc::nullopt, params_.video[video_idx].fps, clock_)); + static_cast(params_.video[video_idx].height), absl::nullopt, + absl::nullopt, params_.video[video_idx].fps, clock_)); } else if (params_.video[video_idx].clip_name == "GeneratorI420A") { video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), static_cast(params_.video[video_idx].height), - test::FrameGenerator::OutputType::I420A, rtc::nullopt, + test::FrameGenerator::OutputType::I420A, absl::nullopt, params_.video[video_idx].fps, clock_)); } else if (params_.video[video_idx].clip_name.empty()) { video_capturers_[video_idx].reset(test::VcmCapturer::Create( @@ -1836,7 +1836,7 @@ void VideoQualityTest::CreateCapturers() { test::FrameGeneratorCapturer::Create( static_cast(params_.video[video_idx].width), static_cast(params_.video[video_idx].height), - rtc::nullopt, rtc::nullopt, params_.video[video_idx].fps, + absl::nullopt, absl::nullopt, params_.video[video_idx].fps, clock_)); } } else { diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index 0e596beae3..f5c7e2a9c2 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -16,13 +16,13 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "call/rtp_stream_receiver_controller_interface.h" #include "call/rtx_receive_stream.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/h264/profile_level_id.h" -#include "common_video/libyuv/include/webrtc_libyuv.h" #include "common_video/include/incoming_video_stream.h" +#include "common_video/libyuv/include/webrtc_libyuv.h" #include "modules/rtp_rtcp/include/rtp_receiver.h" #include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/utility/include/process_thread.h" @@ -375,7 +375,7 @@ int VideoReceiveStream::id() const { return config_.rtp.remote_ssrc; } -rtc::Optional VideoReceiveStream::GetInfo() const { +absl::optional VideoReceiveStream::GetInfo() const { RTC_DCHECK_CALLED_SEQUENTIALLY(&module_process_sequence_checker_); Syncable::Info info; @@ -384,7 +384,7 @@ rtc::Optional VideoReceiveStream::GetInfo() const { if (!rtp_receiver->GetLatestTimestamps( &info.latest_received_capture_timestamp, &info.latest_receive_time_ms)) - return rtc::nullopt; + return absl::nullopt; RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp(); RTC_DCHECK(rtp_rtcp); @@ -393,7 +393,7 @@ rtc::Optional VideoReceiveStream::GetInfo() const { nullptr, nullptr, &info.capture_time_source_clock) != 0) { - return rtc::nullopt; + return absl::nullopt; } info.current_delay_ms = video_receiver_.Delay(); @@ -454,9 +454,9 @@ bool VideoReceiveStream::Decode() { } else { RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); int64_t now_ms = clock_->TimeInMilliseconds(); - rtc::Optional last_packet_ms = + absl::optional last_packet_ms = rtp_video_stream_receiver_.LastReceivedPacketMs(); - rtc::Optional last_keyframe_packet_ms = + absl::optional last_keyframe_packet_ms = rtp_video_stream_receiver_.LastReceivedKeyframePacketMs(); // To avoid spamming keyframe requests for a stream that is not active we diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index 2ca402626c..5b1289443b 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -108,7 +108,7 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, // Implements Syncable. int id() const override; - rtc::Optional GetInfo() const override; + absl::optional GetInfo() const override; uint32_t GetPlayoutTimestamp() const override; void SetMinimumPlayoutDelay(int delay_ms) override; diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index e3fd64277f..3eb2d761a3 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -179,7 +179,7 @@ VideoSendStream::Stats VideoSendStream::GetStats() { return stats_proxy_.GetStats(); } -rtc::Optional VideoSendStream::GetPacingFactorOverride() const { +absl::optional VideoSendStream::GetPacingFactorOverride() const { return send_stream_->configured_pacing_factor_; } diff --git a/video/video_send_stream.h b/video/video_send_stream.h index bbf706aeb4..a41add8e9e 100644 --- a/video/video_send_stream.h +++ b/video/video_send_stream.h @@ -106,7 +106,7 @@ class VideoSendStream : public webrtc::VideoSendStream { class ConstructionTask; - rtc::Optional GetPacingFactorOverride() const; + absl::optional GetPacingFactorOverride() const; rtc::ThreadChecker thread_checker_; rtc::TaskQueue* const worker_queue_; diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc index c8fae7f34e..d8798b7c6b 100644 --- a/video/video_send_stream_impl.cc +++ b/video/video_send_stream_impl.cc @@ -151,25 +151,25 @@ bool TransportSeqNumExtensionConfigured(const VideoSendStream::Config& config) { const char kForcedFallbackFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; -rtc::Optional GetFallbackMinBpsFromFieldTrial() { +absl::optional GetFallbackMinBpsFromFieldTrial() { if (!webrtc::field_trial::IsEnabled(kForcedFallbackFieldTrial)) - return rtc::nullopt; + return absl::nullopt; std::string group = webrtc::field_trial::FindFullName(kForcedFallbackFieldTrial); if (group.empty()) - return rtc::nullopt; + return absl::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::nullopt; + return absl::nullopt; } if (min_bps <= 0) - return rtc::nullopt; + return absl::nullopt; return min_bps; } @@ -370,7 +370,7 @@ VideoSendStreamImpl::VideoSendStreamImpl( if (TransportSeqNumExtensionConfigured(*config_)) { has_packet_feedback_ = true; - rtc::Optional alr_settings; + absl::optional alr_settings; if (content_type == VideoEncoderConfig::ContentType::kScreen) { alr_settings = AlrExperimentSettings::CreateFromFieldTrial( AlrExperimentSettings::kScreenshareProbingBweExperimentName); diff --git a/video/video_send_stream_impl.h b/video/video_send_stream_impl.h index 84fca8f12c..ab9f8d185f 100644 --- a/video/video_send_stream_impl.h +++ b/video/video_send_stream_impl.h @@ -88,7 +88,7 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, void SetTransportOverhead(size_t transport_overhead_per_packet); - rtc::Optional configured_pacing_factor_; + absl::optional configured_pacing_factor_; // From PacketFeedbackObserver. void OnPacketAdded(uint32_t ssrc, uint16_t seq_num) override; diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index dbcfa09dcf..a11d05e3ef 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -58,7 +58,7 @@ class VideoSendStreamPeer { explicit VideoSendStreamPeer(webrtc::VideoSendStream* base_class_stream) : internal_stream_( static_cast(base_class_stream)) {} - rtc::Optional GetPacingFactorOverride() const { + absl::optional GetPacingFactorOverride() const { return internal_stream_->GetPacingFactorOverride(); } @@ -2065,7 +2065,7 @@ class StartStopBitrateObserver : public test::FakeEncoder { bool WaitBitrateChanged(bool non_zero) { do { - rtc::Optional bitrate_kbps; + absl::optional bitrate_kbps; { rtc::CritScope lock(&crit_); bitrate_kbps = bitrate_kbps_; @@ -2085,7 +2085,7 @@ class StartStopBitrateObserver : public test::FakeEncoder { rtc::CriticalSection crit_; rtc::Event encoder_init_; rtc::Event bitrate_changed_; - rtc::Optional bitrate_kbps_ RTC_GUARDED_BY(crit_); + absl::optional bitrate_kbps_ RTC_GUARDED_BY(crit_); }; // This test that if the encoder use an internal source, VideoEncoder::SetRates @@ -3773,7 +3773,7 @@ TEST_F(VideoSendStreamTest, SendsKeepAlive) { class PacingFactorObserver : public test::SendTest { public: PacingFactorObserver(bool configure_send_side, - rtc::Optional expected_pacing_factor) + absl::optional expected_pacing_factor) : test::SendTest(VideoSendStreamTest::kDefaultTimeoutMs), configure_send_side_(configure_send_side), expected_pacing_factor_(expected_pacing_factor) {} @@ -3824,7 +3824,7 @@ class PacingFactorObserver : public test::SendTest { private: const bool configure_send_side_; - const rtc::Optional expected_pacing_factor_; + const absl::optional expected_pacing_factor_; }; std::string GetAlrProbingExperimentString() { @@ -3845,7 +3845,7 @@ TEST_F(VideoSendStreamTest, AlrConfiguredWhenSendSideOn) { TEST_F(VideoSendStreamTest, AlrNotConfiguredWhenSendSideOff) { test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); // Send-side bwe off, use configuration should not be overridden. - PacingFactorObserver test_without_send_side(false, rtc::nullopt); + PacingFactorObserver test_without_send_side(false, absl::nullopt); RunBaseTest(&test_without_send_side); } diff --git a/video/video_stream_decoder.cc b/video/video_stream_decoder.cc index 5557c6cbd6..86810dd25d 100644 --- a/video/video_stream_decoder.cc +++ b/video/video_stream_decoder.cc @@ -75,7 +75,7 @@ VideoStreamDecoder::~VideoStreamDecoder() { // thread may have held the lock when calling VideoDecoder::Decode, Reset, or // Release. Acquiring the same lock in the path of decode callback can deadlock. int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame, - rtc::Optional qp, + absl::optional qp, VideoContentType content_type) { receive_stats_callback_->OnDecodedFrame(qp, video_frame.width(), video_frame.height(), content_type); diff --git a/video/video_stream_decoder.h b/video/video_stream_decoder.h index c7d04b7b14..4bc740697d 100644 --- a/video/video_stream_decoder.h +++ b/video/video_stream_decoder.h @@ -52,7 +52,7 @@ class VideoStreamDecoder : public VCMReceiveCallback, // Implements VCMReceiveCallback. int32_t FrameToRender(VideoFrame& video_frame, - rtc::Optional qp, + absl::optional qp, VideoContentType content_type) override; int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override; void OnIncomingPayloadType(int payload_type) override; diff --git a/video/video_stream_decoder_impl.cc b/video/video_stream_decoder_impl.cc index 46b40a1cd2..1bbf943dc4 100644 --- a/video/video_stream_decoder_impl.cc +++ b/video/video_stream_decoder_impl.cc @@ -232,21 +232,21 @@ VideoStreamDecoderImpl::GetFrameTimestamps(int64_t timestamp) { // VideoDecoder::DecodedImageCallback int32_t VideoStreamDecoderImpl::Decoded(VideoFrame& decoded_image) { - Decoded(decoded_image, rtc::nullopt, rtc::nullopt); + Decoded(decoded_image, absl::nullopt, absl::nullopt); return WEBRTC_VIDEO_CODEC_OK; } // VideoDecoder::DecodedImageCallback int32_t VideoStreamDecoderImpl::Decoded(VideoFrame& decoded_image, int64_t decode_time_ms) { - Decoded(decoded_image, decode_time_ms, rtc::nullopt); + Decoded(decoded_image, decode_time_ms, absl::nullopt); return WEBRTC_VIDEO_CODEC_OK; } // VideoDecoder::DecodedImageCallback void VideoStreamDecoderImpl::Decoded(VideoFrame& decoded_image, - rtc::Optional decode_time_ms, - rtc::Optional qp) { + absl::optional decode_time_ms, + absl::optional qp) { int64_t decode_stop_time_ms = rtc::TimeMillis(); bookkeeping_queue_.PostTask([this, decode_stop_time_ms, decoded_image, @@ -261,11 +261,11 @@ void VideoStreamDecoderImpl::Decoded(VideoFrame& decoded_image, return; } - rtc::Optional casted_qp; + absl::optional casted_qp; if (qp) casted_qp.emplace(*qp); - rtc::Optional casted_decode_time_ms(decode_time_ms.value_or( + absl::optional casted_decode_time_ms(decode_time_ms.value_or( decode_stop_time_ms - frame_timestamps->decode_start_time_ms)); timing_.StopDecodeTimer(0, *casted_decode_time_ms, decode_stop_time_ms, diff --git a/video/video_stream_decoder_impl.h b/video/video_stream_decoder_impl.h index d4de7b6ef2..cd1f953a6d 100644 --- a/video/video_stream_decoder_impl.h +++ b/video/video_stream_decoder_impl.h @@ -15,7 +15,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/video/video_stream_decoder.h" #include "modules/video_coding/frame_buffer2.h" #include "modules/video_coding/jitter_estimator.h" @@ -64,8 +64,8 @@ class VideoStreamDecoderImpl : public VideoStreamDecoder, int32_t Decoded(VideoFrame& decodedImage) override; int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; void Decoded(VideoFrame& decodedImage, - rtc::Optional decode_time_ms, - rtc::Optional qp) override; + absl::optional decode_time_ms, + absl::optional qp) override; VideoStreamDecoder::Callbacks* const callbacks_ RTC_PT_GUARDED_BY(bookkeeping_queue_); @@ -83,7 +83,7 @@ class VideoStreamDecoderImpl : public VideoStreamDecoder, VCMTiming timing_; video_coding::FrameBuffer frame_buffer_; video_coding::VideoLayerFrameId last_continuous_id_; - rtc::Optional current_payload_type_; + absl::optional current_payload_type_; std::unique_ptr decoder_; // Some decoders are pipelined so it is not sufficient to save frame info diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 6d214ffc8e..6aee7768dc 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -183,7 +183,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::nullopt; + sink_wants_.target_pixel_count = absl::nullopt; source_->AddOrUpdateSink(video_stream_encoder_, GetActiveSinkWantsInternal()); return true; @@ -606,7 +606,7 @@ void VideoStreamEncoder::ConfigureQualityScaler() { // Drop frames and scale down until desired quality is achieved. // Use experimental thresholds if available. - rtc::Optional experimental_thresholds; + absl::optional experimental_thresholds; if (quality_scaling_experiment_enabled_) { experimental_thresholds = QualityScalingExperiment::GetQpThresholds( encoder_config_.codec_type); @@ -880,7 +880,7 @@ EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage( int64_t capture_time_us = encoded_image.capture_time_ms_ * rtc::kNumMicrosecsPerMillisec; - rtc::Optional encode_duration_us; + absl::optional encode_duration_us; if (encoded_image.timing_.flags != VideoSendTiming::kInvalid) { encode_duration_us.emplace( // TODO(nisse): Maybe use capture_time_ms_ rather than encode_start_ms_? diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index 7a48a07964..0ea6deca93 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -230,7 +230,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, // Set when configuration must create a new encoder object, e.g., // because of a codec change. bool pending_encoder_creation_ RTC_GUARDED_BY(&encoder_queue_); - rtc::Optional last_frame_info_ + absl::optional last_frame_info_ RTC_GUARDED_BY(&encoder_queue_); int crop_width_ RTC_GUARDED_BY(&encoder_queue_); int crop_height_ RTC_GUARDED_BY(&encoder_queue_); @@ -259,7 +259,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, }; // Stores a snapshot of the last adaptation request triggered by an AdaptUp // or AdaptDown signal. - rtc::Optional last_adaptation_request_ + absl::optional last_adaptation_request_ RTC_GUARDED_BY(&encoder_queue_); rtc::RaceChecker incoming_frame_race_checker_ @@ -274,12 +274,12 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, int64_t last_frame_log_ms_ RTC_GUARDED_BY(incoming_frame_race_checker_); int captured_frame_count_ RTC_GUARDED_BY(&encoder_queue_); int dropped_frame_count_ RTC_GUARDED_BY(&encoder_queue_); - rtc::Optional pending_frame_ RTC_GUARDED_BY(&encoder_queue_); + absl::optional pending_frame_ RTC_GUARDED_BY(&encoder_queue_); int64_t pending_frame_post_time_us_ RTC_GUARDED_BY(&encoder_queue_); VideoBitrateAllocationObserver* bitrate_observer_ RTC_GUARDED_BY(&encoder_queue_); - rtc::Optional last_parameters_update_ms_ + absl::optional last_parameters_update_ms_ RTC_GUARDED_BY(&encoder_queue_); // All public methods are proxied to |encoder_queue_|. It must must be diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index e295393f9d..d83322deff 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -180,8 +180,8 @@ class AdaptingFrameForwarder : public test::FrameForwarder { return last_wants_; } - rtc::Optional last_sent_width() const { return last_width_; } - rtc::Optional last_sent_height() const { return last_height_; } + absl::optional last_sent_width() const { return last_width_; } + absl::optional last_sent_height() const { return last_height_; } void IncomingCapturedFrame(const VideoFrame& video_frame) override { int cropped_width = 0; @@ -201,8 +201,8 @@ class AdaptingFrameForwarder : public test::FrameForwarder { last_width_.emplace(adapted_frame.width()); last_height_.emplace(adapted_frame.height()); } else { - last_width_ = rtc::nullopt; - last_height_ = rtc::nullopt; + last_width_ = absl::nullopt; + last_height_ = absl::nullopt; } } else { test::FrameForwarder::IncomingCapturedFrame(video_frame); @@ -223,8 +223,8 @@ class AdaptingFrameForwarder : public test::FrameForwarder { cricket::VideoAdapter adapter_; bool adaptation_enabled_ RTC_GUARDED_BY(crit_); rtc::VideoSinkWants last_wants_ RTC_GUARDED_BY(crit_); - rtc::Optional last_width_; - rtc::Optional last_height_; + absl::optional last_width_; + absl::optional last_height_; }; class MockableSendStatisticsProxy : public SendStatisticsProxy { @@ -253,7 +253,7 @@ class MockableSendStatisticsProxy : public SendStatisticsProxy { private: rtc::CriticalSection lock_; - rtc::Optional mock_stats_ RTC_GUARDED_BY(lock_); + absl::optional mock_stats_ RTC_GUARDED_BY(lock_); }; class MockBitrateObserver : public VideoBitrateAllocationObserver {