diff --git a/rtc_tools/event_log_visualizer/analyzer.cc b/rtc_tools/event_log_visualizer/analyzer.cc index 3bed18bb57..a8dbc30cb4 100644 --- a/rtc_tools/event_log_visualizer/analyzer.cc +++ b/rtc_tools/event_log_visualizer/analyzer.cc @@ -130,7 +130,7 @@ int64_t WrappingDifference(uint32_t later, uint32_t earlier, int64_t modulus) { // This is much more reliable for outgoing streams than for incoming streams. template -rtc::Optional EstimateRtpClockFrequency( +absl::optional EstimateRtpClockFrequency( const RtpPacketContainer& packets, int64_t end_time_us) { RTC_CHECK(packets.size() >= 2); @@ -151,7 +151,7 @@ rtc::Optional EstimateRtpClockFrequency( << "Failed to estimate RTP clock frequency: Stream too short. (" << packets.size() << " packets, " << last_log_timestamp - first_log_timestamp << " us)"; - return rtc::nullopt; + return absl::nullopt; } double duration = static_cast(last_log_timestamp - first_log_timestamp) / @@ -166,7 +166,7 @@ rtc::Optional EstimateRtpClockFrequency( RTC_LOG(LS_WARNING) << "Failed to estimate RTP clock frequency: Estimate " << estimated_frequency << "not close to any stardard RTP frequency."; - return rtc::nullopt; + return absl::nullopt; } constexpr float kLeftMargin = 0.01f; @@ -174,7 +174,7 @@ constexpr float kRightMargin = 0.02f; constexpr float kBottomMargin = 0.02f; constexpr float kTopMargin = 0.05f; -rtc::Optional NetworkDelayDiff_AbsSendTime( +absl::optional NetworkDelayDiff_AbsSendTime( const LoggedRtpPacket& old_packet, const LoggedRtpPacket& new_packet) { if (old_packet.header.extension.hasAbsoluteSendTime && @@ -188,11 +188,11 @@ rtc::Optional NetworkDelayDiff_AbsSendTime( recv_time_diff - AbsSendTimeToMicroseconds(send_time_diff); return delay_change_us / 1000; } else { - return rtc::nullopt; + return absl::nullopt; } } -rtc::Optional NetworkDelayDiff_CaptureTime( +absl::optional NetworkDelayDiff_CaptureTime( const LoggedRtpPacket& old_packet, const LoggedRtpPacket& new_packet) { int64_t send_time_diff = WrappingDifference( @@ -230,13 +230,13 @@ rtc::Optional NetworkDelayDiff_CaptureTime( // store the result in a TimeSeries. template void ProcessPoints(rtc::FunctionView fx, - rtc::FunctionView(const DataType&)> fy, + rtc::FunctionView(const DataType&)> fy, const IterableType& data_view, TimeSeries* result) { for (size_t i = 0; i < data_view.size(); i++) { const DataType& elem = data_view[i]; float x = fx(elem); - rtc::Optional y = fy(elem); + absl::optional y = fy(elem); if (y) result->points.emplace_back(x, *y); } @@ -248,13 +248,13 @@ void ProcessPoints(rtc::FunctionView fx, template void ProcessPairs( rtc::FunctionView fx, - rtc::FunctionView(const DataType&, - const DataType&)> fy, + rtc::FunctionView(const DataType&, + const DataType&)> fy, const IterableType& data, TimeSeries* result) { for (size_t i = 1; i < data.size(); i++) { float x = fx(data[i]); - rtc::Optional y = fy(data[i - 1], data[i]); + absl::optional y = fy(data[i - 1], data[i]); if (y) result->points.emplace_back(x, static_cast(*y)); } @@ -266,14 +266,14 @@ void ProcessPairs( template void AccumulatePairs( rtc::FunctionView fx, - rtc::FunctionView(const DataType&, - const DataType&)> fy, + rtc::FunctionView(const DataType&, + const DataType&)> fy, const IterableType& data, TimeSeries* result) { ResultType sum = 0; for (size_t i = 1; i < data.size(); i++) { float x = fx(data[i]); - rtc::Optional y = fy(data[i - 1], data[i]); + absl::optional y = fy(data[i - 1], data[i]); if (y) sum += *y; result->points.emplace_back(x, static_cast(sum)); @@ -287,7 +287,7 @@ void AccumulatePairs( template void MovingAverage( rtc::FunctionView fx, - rtc::FunctionView(const DataType&)> fy, + rtc::FunctionView(const DataType&)> fy, const IterableType& data_view, int64_t begin_time, int64_t end_time, @@ -301,7 +301,7 @@ void MovingAverage( for (int64_t t = begin_time; t < end_time + step; t += step) { while (window_index_end < data_view.size() && data_view[window_index_end].log_time_us() < t) { - rtc::Optional value = fy(data_view[window_index_end]); + absl::optional value = fy(data_view[window_index_end]); if (value) sum_in_window += *value; ++window_index_end; @@ -309,7 +309,7 @@ void MovingAverage( while (window_index_begin < data_view.size() && data_view[window_index_begin].log_time_us() < t - window_duration_us) { - rtc::Optional value = fy(data_view[window_index_begin]); + absl::optional value = fy(data_view[window_index_begin]); if (value) sum_in_window -= *value; ++window_index_begin; @@ -465,7 +465,7 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLogNew& log, while (start_iter != log_start_events.end()) { int64_t start = start_iter->log_time_us(); ++start_iter; - rtc::Optional next_start; + absl::optional next_start; if (start_iter != log_start_events.end()) next_start.emplace(start_iter->log_time_us()); if (end_iter != log_end_events.end() && @@ -537,7 +537,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction, TimeSeries time_series(GetStreamName(direction, stream.ssrc), LineStyle::kBar); auto GetPacketSize = [](const LoggedRtpPacket& packet) { - return rtc::Optional(packet.total_length); + return absl::optional(packet.total_length); }; auto ToCallTime = [this](const LoggedRtpPacket& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -599,7 +599,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { uint32_t ssrc = playout_stream.first; if (!MatchingSsrc(ssrc, desired_ssrc_)) continue; - rtc::Optional last_playout_ms; + absl::optional last_playout_ms; TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar); for (const auto& playout_event : playout_stream.second) { float x = ToCallTimeSec(playout_event.log_time_us()); @@ -1139,7 +1139,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { cc.OnTransportFeedback(rtcp_iterator->transport_feedback); std::vector feedback = cc.GetTransportFeedbackVector(); SortPacketFeedbackVector(&feedback); - rtc::Optional bitrate_bps; + absl::optional bitrate_bps; if (!feedback.empty()) { #if !(BWE_TEST_LOGGING_COMPILE_TIME_ENABLE) acknowledged_bitrate_estimator.IncomingPacketFeedbackVector(feedback); @@ -1251,7 +1251,7 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) { clock.TimeInMicroseconds()); rscc.OnReceivedPacket(arrival_time_ms, payload, packet.rtp.header); acked_bitrate.Update(payload, arrival_time_ms); - rtc::Optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); + absl::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); if (bitrate_bps) { uint32_t y = *bitrate_bps / 1000; float x = ToCallTimeSec(clock.TimeInMicroseconds()); @@ -1383,7 +1383,7 @@ void EventLogAnalyzer::CreatePacerDelayGraph(Plot* plot) { int64_t end_time_us = log_segments_.empty() ? std::numeric_limits::max() : log_segments_.front().second; - rtc::Optional estimated_frequency = + absl::optional estimated_frequency = EstimateRtpClockFrequency(packets, end_time_us); if (!estimated_frequency) continue; @@ -1463,11 +1463,11 @@ void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) { TimeSeries time_series("Audio encoder target bitrate", LineStyle::kLine, PointStyle::kHighlight); auto GetAnaBitrateBps = [](const LoggedAudioNetworkAdaptationEvent& ana_event) - -> rtc::Optional { + -> absl::optional { if (ana_event.config.bitrate_bps) - return rtc::Optional( + return absl::optional( static_cast(*ana_event.config.bitrate_bps)); - return rtc::nullopt; + return absl::nullopt; }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1488,9 +1488,9 @@ void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) { auto GetAnaFrameLengthMs = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.frame_length_ms) - return rtc::Optional( + return absl::optional( static_cast(*ana_event.config.frame_length_ms)); - return rtc::Optional(); + return absl::optional(); }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1511,9 +1511,9 @@ void EventLogAnalyzer::CreateAudioEncoderPacketLossGraph(Plot* plot) { auto GetAnaPacketLoss = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.uplink_packet_loss_fraction) - return rtc::Optional(static_cast( + return absl::optional(static_cast( *ana_event.config.uplink_packet_loss_fraction)); - return rtc::Optional(); + return absl::optional(); }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1535,9 +1535,9 @@ void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) { auto GetAnaFecEnabled = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.enable_fec) - return rtc::Optional( + return absl::optional( static_cast(*ana_event.config.enable_fec)); - return rtc::Optional(); + return absl::optional(); }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1558,9 +1558,9 @@ void EventLogAnalyzer::CreateAudioEncoderEnableDtxGraph(Plot* plot) { auto GetAnaDtxEnabled = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.enable_dtx) - return rtc::Optional( + return absl::optional( static_cast(*ana_event.config.enable_dtx)); - return rtc::Optional(); + return absl::optional(); }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1581,9 +1581,9 @@ void EventLogAnalyzer::CreateAudioEncoderNumChannelsGraph(Plot* plot) { auto GetAnaNumChannels = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.num_channels) - return rtc::Optional( + return absl::optional( static_cast(*ana_event.config.num_channels)); - return rtc::Optional(); + return absl::optional(); }; auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) { return this->ToCallTimeSec(packet.log_time_us()); @@ -1605,7 +1605,7 @@ class NetEqStreamInput : public test::NetEqInput { // that outlive the one constructed. NetEqStreamInput(const std::vector* packet_stream, const std::vector* output_events, - rtc::Optional end_time_ms) + absl::optional end_time_ms) : packet_stream_(*packet_stream), packet_stream_it_(packet_stream_.begin()), output_events_it_(output_events->begin()), @@ -1615,22 +1615,22 @@ class NetEqStreamInput : public test::NetEqInput { RTC_DCHECK(output_events); } - rtc::Optional NextPacketTime() const override { + absl::optional NextPacketTime() const override { if (packet_stream_it_ == packet_stream_.end()) { - return rtc::nullopt; + return absl::nullopt; } if (end_time_ms_ && packet_stream_it_->rtp.log_time_ms() > *end_time_ms_) { - return rtc::nullopt; + return absl::nullopt; } return packet_stream_it_->rtp.log_time_ms(); } - rtc::Optional NextOutputEventTime() const override { + absl::optional NextOutputEventTime() const override { if (output_events_it_ == output_events_end_) { - return rtc::nullopt; + return absl::nullopt; } if (end_time_ms_ && output_events_it_->log_time_ms() > *end_time_ms_) { - return rtc::nullopt; + return absl::nullopt; } return output_events_it_->log_time_ms(); } @@ -1661,9 +1661,9 @@ class NetEqStreamInput : public test::NetEqInput { bool ended() const override { return !NextEventTime(); } - rtc::Optional NextHeader() const override { + absl::optional NextHeader() const override { if (packet_stream_it_ == packet_stream_.end()) { - return rtc::nullopt; + return absl::nullopt; } return packet_stream_it_->rtp.header; } @@ -1673,7 +1673,7 @@ class NetEqStreamInput : public test::NetEqInput { std::vector::const_iterator packet_stream_it_; std::vector::const_iterator output_events_it_; const std::vector::const_iterator output_events_end_; - const rtc::Optional end_time_ms_; + const absl::optional end_time_ms_; }; namespace { @@ -1683,7 +1683,7 @@ namespace { std::unique_ptr CreateNetEqTestAndRun( const std::vector* packet_stream, const std::vector* output_events, - rtc::Optional end_time_ms, + absl::optional end_time_ms, const std::string& replacement_file_name, int file_sample_rate_hz) { std::unique_ptr input( @@ -1759,10 +1759,10 @@ EventLogAnalyzer::NetEqStatsGetterMap EventLogAnalyzer::SimulateNetEq( output_events_it = parsed_log_.audio_playout_events().cbegin(); } - rtc::Optional end_time_ms = + absl::optional end_time_ms = log_segments_.empty() - ? rtc::nullopt - : rtc::Optional(log_segments_.front().second / 1000); + ? absl::nullopt + : absl::optional(log_segments_.front().second / 1000); neteq_stats[ssrc] = CreateNetEqTestAndRun( audio_packets, &output_events_it->second, end_time_ms, @@ -1786,8 +1786,8 @@ void EventLogAnalyzer::CreateAudioJitterBufferGraph( std::vector send_times_s; std::vector arrival_delay_ms; std::vector corrected_arrival_delay_ms; - std::vector> playout_delay_ms; - std::vector> target_delay_ms; + std::vector> playout_delay_ms; + std::vector> target_delay_ms; neteq_stats.at(ssrc)->delay_analyzer()->CreateGraphs( &send_times_s, &arrival_delay_ms, &corrected_arrival_delay_ms, &playout_delay_ms, &target_delay_ms); @@ -2014,9 +2014,9 @@ void EventLogAnalyzer::CreateStreamGapAlerts(PacketDirection direction) { : log_segments_.front().second; SeqNumUnwrapper seq_num_unwrapper; - rtc::Optional last_seq_num; + absl::optional last_seq_num; SeqNumUnwrapper capture_time_unwrapper; - rtc::Optional last_capture_time; + absl::optional last_capture_time; // Check for gaps in sequence numbers and capture timestamps. for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) { for (const auto& packet : stream.packet_view) { @@ -2060,7 +2060,7 @@ void EventLogAnalyzer::CreateTransmissionGapAlerts(PacketDirection direction) { for (const LoggedRtpPacket& rtp_packet : stream.packet_view) rtp_in_direction.emplace(rtp_packet.log_time_us(), &rtp_packet); } - rtc::Optional last_rtp_time; + absl::optional last_rtp_time; for (const auto& kv : rtp_in_direction) { int64_t timestamp = kv.first; if (timestamp > end_time_us) { @@ -2075,7 +2075,7 @@ void EventLogAnalyzer::CreateTransmissionGapAlerts(PacketDirection direction) { last_rtp_time.emplace(timestamp); } - rtc::Optional last_rtcp_time; + absl::optional last_rtcp_time; if (direction == kIncomingPacket) { for (const auto& rtcp : parsed_log_.incoming_rtcp_packets()) { if (rtcp.log_time_us() > end_time_us) { diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn index 67c9357c99..544f1227b2 100644 --- a/rtc_tools/network_tester/BUILD.gn +++ b/rtc_tools/network_tester/BUILD.gn @@ -41,13 +41,13 @@ if (rtc_enable_protobuf) { deps = [ ":network_tester_config_proto", ":network_tester_packet_proto", - "../../api:optional", "../../p2p", "../../rtc_base:checks", "../../rtc_base:protobuf_utils", "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_task_queue", "../../rtc_base:sequenced_task_checker", + "//third_party/abseil-cpp/absl/types:optional", ] if (!build_with_chromium && is_clang) { diff --git a/rtc_tools/network_tester/config_reader.cc b/rtc_tools/network_tester/config_reader.cc index 5ef1e4bf8b..8ef88c7eda 100644 --- a/rtc_tools/network_tester/config_reader.cc +++ b/rtc_tools/network_tester/config_reader.cc @@ -31,10 +31,10 @@ ConfigReader::ConfigReader(const std::string& config_file_path) ConfigReader::~ConfigReader() = default; -rtc::Optional ConfigReader::GetNextConfig() { +absl::optional ConfigReader::GetNextConfig() { #ifdef WEBRTC_NETWORK_TESTER_PROTO if (proto_config_index_ >= proto_all_configs_.configs_size()) - return rtc::nullopt; + return absl::nullopt; auto proto_config = proto_all_configs_.configs(proto_config_index_++); RTC_DCHECK(proto_config.has_packet_send_interval_ms()); RTC_DCHECK(proto_config.has_packet_size()); @@ -45,7 +45,7 @@ rtc::Optional ConfigReader::GetNextConfig() { config.execution_time_ms = proto_config.execution_time_ms(); return config; #else - return rtc::nullopt; + return absl::nullopt; #endif // WEBRTC_NETWORK_TESTER_PROTO } diff --git a/rtc_tools/network_tester/config_reader.h b/rtc_tools/network_tester/config_reader.h index e03317fe43..deee245eef 100644 --- a/rtc_tools/network_tester/config_reader.h +++ b/rtc_tools/network_tester/config_reader.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "rtc_base/constructormagic.h" #include "rtc_base/ignore_wundef.h" @@ -40,7 +40,7 @@ class ConfigReader { explicit ConfigReader(const std::string& config_file_path); ~ConfigReader(); - rtc::Optional GetNextConfig(); + absl::optional GetNextConfig(); private: NetworkTesterAllConfigs proto_all_configs_; diff --git a/rtc_tools/network_tester/test_controller.cc b/rtc_tools/network_tester/test_controller.cc index a3a8833655..e5bd92efa9 100644 --- a/rtc_tools/network_tester/test_controller.cc +++ b/rtc_tools/network_tester/test_controller.cc @@ -37,7 +37,7 @@ void TestController::SendConnectTo(const std::string& hostname, int port) { udp_transport_->SetRemoteAddress(rtc::SocketAddress(hostname, port)); NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::HAND_SHAKING); - SendData(packet, rtc::nullopt); + SendData(packet, absl::nullopt); rtc::CritScope scoped_lock(&local_test_done_lock_); local_test_done_ = false; remote_test_done_ = false; @@ -49,7 +49,7 @@ void TestController::Run() { } void TestController::SendData(const NetworkTesterPacket& packet, - rtc::Optional data_size) { + absl::optional data_size) { // Can be call from packet_sender or from test_controller thread. size_t packet_size = packet.ByteSizeLong(); send_data_[0] = packet_size; @@ -65,7 +65,7 @@ void TestController::OnTestDone() { RTC_DCHECK_CALLED_SEQUENTIALLY(&packet_sender_checker_); NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::TEST_DONE); - SendData(packet, rtc::nullopt); + SendData(packet, absl::nullopt); rtc::CritScope scoped_lock(&local_test_done_lock_); local_test_done_ = true; } @@ -92,7 +92,7 @@ void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket, NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::TEST_START); udp_transport_->SetRemoteAddress(remote_addr); - SendData(packet, rtc::nullopt); + SendData(packet, absl::nullopt); packet_sender_.reset(new PacketSender(this, config_file_path_)); packet_sender_->StartSending(); rtc::CritScope scoped_lock(&local_test_done_lock_); diff --git a/rtc_tools/network_tester/test_controller.h b/rtc_tools/network_tester/test_controller.h index 4c9ede18ae..cf65e17459 100644 --- a/rtc_tools/network_tester/test_controller.h +++ b/rtc_tools/network_tester/test_controller.h @@ -49,7 +49,7 @@ class TestController : public sigslot::has_slots<> { void SendConnectTo(const std::string& hostname, int port); void SendData(const NetworkTesterPacket& packet, - rtc::Optional data_size); + absl::optional data_size); void OnTestDone(); diff --git a/test/BUILD.gn b/test/BUILD.gn index 8da8e19c6a..60d725bea6 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -63,7 +63,6 @@ rtc_source_set("video_test_common") { "..:webrtc_common", "../:typedefs", "../api:libjingle_peerconnection_api", - "../api:optional", "../api/video:video_frame", "../api/video:video_frame_i420", "../api/video_codecs:video_codecs_api", @@ -75,6 +74,7 @@ rtc_source_set("video_test_common") { "../rtc_base:rtc_base", "../rtc_base:rtc_task_queue", "../system_wrappers", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -389,9 +389,9 @@ rtc_source_set("fileutils") { deps = [ "..:webrtc_common", "../:typedefs", - "../api:optional", "../rtc_base:checks", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] if (is_ios) { deps += [ ":fileutils_objc" ] @@ -453,10 +453,10 @@ rtc_source_set("fileutils_unittests") { deps = [ ":fileutils", ":test_support", - "../api:optional", "../rtc_base:checks", "../rtc_base:rtc_base_approved", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/test/call_test.cc b/test/call_test.cc index c111b11fc3..789f7750fd 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -323,7 +323,7 @@ void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock, int width, int height) { frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( - width, height, rtc::nullopt, rtc::nullopt, framerate * speed, clock)); + width, height, absl::nullopt, absl::nullopt, framerate * speed, clock)); video_send_stream_->SetSource(frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE); } @@ -332,7 +332,7 @@ void CallTest::CreateFrameGeneratorCapturer(int framerate, int width, int height) { frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( - width, height, rtc::nullopt, rtc::nullopt, framerate, clock_)); + width, height, absl::nullopt, absl::nullopt, framerate, clock_)); video_send_stream_->SetSource(frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE); } diff --git a/test/frame_generator.cc b/test/frame_generator.cc index 040192db01..cc8e6c03cf 100644 --- a/test/frame_generator.cc +++ b/test/frame_generator.cc @@ -402,7 +402,7 @@ class ScrollingImageFrameGenerator : public FrameGenerator { size_t current_frame_num_; VideoFrame* current_source_frame_; - rtc::Optional current_frame_; + absl::optional current_frame_; YuvFileGenerator file_generator_; }; @@ -444,8 +444,8 @@ bool FrameForwarder::has_sinks() const { std::unique_ptr FrameGenerator::CreateSquareGenerator( int width, int height, - rtc::Optional type, - rtc::Optional num_squares) { + absl::optional type, + absl::optional num_squares) { return std::unique_ptr( new SquareGenerator(width, height, type.value_or(OutputType::I420), num_squares.value_or(10))); diff --git a/test/frame_generator.h b/test/frame_generator.h index 049b5e735c..65857af7f0 100644 --- a/test/frame_generator.h +++ b/test/frame_generator.h @@ -67,8 +67,8 @@ class FrameGenerator { static std::unique_ptr CreateSquareGenerator( int width, int height, - rtc::Optional type, - rtc::Optional num_squares); + absl::optional type, + absl::optional num_squares); // Creates a frame generator that repeatedly plays a set of yuv files. // The frame_repeat_count determines how many times each frame is shown, diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc index a9e80d78ca..61f96fa86f 100644 --- a/test/frame_generator_capturer.cc +++ b/test/frame_generator_capturer.cc @@ -87,8 +87,8 @@ class FrameGeneratorCapturer::InsertFrameTask : public rtc::QueuedTask { FrameGeneratorCapturer* FrameGeneratorCapturer::Create( int width, int height, - rtc::Optional type, - rtc::Optional num_squares, + absl::optional type, + absl::optional num_squares, int target_fps, Clock* clock) { std::unique_ptr capturer(new FrameGeneratorCapturer( @@ -187,7 +187,7 @@ void FrameGeneratorCapturer::InsertFrame() { } if (sink_) { - rtc::Optional out_frame = AdaptFrame(*frame); + absl::optional out_frame = AdaptFrame(*frame); if (out_frame) sink_->OnFrame(*out_frame); } diff --git a/test/frame_generator_capturer.h b/test/frame_generator_capturer.h index e135399fef..1aecf497b2 100644 --- a/test/frame_generator_capturer.h +++ b/test/frame_generator_capturer.h @@ -44,8 +44,8 @@ class FrameGeneratorCapturer : public VideoCapturer { static FrameGeneratorCapturer* Create( int width, int height, - rtc::Optional type, - rtc::Optional num_squares, + absl::optional type, + absl::optional num_squares, int target_fps, Clock* clock); @@ -98,7 +98,7 @@ class FrameGeneratorCapturer : public VideoCapturer { std::unique_ptr frame_generator_; int target_fps_ RTC_GUARDED_BY(&lock_); - rtc::Optional wanted_fps_ RTC_GUARDED_BY(&lock_); + absl::optional wanted_fps_ RTC_GUARDED_BY(&lock_); VideoRotation fake_rotation_ = kVideoRotation_0; int64_t first_frame_capture_time_; diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index 6375dc397e..684ce9aab7 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -260,11 +260,11 @@ rtc_static_library("audio_decoder_fuzzer") { deps = [ "../..:webrtc_common", "../../:typedefs", - "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -454,11 +454,11 @@ rtc_static_library("audio_processing_fuzzer_helper") { ] deps = [ ":fuzz_data_helper", - "../../api:optional", "../../api/audio:audio_frame_api", "../../modules/audio_processing", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/test/fuzzers/audio_decoder_fuzzer.cc b/test/fuzzers/audio_decoder_fuzzer.cc index f6ac4cb0bb..40a7315ef6 100644 --- a/test/fuzzers/audio_decoder_fuzzer.cc +++ b/test/fuzzers/audio_decoder_fuzzer.cc @@ -12,8 +12,8 @@ #include +#include "absl/types/optional.h" #include "api/audio_codecs/audio_decoder.h" -#include "api/optional.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "rtc_base/checks.h" diff --git a/test/fuzzers/neteq_rtp_fuzzer.cc b/test/fuzzers/neteq_rtp_fuzzer.cc index 73cbda26eb..e28af90f31 100644 --- a/test/fuzzers/neteq_rtp_fuzzer.cc +++ b/test/fuzzers/neteq_rtp_fuzzer.cc @@ -65,11 +65,11 @@ class FuzzRtpInput : public NetEqInput { FuzzHeader(); } - rtc::Optional NextPacketTime() const override { + absl::optional NextPacketTime() const override { return packet_->time_ms; } - rtc::Optional NextOutputEventTime() const override { + absl::optional NextOutputEventTime() const override { return input_->NextOutputEventTime(); } @@ -85,7 +85,7 @@ class FuzzRtpInput : public NetEqInput { bool ended() const override { return ended_; } - rtc::Optional NextHeader() const override { + absl::optional NextHeader() const override { RTC_DCHECK(packet_); return packet_->header; } diff --git a/test/fuzzers/neteq_signal_fuzzer.cc b/test/fuzzers/neteq_signal_fuzzer.cc index 981ba282ed..611964d70e 100644 --- a/test/fuzzers/neteq_signal_fuzzer.cc +++ b/test/fuzzers/neteq_signal_fuzzer.cc @@ -88,11 +88,11 @@ class FuzzSignalInput : public NetEqInput { output_event_period_ms_ = fuzz_data_.SelectOneOf(output_event_periods); } - rtc::Optional NextPacketTime() const override { + absl::optional NextPacketTime() const override { return packet_->time_ms; } - rtc::Optional NextOutputEventTime() const override { + absl::optional NextOutputEventTime() const override { return next_output_event_ms_; } @@ -124,7 +124,7 @@ class FuzzSignalInput : public NetEqInput { bool ended() const override { return ended_; } - rtc::Optional NextHeader() const override { + absl::optional NextHeader() const override { RTC_DCHECK(packet_); return packet_->header; } diff --git a/test/mock_audio_decoder_factory.h b/test/mock_audio_decoder_factory.h index 3a4399732e..247f9fa8d4 100644 --- a/test/mock_audio_decoder_factory.h +++ b/test/mock_audio_decoder_factory.h @@ -28,14 +28,14 @@ class MockAudioDecoderFactory : public AudioDecoderFactory { MOCK_METHOD1(IsSupportedDecoder, bool(const SdpAudioFormat&)); std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - rtc::Optional codec_pair_id) { + absl::optional codec_pair_id) { std::unique_ptr return_value; MakeAudioDecoderMock(format, codec_pair_id, &return_value); return return_value; } MOCK_METHOD3(MakeAudioDecoderMock, void(const SdpAudioFormat& format, - rtc::Optional codec_pair_id, + absl::optional codec_pair_id, std::unique_ptr* return_value)); // Creates a MockAudioDecoderFactory with no formats and that may not be diff --git a/test/mock_audio_encoder.h b/test/mock_audio_encoder.h index 7154e64626..60425e0613 100644 --- a/test/mock_audio_encoder.h +++ b/test/mock_audio_encoder.h @@ -43,7 +43,7 @@ class MockAudioEncoder : public AudioEncoder { MOCK_METHOD1(SetMaxPayloadSize, void(int max_payload_size_bytes)); MOCK_METHOD2(OnReceivedUplinkBandwidth, void(int target_audio_bitrate_bps, - rtc::Optional probing_interval_ms)); + absl::optional probing_interval_ms)); MOCK_METHOD1(OnReceivedUplinkPacketLossFraction, void(float uplink_packet_loss_fraction)); diff --git a/test/mock_audio_encoder_factory.h b/test/mock_audio_encoder_factory.h index 3eaa3b9873..340602c35f 100644 --- a/test/mock_audio_encoder_factory.h +++ b/test/mock_audio_encoder_factory.h @@ -25,12 +25,12 @@ class MockAudioEncoderFactory : public testing::NiceMock { public: MOCK_METHOD0(GetSupportedEncoders, std::vector()); MOCK_METHOD1(QueryAudioEncoder, - rtc::Optional(const SdpAudioFormat& format)); + absl::optional(const SdpAudioFormat& format)); std::unique_ptr MakeAudioEncoder( int payload_type, const SdpAudioFormat& format, - rtc::Optional codec_pair_id) { + absl::optional codec_pair_id) { std::unique_ptr return_value; MakeAudioEncoderMock(payload_type, format, codec_pair_id, &return_value); return return_value; @@ -38,7 +38,7 @@ class MockAudioEncoderFactory : public testing::NiceMock { MOCK_METHOD4(MakeAudioEncoderMock, void(int payload_type, const SdpAudioFormat& format, - rtc::Optional codec_pair_id, + absl::optional codec_pair_id, std::unique_ptr* return_value)); // Creates a MockAudioEncoderFactory with no formats and that may not be @@ -55,7 +55,7 @@ class MockAudioEncoderFactory : public testing::NiceMock { ON_CALL(*factory.get(), GetSupportedEncoders()) .WillByDefault(Return(std::vector())); ON_CALL(*factory.get(), QueryAudioEncoder(_)) - .WillByDefault(Return(rtc::nullopt)); + .WillByDefault(Return(absl::nullopt)); EXPECT_CALL(*factory.get(), GetSupportedEncoders()).Times(AnyNumber()); EXPECT_CALL(*factory.get(), QueryAudioEncoder(_)).Times(AnyNumber()); @@ -78,7 +78,7 @@ class MockAudioEncoderFactory : public testing::NiceMock { ON_CALL(*factory.get(), GetSupportedEncoders()) .WillByDefault(Return(std::vector())); ON_CALL(*factory.get(), QueryAudioEncoder(_)) - .WillByDefault(Return(rtc::nullopt)); + .WillByDefault(Return(absl::nullopt)); ON_CALL(*factory.get(), MakeAudioEncoderMock(_, _, _, _)) .WillByDefault(SetArgPointee<3>(nullptr)); diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc index 7ba24c1fea..76a635a1a4 100644 --- a/test/testsupport/fileutils.cc +++ b/test/testsupport/fileutils.cc @@ -223,9 +223,9 @@ std::string GenerateTempFilename(const std::string& dir, return filename; } -rtc::Optional> ReadDirectory(std::string path) { +absl::optional> ReadDirectory(std::string path) { if (path.length() == 0) - return rtc::Optional>(); + return absl::optional>(); #if defined(WEBRTC_WIN) // Append separator character if needed. @@ -236,7 +236,7 @@ rtc::Optional> ReadDirectory(std::string path) { WIN32_FIND_DATA data; HANDLE handle = ::FindFirstFile(rtc::ToUtf16(path + '*').c_str(), &data); if (handle == INVALID_HANDLE_VALUE) - return rtc::Optional>(); + return absl::optional>(); // Populate output. std::vector found_entries; @@ -257,7 +257,7 @@ rtc::Optional> ReadDirectory(std::string path) { // Init. DIR* dir = ::opendir(path.c_str()); if (dir == nullptr) - return rtc::Optional>(); + return absl::optional>(); // Populate output. std::vector found_entries; @@ -271,7 +271,7 @@ rtc::Optional> ReadDirectory(std::string path) { closedir(dir); #endif - return rtc::Optional>(std::move(found_entries)); + return absl::optional>(std::move(found_entries)); } bool CreateDir(const std::string& directory_name) { diff --git a/test/testsupport/fileutils.h b/test/testsupport/fileutils.h index b1eec8bc00..af39a9457a 100644 --- a/test/testsupport/fileutils.h +++ b/test/testsupport/fileutils.h @@ -16,7 +16,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { namespace test { @@ -81,7 +81,7 @@ std::string WorkingDir(); // of strings with one element for each found file or directory. Each element is // a path created by prepending |dir| to the file/directory name. "." and ".." // are never added in the returned vector. -rtc::Optional> ReadDirectory(std::string path); +absl::optional> ReadDirectory(std::string path); // Creates a directory if it not already exists. // Returns true if successful. Will print an error message to stderr and return diff --git a/test/testsupport/fileutils_unittest.cc b/test/testsupport/fileutils_unittest.cc index 7f85135978..b39be6fd5c 100644 --- a/test/testsupport/fileutils_unittest.cc +++ b/test/testsupport/fileutils_unittest.cc @@ -17,7 +17,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "test/gtest.h" @@ -41,7 +41,7 @@ namespace { void CleanDir(const std::string& dir, size_t* num_deleted_entries) { RTC_DCHECK(num_deleted_entries); *num_deleted_entries = 0; - rtc::Optional> dir_content = ReadDirectory(dir); + absl::optional> dir_content = ReadDirectory(dir); EXPECT_TRUE(dir_content); for (const auto& entry : *dir_content) { if (DirExists(entry)) { @@ -238,7 +238,7 @@ TEST_F(FileUtilsTest, WriteReadDeleteFilesAndDirs) { EXPECT_TRUE(DirExists(temp_subdir)); // Checks. - rtc::Optional> dir_content = + absl::optional> dir_content = ReadDirectory(temp_directory); EXPECT_TRUE(dir_content); EXPECT_EQ(2u, dir_content->size()); diff --git a/test/vcm_capturer.cc b/test/vcm_capturer.cc index 82b5cbc455..22631acbc6 100644 --- a/test/vcm_capturer.cc +++ b/test/vcm_capturer.cc @@ -108,7 +108,7 @@ VcmCapturer::~VcmCapturer() { Destroy(); } void VcmCapturer::OnFrame(const VideoFrame& frame) { rtc::CritScope lock(&crit_); if (started_ && sink_) { - rtc::Optional out_frame = AdaptFrame(frame); + absl::optional out_frame = AdaptFrame(frame); if (out_frame) sink_->OnFrame(*out_frame); } diff --git a/test/video_capturer.cc b/test/video_capturer.cc index c81c9f8a56..4faf4491cb 100644 --- a/test/video_capturer.cc +++ b/test/video_capturer.cc @@ -17,7 +17,7 @@ namespace test { VideoCapturer::VideoCapturer() : video_adapter_(new cricket::VideoAdapter()) {} VideoCapturer::~VideoCapturer() {} -rtc::Optional VideoCapturer::AdaptFrame(const VideoFrame& frame) { +absl::optional VideoCapturer::AdaptFrame(const VideoFrame& frame) { int cropped_width = 0; int cropped_height = 0; int out_width = 0; @@ -27,10 +27,10 @@ rtc::Optional VideoCapturer::AdaptFrame(const VideoFrame& frame) { frame.width(), frame.height(), frame.timestamp_us() * 1000, &cropped_width, &cropped_height, &out_width, &out_height)) { // Drop frame in order to respect frame rate constraint. - return rtc::nullopt; + return absl::nullopt; } - rtc::Optional out_frame; + absl::optional out_frame; if (out_height != frame.height() || out_width != frame.width()) { // Video adapter has requested a down-scale. Allocate a new buffer and // return scaled version. diff --git a/test/video_capturer.h b/test/video_capturer.h index 63e1cd8e7e..d117b9682b 100644 --- a/test/video_capturer.h +++ b/test/video_capturer.h @@ -14,7 +14,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame.h" #include "api/video/video_source_interface.h" @@ -41,7 +41,7 @@ class VideoCapturer : public rtc::VideoSourceInterface { const rtc::VideoSinkWants& wants) override; protected: - rtc::Optional AdaptFrame(const VideoFrame& frame); + absl::optional AdaptFrame(const VideoFrame& frame); rtc::VideoSinkWants GetSinkWants(); private: