From 00c71836144bebc1ffc61565f3bbb2048b7f4402 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 15 Jun 2018 15:58:38 +0200 Subject: [PATCH] Replace rtc::Optional with absl::optional in media, ortc, p2p This is a no-op change because rtc::Optional is an alias to absl::optional This CL generated by running script with parameters 'media ortc p2p': find $@ -type f \( -name \*.h -o -name \*.cc \) \ -exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \ -exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \ -exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+ find $@ -type f -name BUILD.gn \ -exec sed -r -i 's|"(../)*api:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+; git cl format Bug: webrtc:9078 Change-Id: I19167714af7cc1436d34cfcba6c8b3718d8e677b Reviewed-on: https://webrtc-review.googlesource.com/83731 Reviewed-by: Karl Wiberg Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#23638} --- media/BUILD.gn | 6 +-- media/base/adaptedvideotracksource.h | 2 +- media/base/codec_unittest.cc | 2 +- media/base/h264_profile_level_id.cc | 30 +++++++------- media/base/h264_profile_level_id.h | 10 ++--- media/base/mediachannel.h | 23 ++++++----- media/base/videoadapter.cc | 8 ++-- media/base/videoadapter.h | 10 ++--- media/base/videoadapter_unittest.cc | 35 ++++++++-------- media/engine/fakewebrtccall.h | 2 +- media/engine/payload_type_mapper.cc | 12 +++--- media/engine/payload_type_mapper.h | 9 ++-- media/engine/webrtcvideoengine.cc | 48 +++++++++++----------- media/engine/webrtcvideoengine.h | 38 ++++++++--------- media/engine/webrtcvideoengine_unittest.cc | 10 ++--- media/engine/webrtcvoiceengine.cc | 43 +++++++++---------- media/engine/webrtcvoiceengine.h | 12 +++--- media/engine/webrtcvoiceengine_unittest.cc | 19 +++++---- ortc/BUILD.gn | 2 +- ortc/rtpparametersconversion.cc | 16 ++++---- ortc/rtpparametersconversion.h | 4 +- ortc/rtpparametersconversion_unittest.cc | 4 +- p2p/BUILD.gn | 2 +- p2p/base/dtlstransport.cc | 6 +-- p2p/base/dtlstransport.h | 6 +-- p2p/base/fakedtlstransport.h | 6 +-- p2p/base/fakeicetransport.h | 8 ++-- p2p/base/icetransportinternal.h | 34 +++++++-------- p2p/base/mockicetransport.h | 2 +- p2p/base/p2ptransportchannel.cc | 24 +++++------ p2p/base/p2ptransportchannel.h | 14 +++---- p2p/base/p2ptransportchannel_unittest.cc | 8 ++-- p2p/base/packettransportinternal.cc | 4 +- p2p/base/packettransportinternal.h | 6 +-- p2p/base/port.cc | 2 +- p2p/base/port.h | 24 +++++------ p2p/base/port_unittest.cc | 4 +- p2p/base/portallocator.cc | 2 +- p2p/base/portallocator.h | 10 ++--- p2p/base/portinterface.h | 4 +- p2p/base/regatheringcontroller.cc | 2 +- p2p/base/regatheringcontroller.h | 6 +-- p2p/base/regatheringcontroller_unittest.cc | 4 +- p2p/base/stunport.cc | 6 +-- p2p/base/stunport.h | 10 ++--- p2p/base/stunport_unittest.cc | 4 +- p2p/base/turnport.cc | 6 +-- p2p/base/turnport_unittest.cc | 2 +- p2p/base/udptransport.cc | 4 +- p2p/base/udptransport.h | 4 +- p2p/client/basicportallocator.cc | 2 +- p2p/client/basicportallocator.h | 2 +- 52 files changed, 283 insertions(+), 280 deletions(-) diff --git a/media/BUILD.gn b/media/BUILD.gn index cfa81cbdc0..0a62d4f27f 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -40,9 +40,9 @@ rtc_source_set("rtc_h264_profile_id") { deps = [ "..:webrtc_common", - "../api:optional", "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -111,7 +111,6 @@ rtc_static_library("rtc_media_base") { ":rtc_media_config", "..:webrtc_common", "../api:libjingle_peerconnection_api", - "../api:optional", "../api/audio_codecs:audio_codecs_api", "../api/video:video_frame", "../api/video:video_frame_i420", @@ -122,6 +121,7 @@ rtc_static_library("rtc_media_base") { "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", "../system_wrappers:field_trial_api", + "//third_party/abseil-cpp/absl/types:optional", ] if (!build_with_mozilla) { @@ -304,7 +304,6 @@ rtc_static_library("rtc_audio_video") { "..:webrtc_common", "../api:call_api", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/audio_codecs:audio_codecs_api", "../api/video:video_frame", @@ -328,6 +327,7 @@ rtc_static_library("rtc_audio_video") { "../system_wrappers", "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/media/base/adaptedvideotracksource.h b/media/base/adaptedvideotracksource.h index e7edb9a64f..7e7ba7eeed 100644 --- a/media/base/adaptedvideotracksource.h +++ b/media/base/adaptedvideotracksource.h @@ -75,7 +75,7 @@ class AdaptedVideoTrackSource cricket::VideoAdapter video_adapter_; rtc::CriticalSection stats_crit_; - rtc::Optional stats_ RTC_GUARDED_BY(stats_crit_); + absl::optional stats_ RTC_GUARDED_BY(stats_crit_); VideoBroadcaster broadcaster_; }; diff --git a/media/base/codec_unittest.cc b/media/base/codec_unittest.cc index ed4ced0323..36e0c3895c 100644 --- a/media/base/codec_unittest.cc +++ b/media/base/codec_unittest.cc @@ -354,7 +354,7 @@ TEST(CodecTest, TestToCodecParameters) { EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO, codec_params_1.kind); EXPECT_EQ("V", codec_params_1.name); EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); - EXPECT_EQ(rtc::nullopt, codec_params_1.num_channels); + EXPECT_EQ(absl::nullopt, codec_params_1.num_channels); ASSERT_EQ(1u, codec_params_1.parameters.size()); EXPECT_EQ("p1", codec_params_1.parameters.begin()->first); EXPECT_EQ("v1", codec_params_1.parameters.begin()->second); diff --git a/media/base/h264_profile_level_id.cc b/media/base/h264_profile_level_id.cc index c441b50a82..65a6cf0cc9 100644 --- a/media/base/h264_profile_level_id.cc +++ b/media/base/h264_profile_level_id.cc @@ -118,13 +118,13 @@ static constexpr LevelConstraint kLevelConstraints[] = { } // anonymous namespace -rtc::Optional ParseProfileLevelId(const char* str) { +absl::optional ParseProfileLevelId(const char* str) { // The string should consist of 3 bytes in hexadecimal format. if (strlen(str) != 6u) - return rtc::nullopt; + return absl::nullopt; const uint32_t profile_level_id_numeric = strtol(str, nullptr, 16); if (profile_level_id_numeric == 0) - return rtc::nullopt; + return absl::nullopt; // Separate into three bytes. const uint8_t level_idc = @@ -159,7 +159,7 @@ rtc::Optional ParseProfileLevelId(const char* str) { break; default: // Unrecognized level_idc. - return rtc::nullopt; + return absl::nullopt; } // Parse profile_idc/profile_iop into a Profile enum. @@ -171,10 +171,10 @@ rtc::Optional ParseProfileLevelId(const char* str) { } // Unrecognized profile_idc/profile_iop combination. - return rtc::nullopt; + return absl::nullopt; } -rtc::Optional SupportedLevel(int max_frame_pixel_count, float max_fps) { +absl::optional SupportedLevel(int max_frame_pixel_count, float max_fps) { static const int kPixelsPerMacroblock = 16 * 16; for (int i = arraysize(kLevelConstraints) - 1; i >= 0; --i) { @@ -188,10 +188,10 @@ rtc::Optional SupportedLevel(int max_frame_pixel_count, float max_fps) { } // No level supported. - return rtc::nullopt; + return absl::nullopt; } -rtc::Optional ParseSdpProfileLevelId( +absl::optional ParseSdpProfileLevelId( const CodecParameterMap& params) { // TODO(magjed): The default should really be kProfileBaseline and kLevel1 // according to the spec: https://tools.ietf.org/html/rfc6184#section-8.1. In @@ -209,7 +209,7 @@ rtc::Optional ParseSdpProfileLevelId( : ParseProfileLevelId(profile_level_id_it->second.c_str()); } -rtc::Optional ProfileLevelIdToString( +absl::optional ProfileLevelIdToString( const ProfileLevelId& profile_level_id) { // Handle special case level == 1b. if (profile_level_id.level == kLevel1_b) { @@ -222,7 +222,7 @@ rtc::Optional ProfileLevelIdToString( return {"4d100b"}; // Level 1b is not allowed for other profiles. default: - return rtc::nullopt; + return absl::nullopt; } } @@ -245,7 +245,7 @@ rtc::Optional ProfileLevelIdToString( break; // Unrecognized profile. default: - return rtc::nullopt; + return absl::nullopt; } char str[7]; @@ -267,9 +267,9 @@ void GenerateProfileLevelIdForAnswer( } // Parse profile-level-ids. - const rtc::Optional local_profile_level_id = + const absl::optional local_profile_level_id = ParseSdpProfileLevelId(local_supported_params); - const rtc::Optional remote_profile_level_id = + const absl::optional remote_profile_level_id = ParseSdpProfileLevelId(remote_offered_params); // The local and remote codec must have valid and equal H264 Profiles. RTC_DCHECK(local_profile_level_id); @@ -297,9 +297,9 @@ void GenerateProfileLevelIdForAnswer( bool IsSameH264Profile(const CodecParameterMap& params1, const CodecParameterMap& params2) { - const rtc::Optional profile_level_id = + const absl::optional profile_level_id = webrtc::H264::ParseSdpProfileLevelId(params1); - const rtc::Optional other_profile_level_id = + const absl::optional other_profile_level_id = webrtc::H264::ParseSdpProfileLevelId(params2); // Compare H264 profiles, but not levels. return profile_level_id && other_profile_level_id && diff --git a/media/base/h264_profile_level_id.h b/media/base/h264_profile_level_id.h index f46efd3eb4..b4ff88369c 100644 --- a/media/base/h264_profile_level_id.h +++ b/media/base/h264_profile_level_id.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "common_types.h" // NOLINT(build/include) namespace webrtc { @@ -55,24 +55,24 @@ struct ProfileLevelId { // Parse profile level id that is represented as a string of 3 hex bytes. // Nothing will be returned if the string is not a recognized H264 // profile level id. -rtc::Optional ParseProfileLevelId(const char* str); +absl::optional ParseProfileLevelId(const char* str); // Parse profile level id that is represented as a string of 3 hex bytes // contained in an SDP key-value map. A default profile level id will be // returned if the profile-level-id key is missing. Nothing will be returned if // the key is present but the string is invalid. -rtc::Optional ParseSdpProfileLevelId( +absl::optional ParseSdpProfileLevelId( const CodecParameterMap& params); // Given that a decoder supports up to a given frame size (in pixels) at up to a // given number of frames per second, return the highest H.264 level where it // can guarantee that it will be able to support all valid encoded streams that // are within that level. -rtc::Optional SupportedLevel(int max_frame_pixel_count, float max_fps); +absl::optional SupportedLevel(int max_frame_pixel_count, float max_fps); // Returns canonical string representation as three hex bytes of the profile // level id, or returns nothing for invalid profile level ids. -rtc::Optional ProfileLevelIdToString( +absl::optional ProfileLevelIdToString( const ProfileLevelId& profile_level_id); // Generate codec parameters that will be used as answer in an SDP negotiation diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h index a316c709e2..a9b586a052 100644 --- a/media/base/mediachannel.h +++ b/media/base/mediachannel.h @@ -17,9 +17,9 @@ #include #include +#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_options.h" -#include "api/optional.h" #include "api/rtcerror.h" #include "api/rtpparameters.h" #include "api/rtpreceiverinterface.h" @@ -62,7 +62,8 @@ struct VideoFormat; const int kScreencastDefaultFps = 5; template -static std::string ToStringIfSet(const char* key, const rtc::Optional& val) { +static std::string ToStringIfSet(const char* key, + const absl::optional& val) { std::string str; if (val) { str = key; @@ -122,20 +123,20 @@ struct VideoOptions { // Enable denoising? This flag comes from the getUserMedia // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it // on to the codec options. Disabled by default. - rtc::Optional video_noise_reduction; + absl::optional video_noise_reduction; // Force screencast to use a minimum bitrate. This flag comes from // the PeerConnection constraint 'googScreencastMinBitrate'. It is // copied to the encoder config by WebRtcVideoChannel. - rtc::Optional screencast_min_bitrate_kbps; + absl::optional screencast_min_bitrate_kbps; // Set by screencast sources. Implies selection of encoding settings // suitable for screencast. Most likely not the right way to do // things, e.g., screencast of a text document and screencast of a // youtube video have different needs. - rtc::Optional is_screencast; + absl::optional is_screencast; private: template - static void SetFrom(rtc::Optional* s, const rtc::Optional& o) { + static void SetFrom(absl::optional* s, const absl::optional& o) { if (o) { *s = o; } @@ -328,7 +329,7 @@ struct MediaSenderInfo { float fraction_lost = 0.0f; int64_t rtt_ms = 0; std::string codec_name; - rtc::Optional codec_payload_type; + absl::optional codec_payload_type; std::vector local_stats; std::vector remote_stats; }; @@ -374,7 +375,7 @@ struct MediaReceiverInfo { int packets_lost = 0; float fraction_lost = 0.0f; std::string codec_name; - rtc::Optional codec_payload_type; + absl::optional codec_payload_type; std::vector local_stats; std::vector remote_stats; }; @@ -468,7 +469,7 @@ struct VideoSenderInfo : public MediaSenderInfo { int encode_usage_percent = 0; uint32_t frames_encoded = 0; bool has_entered_low_resolution = false; - rtc::Optional qp_sum; + absl::optional qp_sum; webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; // https://w3c.github.io/webrtc-stats/#dom-rtcvideosenderstats-hugeframessent uint32_t huge_frames_sent = 0; @@ -496,7 +497,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo { uint32_t frames_received = 0; uint32_t frames_decoded = 0; uint32_t frames_rendered = 0; - rtc::Optional qp_sum; + absl::optional qp_sum; int64_t interframe_delay_max_ms = -1; webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; @@ -526,7 +527,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo { // 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 DataSenderInfo : public MediaSenderInfo { diff --git a/media/base/videoadapter.cc b/media/base/videoadapter.cc index 52619831b4..ded1cc6a46 100644 --- a/media/base/videoadapter.cc +++ b/media/base/videoadapter.cc @@ -16,7 +16,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "media/base/mediaconstants.h" #include "media/base/videocommon.h" #include "rtc_base/arraysize.h" @@ -256,14 +256,14 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, } void VideoAdapter::OnOutputFormatRequest( - const rtc::Optional& format) { + const absl::optional& format) { rtc::CritScope cs(&critical_section_); requested_format_ = format; - next_frame_timestamp_ns_ = rtc::nullopt; + next_frame_timestamp_ns_ = absl::nullopt; } void VideoAdapter::OnResolutionFramerateRequest( - const rtc::Optional& target_pixel_count, + const absl::optional& target_pixel_count, int max_pixel_count, int max_framerate_fps) { rtc::CritScope cs(&critical_section_); diff --git a/media/base/videoadapter.h b/media/base/videoadapter.h index abf6069df7..4bb6574881 100644 --- a/media/base/videoadapter.h +++ b/media/base/videoadapter.h @@ -11,7 +11,7 @@ #ifndef MEDIA_BASE_VIDEOADAPTER_H_ #define MEDIA_BASE_VIDEOADAPTER_H_ -#include "api/optional.h" +#include "absl/types/optional.h" #include "media/base/videocommon.h" #include "rtc_base/constructormagic.h" #include "rtc_base/criticalsection.h" @@ -48,7 +48,7 @@ class VideoAdapter { // requested aspect ratio is orientation agnostic and will be adjusted to // maintain the input orientation, so it doesn't matter if e.g. 1280x720 or // 720x1280 is requested. - void OnOutputFormatRequest(const rtc::Optional& format); + void OnOutputFormatRequest(const absl::optional& format); // Requests the output frame size from |AdaptFrameResolution| to have as close // as possible to |target_pixel_count| pixels (if set) but no more than @@ -58,7 +58,7 @@ class VideoAdapter { // Set |max_pixel_count| and/or |max_framerate_fps| to // std::numeric_limit::max() if no upper limit is desired. void OnResolutionFramerateRequest( - const rtc::Optional& target_pixel_count, + const absl::optional& target_pixel_count, int max_pixel_count, int max_framerate_fps); @@ -75,13 +75,13 @@ class VideoAdapter { // Resolution must be divisible by this factor. const int required_resolution_alignment_; // The target timestamp for the next frame based on requested format. - rtc::Optional next_frame_timestamp_ns_ + absl::optional next_frame_timestamp_ns_ RTC_GUARDED_BY(critical_section_); // Max number of pixels requested via calls to OnOutputFormatRequest, // OnResolutionRequest respectively. // The adapted output format is the minimum of these. - rtc::Optional requested_format_ + absl::optional requested_format_ RTC_GUARDED_BY(critical_section_); int resolution_request_target_pixel_count_ RTC_GUARDED_BY(critical_section_); int resolution_request_max_pixel_count_ RTC_GUARDED_BY(critical_section_); diff --git a/media/base/videoadapter_unittest.cc b/media/base/videoadapter_unittest.cc index 1d6fd51656..a973778f1d 100644 --- a/media/base/videoadapter_unittest.cc +++ b/media/base/videoadapter_unittest.cc @@ -379,7 +379,7 @@ TEST_F(VideoAdapterTest, AdaptFramerateOntheFly) { // Do not adapt the frame rate or the resolution. Expect no frame drop, no // cropping, and no resolution change. TEST_F(VideoAdapterTest, AdaptFramerateRequestMax) { - adapter_.OnResolutionFramerateRequest(rtc::nullopt, + adapter_.OnResolutionFramerateRequest(absl::nullopt, std::numeric_limits::max(), std::numeric_limits::max()); @@ -396,7 +396,7 @@ TEST_F(VideoAdapterTest, AdaptFramerateRequestMax) { } TEST_F(VideoAdapterTest, AdaptFramerateRequestZero) { - adapter_.OnResolutionFramerateRequest(rtc::nullopt, + adapter_.OnResolutionFramerateRequest(absl::nullopt, std::numeric_limits::max(), 0); for (int i = 0; i < 10; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -411,7 +411,7 @@ TEST_F(VideoAdapterTest, AdaptFramerateRequestZero) { // the number of dropped frames to be half of the number the captured frames. TEST_F(VideoAdapterTest, AdaptFramerateRequestHalf) { adapter_.OnResolutionFramerateRequest( - rtc::nullopt, std::numeric_limits::max(), kDefaultFps / 2); + absl::nullopt, std::numeric_limits::max(), kDefaultFps / 2); for (int i = 0; i < 10; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -732,7 +732,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(720, out_height_); // Adapt down one step. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 1280 * 720 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 1280 * 720 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -743,7 +743,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(540, out_height_); // Adapt down one step more. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 960 * 540 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 960 * 540 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -754,7 +754,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(360, out_height_); // Adapt down one step more. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 360 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -810,7 +810,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestMaxZero) { EXPECT_EQ(1280, out_width_); EXPECT_EQ(720, out_height_); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 0, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 0, std::numeric_limits::max()); EXPECT_FALSE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -819,7 +819,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestMaxZero) { TEST_F(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { // Large step down. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 360 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -842,7 +842,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { } TEST_F(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 360 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -862,7 +862,7 @@ TEST_F(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 960 * 720, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 960 * 720, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -882,7 +882,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestReset) { EXPECT_EQ(1280, out_width_); EXPECT_EQ(720, out_height_); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 360 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 - 1, std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, @@ -892,7 +892,7 @@ TEST_F(VideoAdapterTest, TestOnResolutionRequestReset) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, + adapter_.OnResolutionFramerateRequest(absl::nullopt, std::numeric_limits::max(), std::numeric_limits::max()); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, @@ -918,7 +918,7 @@ TEST_F(VideoAdapterTest, TestCroppingWithResolutionRequest) { EXPECT_EQ(360, out_height_); // Adapt down one step. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 360 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 - 1, std::numeric_limits::max()); // Expect cropping to 16:9 format and 3/4 scaling. EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, @@ -930,7 +930,7 @@ TEST_F(VideoAdapterTest, TestCroppingWithResolutionRequest) { EXPECT_EQ(270, out_height_); // Adapt down one step more. - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 480 * 270 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 480 * 270 - 1, std::numeric_limits::max()); // Expect cropping to 16:9 format and 1/2 scaling. EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, @@ -982,7 +982,7 @@ TEST_F(VideoAdapterTest, TestCroppingOddResolution) { // Ask for 640x360 (16:9 aspect), with 3/16 scaling. adapter_.OnOutputFormatRequest( VideoFormat(640, 360, 0, FOURCC_I420)); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 360 * 3 / 16 * 3 / 16, std::numeric_limits::max()); @@ -1004,8 +1004,7 @@ TEST_F(VideoAdapterTest, TestAdaptToVerySmallResolution) { const int w = 1920; const int h = 1080; adapter_.OnOutputFormatRequest(VideoFormat(w, h, 0, FOURCC_I420)); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, - w * h * 1 / 16 * 1 / 16, + adapter_.OnResolutionFramerateRequest(absl::nullopt, w * h * 1 / 16 * 1 / 16, std::numeric_limits::max()); // Send 1920x1080 (16:9 aspect). @@ -1052,7 +1051,7 @@ TEST_F(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) { &cropped_width_, &cropped_height_, &out_width_, &out_height_)); - adapter_.OnResolutionFramerateRequest(rtc::nullopt, 640 * 480 - 1, + adapter_.OnResolutionFramerateRequest(absl::nullopt, 640 * 480 - 1, std::numeric_limits::max()); // Still expect all frames to be dropped diff --git a/media/engine/fakewebrtccall.h b/media/engine/fakewebrtccall.h index 2c1096595b..00bd079d99 100644 --- a/media/engine/fakewebrtccall.h +++ b/media/engine/fakewebrtccall.h @@ -184,7 +184,7 @@ class FakeVideoSendStream final bool framerate_scaling_enabled_; rtc::VideoSourceInterface* source_; int num_swapped_frames_; - rtc::Optional last_frame_; + absl::optional last_frame_; webrtc::VideoSendStream::Stats stats_; int num_encoder_reconfigurations_ = 0; }; diff --git a/media/engine/payload_type_mapper.cc b/media/engine/payload_type_mapper.cc index 1927f43a00..57397d1ae6 100644 --- a/media/engine/payload_type_mapper.cc +++ b/media/engine/payload_type_mapper.cc @@ -85,7 +85,7 @@ PayloadTypeMapper::PayloadTypeMapper() PayloadTypeMapper::~PayloadTypeMapper() = default; -rtc::Optional PayloadTypeMapper::GetMappingFor( +absl::optional PayloadTypeMapper::GetMappingFor( const webrtc::SdpAudioFormat& format) { auto iter = mappings_.find(format); if (iter != mappings_.end()) @@ -102,19 +102,19 @@ rtc::Optional PayloadTypeMapper::GetMappingFor( } } - return rtc::nullopt; + return absl::nullopt; } -rtc::Optional PayloadTypeMapper::FindMappingFor( +absl::optional PayloadTypeMapper::FindMappingFor( const webrtc::SdpAudioFormat& format) const { auto iter = mappings_.find(format); if (iter != mappings_.end()) return iter->second; - return rtc::nullopt; + return absl::nullopt; } -rtc::Optional PayloadTypeMapper::ToAudioCodec( +absl::optional PayloadTypeMapper::ToAudioCodec( const webrtc::SdpAudioFormat& format) { // TODO(ossu): We can safely set bitrate to zero here, since that field is // not presented in the SDP. It is used to ferry around some target bitrate @@ -129,7 +129,7 @@ rtc::Optional PayloadTypeMapper::ToAudioCodec( return std::move(codec); } - return rtc::nullopt; + return absl::nullopt; } bool PayloadTypeMapper::SdpAudioFormatOrdering::operator()( diff --git a/media/engine/payload_type_mapper.h b/media/engine/payload_type_mapper.h index 914c08c97b..d8ab4a4261 100644 --- a/media/engine/payload_type_mapper.h +++ b/media/engine/payload_type_mapper.h @@ -14,8 +14,8 @@ #include #include +#include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" -#include "api/optional.h" #include "media/base/codec.h" namespace cricket { @@ -30,15 +30,16 @@ class PayloadTypeMapper { // Finds the current payload type for |format| or assigns a new one, if no // current mapping exists. Will return an empty value if it was unable to // create a mapping, i.e. if all dynamic payload type ids have been used up. - rtc::Optional GetMappingFor(const webrtc::SdpAudioFormat& format); + absl::optional GetMappingFor(const webrtc::SdpAudioFormat& format); // Finds the current payload type for |format|, if any. Returns an empty value // if no payload type mapping exists for the format. - rtc::Optional FindMappingFor(const webrtc::SdpAudioFormat& format) const; + absl::optional FindMappingFor( + const webrtc::SdpAudioFormat& format) const; // Like GetMappingFor, but fills in an AudioCodec structure with the necessary // information instead. - rtc::Optional ToAudioCodec(const webrtc::SdpAudioFormat& format); + absl::optional ToAudioCodec(const webrtc::SdpAudioFormat& format); private: struct SdpAudioFormatOrdering { diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc index bce0090ff8..aff2529a1b 100644 --- a/media/engine/webrtcvideoengine.cc +++ b/media/engine/webrtcvideoengine.cc @@ -358,46 +358,46 @@ bool GetVp9LayersFromFieldTrialGroup(size_t* num_spatial_layers, return true; } -rtc::Optional GetVp9SpatialLayersFromFieldTrial() { +absl::optional GetVp9SpatialLayersFromFieldTrial() { size_t num_sl; size_t num_tl; if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) { return num_sl; } - return rtc::nullopt; + return absl::nullopt; } -rtc::Optional GetVp9TemporalLayersFromFieldTrial() { +absl::optional GetVp9TemporalLayersFromFieldTrial() { size_t num_sl; size_t num_tl; if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) { return num_tl; } - return rtc::nullopt; + return absl::nullopt; } 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; } @@ -493,7 +493,7 @@ DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( WebRtcVideoChannel* channel, uint32_t ssrc) { - rtc::Optional default_recv_ssrc = + absl::optional default_recv_ssrc = channel->GetDefaultReceiveStreamSsrc(); if (default_recv_ssrc) { @@ -524,7 +524,7 @@ void DefaultUnsignalledSsrcHandler::SetDefaultSink( WebRtcVideoChannel* channel, rtc::VideoSinkInterface* sink) { default_sink_ = sink; - rtc::Optional default_recv_ssrc = + absl::optional default_recv_ssrc = channel->GetDefaultReceiveStreamSsrc(); if (default_recv_ssrc) { channel->SetSink(*default_recv_ssrc, default_sink_); @@ -629,7 +629,7 @@ WebRtcVideoChannel::~WebRtcVideoChannel() { delete kv.second; } -rtc::Optional +absl::optional WebRtcVideoChannel::SelectSendVideoCodec( const std::vector& remote_mapped_codecs) const { const std::vector local_supported_codecs = @@ -645,7 +645,7 @@ WebRtcVideoChannel::SelectSendVideoCodec( return remote_mapped_codec; } // No remote codec was supported. - return rtc::nullopt; + return absl::nullopt; } bool WebRtcVideoChannel::NonFlexfecReceiveCodecsHaveChanged( @@ -686,7 +686,7 @@ bool WebRtcVideoChannel::GetChangedSendParameters( } // Select one of the remote codecs that will be used as send codec. - rtc::Optional selected_send_codec = + absl::optional selected_send_codec = SelectSendVideoCodec(MapCodecs(params.codecs)); if (!selected_send_codec) { @@ -712,7 +712,7 @@ bool WebRtcVideoChannel::GetChangedSendParameters( params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); if (!send_rtp_extensions_ || (*send_rtp_extensions_ != filtered_extensions)) { changed_params->rtp_header_extensions = - rtc::Optional>(filtered_extensions); + absl::optional>(filtered_extensions); } if (params.mid != send_params_.mid) { @@ -965,7 +965,7 @@ bool WebRtcVideoChannel::GetChangedRecvParameters( if (NonFlexfecReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) { changed_params->codec_settings = - rtc::Optional>(mapped_codecs); + absl::optional>(mapped_codecs); } // Handle RTP header extensions. @@ -973,7 +973,7 @@ bool WebRtcVideoChannel::GetChangedRecvParameters( params.extensions, webrtc::RtpExtension::IsSupportedForVideo, false); if (filtered_extensions != recv_rtp_extensions_) { changed_params->rtp_header_extensions = - rtc::Optional>(filtered_extensions); + absl::optional>(filtered_extensions); } int flexfec_payload_type = mapped_codecs.front().flexfec_payload_type; @@ -1532,9 +1532,9 @@ void WebRtcVideoChannel::SetInterface(NetworkInterface* iface) { kVideoRtpBufferSize); } -rtc::Optional WebRtcVideoChannel::GetDefaultReceiveStreamSsrc() { +absl::optional WebRtcVideoChannel::GetDefaultReceiveStreamSsrc() { rtc::CritScope stream_lock(&stream_crit_); - rtc::Optional ssrc; + absl::optional ssrc; for (auto it = receive_streams_.begin(); it != receive_streams_.end(); ++it) { if (it->second->IsDefaultStream()) { ssrc.emplace(it->first); @@ -1563,7 +1563,7 @@ WebRtcVideoChannel::WebRtcVideoSendStream::VideoSendStreamParameters:: webrtc::VideoSendStream::Config config, const VideoOptions& options, int max_bitrate_bps, - const rtc::Optional& codec_settings) + const absl::optional& codec_settings) : config(std::move(config)), options(options), max_bitrate_bps(max_bitrate_bps), @@ -1577,8 +1577,8 @@ WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( const VideoOptions& options, bool enable_cpu_overuse_detection, int max_bitrate_bps, - const rtc::Optional& codec_settings, - const rtc::Optional>& rtp_extensions, + const absl::optional& codec_settings, + const absl::optional>& rtp_extensions, // TODO(deadbeef): Don't duplicate information between send_params, // rtp_extensions, options, etc. const VideoSendParameters& send_params) @@ -2201,7 +2201,7 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::GetSsrcs() const { return stream_params_.ssrcs; } -rtc::Optional +absl::optional WebRtcVideoChannel::WebRtcVideoReceiveStream::GetFirstPrimarySsrc() const { std::vector primary_ssrcs; stream_params_.GetPrimarySsrcs(&primary_ssrcs); @@ -2209,7 +2209,7 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::GetFirstPrimarySsrc() const { if (primary_ssrcs.empty()) { RTC_LOG(LS_WARNING) << "Empty primary ssrcs vector, returning empty optional"; - return rtc::nullopt; + return absl::nullopt; } else { return primary_ssrcs[0]; } diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h index 867fd289e5..041eb6a293 100644 --- a/media/engine/webrtcvideoengine.h +++ b/media/engine/webrtcvideoengine.h @@ -17,8 +17,8 @@ #include #include +#include "absl/types/optional.h" #include "api/call/transport.h" -#include "api/optional.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" @@ -162,7 +162,7 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { // Implemented for VideoMediaChannelTest. bool sending() const { return sending_; } - rtc::Optional GetDefaultReceiveStreamSsrc(); + absl::optional GetDefaultReceiveStreamSsrc(); StreamParams unsignaled_stream_params() { return unsignaled_stream_params_; } @@ -200,22 +200,22 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { struct ChangedSendParameters { // These optionals are unset if not changed. - rtc::Optional codec; - rtc::Optional> rtp_header_extensions; - rtc::Optional mid; - rtc::Optional max_bandwidth_bps; - rtc::Optional conference_mode; - rtc::Optional rtcp_mode; + absl::optional codec; + absl::optional> rtp_header_extensions; + absl::optional mid; + absl::optional max_bandwidth_bps; + absl::optional conference_mode; + absl::optional rtcp_mode; }; struct ChangedRecvParameters { // These optionals are unset if not changed. - rtc::Optional> codec_settings; - rtc::Optional> rtp_header_extensions; + absl::optional> codec_settings; + absl::optional> rtp_header_extensions; // Keep track of the FlexFEC payload type separately from |codec_settings|. // This allows us to recreate the FlexfecReceiveStream separately from the // VideoReceiveStream when the FlexFEC payload type is changed. - rtc::Optional flexfec_payload_type; + absl::optional flexfec_payload_type; }; bool GetChangedSendParameters(const VideoSendParameters& params, @@ -250,8 +250,8 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { const VideoOptions& options, bool enable_cpu_overuse_detection, int max_bitrate_bps, - const rtc::Optional& codec_settings, - const rtc::Optional>& rtp_extensions, + const absl::optional& codec_settings, + const absl::optional>& rtp_extensions, const VideoSendParameters& send_params); virtual ~WebRtcVideoSendStream(); @@ -286,12 +286,12 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { webrtc::VideoSendStream::Config config, const VideoOptions& options, int max_bitrate_bps, - const rtc::Optional& codec_settings); + const absl::optional& codec_settings); webrtc::VideoSendStream::Config config; VideoOptions options; int max_bitrate_bps; bool conference_mode; - rtc::Optional codec_settings; + absl::optional codec_settings; // Sent resolutions + bitrates etc. by the underlying VideoSendStream, // typically changes when setting a new resolution or reconfiguring // bitrates. @@ -402,7 +402,7 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { std::string GetCodecNameFromPayloadType(int payload_type); - rtc::Optional GetFirstPrimarySsrc() const; + absl::optional GetFirstPrimarySsrc() const; webrtc::Call* const call_; StreamParams stream_params_; @@ -444,7 +444,7 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { // Select what video codec will be used for sending, i.e. what codec is used // for local encoding, based on supported remote codecs. The first remote // codec that is supported locally will be selected. - rtc::Optional SelectSendVideoCodec( + absl::optional SelectSendVideoCodec( const std::vector& remote_mapped_codecs) const; static bool NonFlexfecReceiveCodecsHaveChanged( @@ -477,8 +477,8 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { std::set send_ssrcs_ RTC_GUARDED_BY(stream_crit_); std::set receive_ssrcs_ RTC_GUARDED_BY(stream_crit_); - rtc::Optional send_codec_; - rtc::Optional> send_rtp_extensions_; + absl::optional send_codec_; + absl::optional> send_rtp_extensions_; webrtc::VideoEncoderFactory* const encoder_factory_; DecoderFactoryAdapter* const decoder_factory_; diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc index 2cb2b20f7d..2fc5bec31e 100644 --- a/media/engine/webrtcvideoengine_unittest.cc +++ b/media/engine/webrtcvideoengine_unittest.cc @@ -584,7 +584,7 @@ size_t WebRtcVideoEngineTest::GetEngineCodecIndex( // The tests only use H264 Constrained Baseline. Make sure we don't return // an internal H264 codec from the engine with a different H264 profile. if (CodecNamesEq(name.c_str(), kH264CodecName)) { - const rtc::Optional profile_level_id = + const absl::optional profile_level_id = webrtc::H264::ParseSdpProfileLevelId(engine_codec.params); if (profile_level_id->profile != webrtc::H264::kProfileConstrainedBaseline) { @@ -5320,7 +5320,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPriorityOneStream) { // Check that the vector of VideoStreams also was propagated correctly. Note // that this is testing the behavior of the FakeVideoSendStream, which mimics // the calls to CreateEncoderStreams to get the VideoStreams. - EXPECT_EQ(rtc::Optional(new_bitrate_priority), + EXPECT_EQ(absl::optional(new_bitrate_priority), video_send_stream->GetVideoStreams()[0].bitrate_priority); } @@ -5381,13 +5381,13 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) { // these are created appropriately for the simulcast case. EXPECT_EQ(rtc::checked_cast(kNumSimulcastStreams), video_send_stream->GetVideoStreams().size()); - EXPECT_EQ(rtc::Optional(new_bitrate_priority), + EXPECT_EQ(absl::optional(new_bitrate_priority), video_send_stream->GetVideoStreams()[0].bitrate_priority); // Since we are only setting bitrate priority per-sender, the other // VideoStreams should have a bitrate priority of 0. - EXPECT_EQ(rtc::nullopt, + EXPECT_EQ(absl::nullopt, video_send_stream->GetVideoStreams()[1].bitrate_priority); - EXPECT_EQ(rtc::nullopt, + EXPECT_EQ(absl::nullopt, video_send_stream->GetVideoStreams()[2].bitrate_priority); EXPECT_TRUE(channel_->SetVideoSend(primary_ssrc, nullptr, nullptr)); } diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index 60f819345f..fd34d08541 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -147,7 +147,7 @@ bool VerifyUniquePayloadTypes(const std::vector& codecs) { return it == payload_types.end(); } -rtc::Optional GetAudioNetworkAdaptorConfig( +absl::optional GetAudioNetworkAdaptorConfig( const AudioOptions& options) { if (options.audio_network_adaptor && *options.audio_network_adaptor && options.audio_network_adaptor_config) { @@ -155,14 +155,14 @@ rtc::Optional GetAudioNetworkAdaptorConfig( // equals true and |options_.audio_network_adaptor_config| has a value. return options.audio_network_adaptor_config; } - return rtc::nullopt; + return absl::nullopt; } // |max_send_bitrate_bps| is the bitrate from "b=" in SDP. // |rtp_max_bitrate_bps| is the bitrate from RtpSender::SetParameters. -rtc::Optional ComputeSendBitrate(int max_send_bitrate_bps, - rtc::Optional rtp_max_bitrate_bps, - const webrtc::AudioCodecSpec& spec) { +absl::optional ComputeSendBitrate(int max_send_bitrate_bps, + absl::optional rtp_max_bitrate_bps, + const webrtc::AudioCodecSpec& spec) { // If application-configured bitrate is set, take minimum of that and SDP // bitrate. const int bps = @@ -181,7 +181,7 @@ rtc::Optional ComputeSendBitrate(int max_send_bitrate_bps, << " to bitrate " << bps << " bps" << ", requires at least " << spec.info.min_bitrate_bps << " bps."; - return rtc::nullopt; + return absl::nullopt; } if (spec.info.HasFixedBitrate()) { @@ -683,7 +683,7 @@ AudioCodecs WebRtcVoiceEngine::CollectCodecs( auto map_format = [&mapper](const webrtc::SdpAudioFormat& format, AudioCodecs* out) { - rtc::Optional opt_codec = mapper.ToAudioCodec(format); + absl::optional opt_codec = mapper.ToAudioCodec(format); if (opt_codec) { if (out) { out->push_back(*opt_codec); @@ -698,7 +698,7 @@ AudioCodecs WebRtcVoiceEngine::CollectCodecs( for (const auto& spec : specs) { // We need to do some extra stuff before adding the main codecs to out. - rtc::Optional opt_codec = map_format(spec.format, nullptr); + absl::optional opt_codec = map_format(spec.format, nullptr); if (opt_codec) { AudioCodec& codec = *opt_codec; if (spec.info.supports_network_adaption) { @@ -750,15 +750,15 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream const std::string& mid, const std::string& c_name, const std::string track_id, - const rtc::Optional& + const absl::optional& send_codec_spec, const std::vector& extensions, int max_send_bitrate_bps, - const rtc::Optional& audio_network_adaptor_config, + const absl::optional& audio_network_adaptor_config, webrtc::Call* call, webrtc::Transport* send_transport, const rtc::scoped_refptr& encoder_factory, - const rtc::Optional codec_pair_id) + const absl::optional codec_pair_id) : call_(call), config_(send_transport), send_side_bwe_with_overhead_( @@ -815,7 +815,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream } void SetAudioNetworkAdaptorConfig( - const rtc::Optional& audio_network_adaptor_config) { + const absl::optional& audio_network_adaptor_config) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); if (config_.audio_network_adaptor_config == audio_network_adaptor_config) { return; @@ -976,7 +976,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream return error; } - rtc::Optional send_rate; + absl::optional send_rate; if (audio_codec_spec_) { send_rate = ComputeSendBitrate(max_send_bitrate_bps_, parameters.encodings[0].max_bitrate_bps, @@ -986,7 +986,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream } } - const rtc::Optional old_rtp_max_bitrate = + const absl::optional old_rtp_max_bitrate = rtp_parameters_.encodings[0].max_bitrate_bps; double old_priority = rtp_parameters_.encodings[0].bitrate_priority; rtp_parameters_ = parameters; @@ -1122,7 +1122,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream bool muted_ = false; int max_send_bitrate_bps_; webrtc::RtpParameters rtp_parameters_; - rtc::Optional audio_codec_spec_; + absl::optional audio_codec_spec_; RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); }; @@ -1140,7 +1140,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { webrtc::Transport* rtcp_send_transport, const rtc::scoped_refptr& decoder_factory, const std::map& decoder_map, - rtc::Optional codec_pair_id, + absl::optional codec_pair_id, size_t jitter_buffer_max_packets, bool jitter_buffer_fast_accelerate) : call_(call), config_() { @@ -1515,7 +1515,7 @@ bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { return false; } - rtc::Optional audio_network_adaptor_config = + absl::optional audio_network_adaptor_config = GetAudioNetworkAdaptorConfig(options_); for (auto& it : send_streams_) { it.second->SetAudioNetworkAdaptorConfig(audio_network_adaptor_config); @@ -1608,7 +1608,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs( bool WebRtcVoiceMediaChannel::SetSendCodecs( const std::vector& codecs) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - dtmf_payload_type_ = rtc::nullopt; + dtmf_payload_type_ = absl::nullopt; dtmf_payload_freq_ = -1; // Validate supplied codecs list. @@ -1638,9 +1638,10 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( } // Scan through the list to figure out the codec to use for sending. - rtc::Optional send_codec_spec; + absl::optional + send_codec_spec; webrtc::BitrateConstraints bitrate_config; - rtc::Optional voice_codec_info; + absl::optional voice_codec_info; for (const AudioCodec& voice_codec : codecs) { if (!(IsCodec(voice_codec, kCnCodecName) || IsCodec(voice_codec, kDtmfCodecName) || @@ -1811,7 +1812,7 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) { return false; } - rtc::Optional audio_network_adaptor_config = + absl::optional audio_network_adaptor_config = GetAudioNetworkAdaptorConfig(options_); WebRtcAudioSendStream* stream = new WebRtcAudioSendStream( ssrc, mid_, sp.cname, sp.id, send_codec_spec_, send_rtp_extensions_, diff --git a/media/engine/webrtcvoiceengine.h b/media/engine/webrtcvoiceengine.h index 21b352bf87..a95ff9f83a 100644 --- a/media/engine/webrtcvoiceengine.h +++ b/media/engine/webrtcvoiceengine.h @@ -124,10 +124,10 @@ class WebRtcVoiceEngine final { // in case they are missing in the audio options. We need to do this because // SetExtraOptions() will revert to defaults for options which are not // provided. - rtc::Optional extended_filter_aec_; - rtc::Optional delay_agnostic_aec_; - rtc::Optional experimental_ns_; - rtc::Optional intelligibility_enhancer_; + absl::optional extended_filter_aec_; + absl::optional delay_agnostic_aec_; + absl::optional experimental_ns_; + absl::optional intelligibility_enhancer_; // Jitter buffer settings for new streams. size_t audio_jitter_buffer_max_packets_ = 50; bool audio_jitter_buffer_fast_accelerate_ = false; @@ -241,7 +241,7 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel, int max_send_bitrate_bps_ = 0; AudioOptions options_; - rtc::Optional dtmf_payload_type_; + absl::optional dtmf_payload_type_; int dtmf_payload_freq_ = -1; bool recv_transport_cc_enabled_ = false; bool recv_nack_enabled_ = false; @@ -277,7 +277,7 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel, std::map recv_streams_; std::vector recv_rtp_extensions_; - rtc::Optional + absl::optional send_codec_spec_; // TODO(kwiberg): Per-SSRC codec pair IDs? diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc index 53c4393e33..b03af34661 100644 --- a/media/engine/webrtcvoiceengine_unittest.cc +++ b/media/engine/webrtcvoiceengine_unittest.cc @@ -386,11 +386,12 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_EQ(expected_bitrate, spec->target_bitrate_bps); } - rtc::Optional GetCodecBitrate(int32_t ssrc) { + absl::optional GetCodecBitrate(int32_t ssrc) { return GetSendStreamConfig(ssrc).send_codec_spec->target_bitrate_bps; } - const rtc::Optional& GetAudioNetworkAdaptorConfig(int32_t ssrc) { + const absl::optional& GetAudioNetworkAdaptorConfig( + int32_t ssrc) { return GetSendStreamConfig(ssrc).audio_network_adaptor_config; } @@ -1092,7 +1093,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRtpParametersEncodingsActive) { // Now change it back to active and verify we resume sending. // This should occur even when other parameters are updated. parameters.encodings[0].active = true; - parameters.encodings[0].max_bitrate_bps = rtc::Optional(6000); + parameters.encodings[0].max_bitrate_bps = absl::optional(6000); EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, parameters).ok()); EXPECT_TRUE(GetSendStream(kSsrcX).IsSending()); } @@ -1344,7 +1345,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { EXPECT_EQ(22000, send_codec_spec.target_bitrate_bps); EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); EXPECT_NE(send_codec_spec.format.clockrate_hz, 8000); - EXPECT_EQ(rtc::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); EXPECT_FALSE(channel_->CanInsertDtmf()); } @@ -1943,7 +1944,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); - EXPECT_EQ(rtc::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); } // Set PCMU(8K) and CN(8K). VAD should be activated. parameters.codecs[1] = kCn8000Codec; @@ -1960,7 +1961,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); - EXPECT_EQ(rtc::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); } } @@ -2155,7 +2156,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { const auto& send_codec_spec = *call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); - EXPECT_EQ(rtc::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); } } @@ -2322,7 +2323,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) { cricket::AudioOptions options; options.audio_network_adaptor = false; SetAudioSend(kSsrcX, true, nullptr, &options); - EXPECT_EQ(rtc::nullopt, GetAudioNetworkAdaptorConfig(kSsrcX)); + EXPECT_EQ(absl::nullopt, GetAudioNetworkAdaptorConfig(kSsrcX)); } TEST_F(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { @@ -2334,7 +2335,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { GetAudioNetworkAdaptorConfig(kSsrcX)); const int initial_num = call_.GetNumCreatedSendStreams(); cricket::AudioOptions options; - options.audio_network_adaptor = rtc::nullopt; + options.audio_network_adaptor = absl::nullopt; // Unvalued |options.audio_network_adaptor|.should not reset audio network // adaptor. SetAudioSend(kSsrcX, true, nullptr, &options); diff --git a/ortc/BUILD.gn b/ortc/BUILD.gn index a45799cffa..08bdf8cd07 100644 --- a/ortc/BUILD.gn +++ b/ortc/BUILD.gn @@ -34,7 +34,6 @@ rtc_static_library("ortc") { # libjingle_peerconnection. deps = [ "../api:libjingle_peerconnection_api", - "../api:optional", "../api:ortc_api", "../api/video_codecs:builtin_video_decoder_factory", "../api/video_codecs:builtin_video_encoder_factory", @@ -54,6 +53,7 @@ rtc_static_library("ortc") { "../rtc_base:checks", "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] if (!build_with_chromium && is_clang) { diff --git a/ortc/rtpparametersconversion.cc b/ortc/rtpparametersconversion.cc index 1c336e2996..ff5bece5c9 100644 --- a/ortc/rtpparametersconversion.cc +++ b/ortc/rtpparametersconversion.cc @@ -230,7 +230,7 @@ RTCErrorOr ToCricketStreamParamsVec( return std::move(cricket_streams); } -rtc::Optional ToRtcpFeedback( +absl::optional ToRtcpFeedback( const cricket::FeedbackParam& cricket_feedback) { if (cricket_feedback.id() == cricket::kRtcpFbParamCcm) { if (cricket_feedback.param() == cricket::kRtcpFbCcmParamFir) { @@ -238,7 +238,7 @@ rtc::Optional ToRtcpFeedback( } else { RTC_LOG(LS_WARNING) << "Unsupported parameter for CCM RTCP feedback: " << cricket_feedback.param(); - return rtc::nullopt; + return absl::nullopt; } } else if (cricket_feedback.id() == cricket::kRtcpFbParamNack) { if (cricket_feedback.param().empty()) { @@ -249,13 +249,13 @@ rtc::Optional ToRtcpFeedback( } else { RTC_LOG(LS_WARNING) << "Unsupported parameter for NACK RTCP feedback: " << cricket_feedback.param(); - return rtc::nullopt; + return absl::nullopt; } } else if (cricket_feedback.id() == cricket::kRtcpFbParamRemb) { if (!cricket_feedback.param().empty()) { RTC_LOG(LS_WARNING) << "Unsupported parameter for REMB RTCP feedback: " << cricket_feedback.param(); - return rtc::nullopt; + return absl::nullopt; } else { return RtcpFeedback(RtcpFeedbackType::REMB); } @@ -264,14 +264,14 @@ rtc::Optional ToRtcpFeedback( RTC_LOG(LS_WARNING) << "Unsupported parameter for transport-cc RTCP feedback: " << cricket_feedback.param(); - return rtc::nullopt; + return absl::nullopt; } else { return RtcpFeedback(RtcpFeedbackType::TRANSPORT_CC); } } RTC_LOG(LS_WARNING) << "Unsupported RTCP feedback type: " << cricket_feedback.id(); - return rtc::nullopt; + return absl::nullopt; } std::vector ToRtpEncodings( @@ -328,7 +328,7 @@ RtpCodecCapability ToRtpCodecCapability(const C& cricket_codec) { codec.preferred_payload_type.emplace(cricket_codec.id); for (const cricket::FeedbackParam& cricket_feedback : cricket_codec.feedback_params.params()) { - rtc::Optional feedback = ToRtcpFeedback(cricket_feedback); + absl::optional feedback = ToRtcpFeedback(cricket_feedback); if (feedback) { codec.rtcp_feedback.push_back(feedback.value()); } @@ -368,7 +368,7 @@ RtpCodecParameters ToRtpCodecParameters(const C& cricket_codec) { codec_param.payload_type = cricket_codec.id; for (const cricket::FeedbackParam& cricket_feedback : cricket_codec.feedback_params.params()) { - rtc::Optional feedback = ToRtcpFeedback(cricket_feedback); + absl::optional feedback = ToRtcpFeedback(cricket_feedback); if (feedback) { codec_param.rtcp_feedback.push_back(feedback.value()); } diff --git a/ortc/rtpparametersconversion.h b/ortc/rtpparametersconversion.h index c75e35440f..c5aa16b588 100644 --- a/ortc/rtpparametersconversion.h +++ b/ortc/rtpparametersconversion.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/rtcerror.h" #include "api/rtpparameters.h" #include "media/base/codec.h" @@ -80,7 +80,7 @@ RTCErrorOr ToCricketStreamParamsVec( // Returns empty value if |cricket_feedback| is a feedback type not // supported/recognized. -rtc::Optional ToRtcpFeedback( +absl::optional ToRtcpFeedback( const cricket::FeedbackParam& cricket_feedback); std::vector ToRtpEncodings( diff --git a/ortc/rtpparametersconversion_unittest.cc b/ortc/rtpparametersconversion_unittest.cc index d08ce9a19c..ddf761d3f0 100644 --- a/ortc/rtpparametersconversion_unittest.cc +++ b/ortc/rtpparametersconversion_unittest.cc @@ -373,7 +373,7 @@ TEST(RtpParametersConversionTest, ToCricketStreamParamsVecMultipleEncodings) { } TEST(RtpParametersConversionTest, ToRtcpFeedback) { - rtc::Optional result = ToRtcpFeedback({"ccm", "fir"}); + absl::optional result = ToRtcpFeedback({"ccm", "fir"}); EXPECT_EQ(RtcpFeedback(RtcpFeedbackType::CCM, RtcpFeedbackMessageType::FIR), *result); result = ToRtcpFeedback(cricket::FeedbackParam("nack")); @@ -391,7 +391,7 @@ TEST(RtpParametersConversionTest, ToRtcpFeedback) { TEST(RtpParametersConversionTest, ToRtcpFeedbackErrors) { // CCM with missing or invalid message type. - rtc::Optional result = ToRtcpFeedback({"ccm", "pli"}); + absl::optional result = ToRtcpFeedback({"ccm", "pli"}); EXPECT_FALSE(result); result = ToRtcpFeedback(cricket::FeedbackParam("ccm")); EXPECT_FALSE(result); diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 07d1f711b6..55e96cafc4 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -83,7 +83,6 @@ rtc_static_library("rtc_p2p") { deps = [ "../api:libjingle_peerconnection_api", - "../api:optional", "../api:ortc_api", "../logging:ice_log", "../rtc_base:checks", @@ -91,6 +90,7 @@ rtc_static_library("rtc_p2p") { "../rtc_base:safe_minmax", "../rtc_base:stringutils", "../system_wrappers:field_trial_api", + "//third_party/abseil-cpp/absl/types:optional", ] if (build_with_chromium) { diff --git a/p2p/base/dtlstransport.cc b/p2p/base/dtlstransport.cc index e17d5c375d..1bb1a6af2b 100644 --- a/p2p/base/dtlstransport.cc +++ b/p2p/base/dtlstransport.cc @@ -457,7 +457,7 @@ int DtlsTransport::GetError() { return ice_transport_->GetError(); } -rtc::Optional DtlsTransport::network_route() const { +absl::optional DtlsTransport::network_route() const { return ice_transport_->network_route(); } @@ -693,7 +693,7 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { } void DtlsTransport::OnNetworkRouteChanged( - rtc::Optional network_route) { + absl::optional network_route) { SignalNetworkRouteChanged(network_route); } @@ -799,7 +799,7 @@ void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { void DtlsTransport::ConfigureHandshakeTimeout() { RTC_DCHECK(dtls_); - rtc::Optional rtt = ice_transport_->GetRttEstimate(); + absl::optional rtt = ice_transport_->GetRttEstimate(); if (rtt) { // Limit the timeout to a reasonable range in case the ICE RTT takes // extreme values. diff --git a/p2p/base/dtlstransport.h b/p2p/base/dtlstransport.h index a4b1c6cdec..4003ab6a62 100644 --- a/p2p/base/dtlstransport.h +++ b/p2p/base/dtlstransport.h @@ -171,7 +171,7 @@ class DtlsTransport : public DtlsTransportInternal { int GetError() override; - rtc::Optional network_route() const override; + absl::optional network_route() const override; int SetOption(rtc::Socket::Option opt, int value) override; @@ -198,7 +198,7 @@ class DtlsTransport : public DtlsTransportInternal { void OnReadyToSend(rtc::PacketTransportInternal* transport); void OnReceivingState(rtc::PacketTransportInternal* transport); void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err); - void OnNetworkRouteChanged(rtc::Optional network_route); + void OnNetworkRouteChanged(absl::optional network_route); bool SetupDtls(); void MaybeStartDtls(); bool HandleDtlsPacket(const char* data, size_t size); @@ -223,7 +223,7 @@ class DtlsTransport : public DtlsTransportInternal { std::vector srtp_ciphers_; // SRTP ciphers to use with DTLS. bool dtls_active_ = false; rtc::scoped_refptr local_certificate_; - rtc::Optional dtls_role_; + absl::optional dtls_role_; rtc::SSLProtocolVersion ssl_max_version_; rtc::CryptoOptions crypto_options_; rtc::Buffer remote_fingerprint_value_; diff --git a/p2p/base/fakedtlstransport.h b/p2p/base/fakedtlstransport.h index a1bea1359f..5907f070ad 100644 --- a/p2p/base/fakedtlstransport.h +++ b/p2p/base/fakedtlstransport.h @@ -225,7 +225,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { } int GetError() override { return ice_transport_->GetError(); } - rtc::Optional network_route() const override { + absl::optional network_route() const override { return ice_transport_->network_route(); } @@ -257,7 +257,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { SignalWritableState(this); } - void OnNetworkRouteChanged(rtc::Optional network_route) { + void OnNetworkRouteChanged(absl::optional network_route) { SignalNetworkRouteChanged(network_route); } @@ -271,7 +271,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { bool do_dtls_ = false; rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; rtc::SSLFingerprint dtls_fingerprint_; - rtc::Optional dtls_role_; + absl::optional dtls_role_; int crypto_suite_ = rtc::SRTP_AES128_CM_SHA1_80; rtc::CryptoOptions crypto_options_; diff --git a/p2p/base/fakeicetransport.h b/p2p/base/fakeicetransport.h index aa6afb8e3f..25eb8a4335 100644 --- a/p2p/base/fakeicetransport.h +++ b/p2p/base/fakeicetransport.h @@ -168,7 +168,7 @@ class FakeIceTransport : public IceTransportInternal { return true; } - rtc::Optional GetRttEstimate() override { return rtc::nullopt; } + absl::optional GetRttEstimate() override { return absl::nullopt; } void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override { } @@ -224,10 +224,10 @@ class FakeIceTransport : public IceTransportInternal { rtc::CopyOnWriteBuffer last_sent_packet() { return last_sent_packet_; } - rtc::Optional network_route() const override { + absl::optional network_route() const override { return network_route_; } - void SetNetworkRoute(rtc::Optional network_route) { + void SetNetworkRoute(absl::optional network_route) { network_route_ = network_route; } @@ -282,7 +282,7 @@ class FakeIceTransport : public IceTransportInternal { bool receiving_ = false; bool combine_outgoing_packets_ = false; rtc::CopyOnWriteBuffer send_packet_; - rtc::Optional network_route_; + absl::optional network_route_; std::map socket_options_; rtc::CopyOnWriteBuffer last_sent_packet_; }; diff --git a/p2p/base/icetransportinternal.h b/p2p/base/icetransportinternal.h index c60059e323..84e33864a6 100644 --- a/p2p/base/icetransportinternal.h +++ b/p2p/base/icetransportinternal.h @@ -63,14 +63,14 @@ enum class NominationMode { }; // Information about ICE configuration. -// TODO(deadbeef): Use rtc::Optional to represent unset values, instead of +// TODO(deadbeef): Use absl::optional to represent unset values, instead of // -1. struct IceConfig { // The ICE connection receiving timeout value in milliseconds. - rtc::Optional receiving_timeout; + absl::optional receiving_timeout; // Time interval in milliseconds to ping a backup connection when the ICE // channel is strongly connected. - rtc::Optional backup_connection_ping_interval; + absl::optional backup_connection_ping_interval; ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE; @@ -83,7 +83,7 @@ struct IceConfig { bool prioritize_most_likely_candidate_pairs = false; // Writable connections are pinged at a slower rate once stablized. - rtc::Optional stable_writable_connection_ping_interval; + absl::optional stable_writable_connection_ping_interval; // If set to true, this means the ICE transport should presume TURN-to-TURN // candidate pairs will succeed, even before a binding response is received. @@ -91,16 +91,16 @@ struct IceConfig { // Interval to check on all networks and to perform ICE regathering on any // active network having no connection on it. - rtc::Optional regather_on_failed_networks_interval; + absl::optional regather_on_failed_networks_interval; // Interval to perform ICE regathering on all networks // The delay in milliseconds is sampled from the uniform distribution [a, b] - rtc::Optional regather_all_networks_interval_range; + absl::optional regather_all_networks_interval_range; // The time period in which we will not switch the selected connection // when a new connection becomes receiving but the selected connection is not // in case that the selected connection may become receiving soon. - rtc::Optional receiving_switching_delay; + absl::optional receiving_switching_delay; // TODO(honghaiz): Change the default to regular nomination. // Default nomination mode if the remote does not support renomination. @@ -110,12 +110,12 @@ struct IceConfig { // for a candidate pair when it is both writable and receiving (strong // connectivity). This parameter overrides the default value given by // |STRONG_PING_INTERVAL| in p2ptransport.h if set. - rtc::Optional ice_check_interval_strong_connectivity; + absl::optional ice_check_interval_strong_connectivity; // The interval in milliseconds at which ICE checks (STUN pings) will be sent // for a candidate pair when it is either not writable or not receiving (weak // connectivity). This parameter overrides the default value given by // |WEAK_PING_INTERVAL| in p2ptransport.h if set. - rtc::Optional ice_check_interval_weak_connectivity; + absl::optional ice_check_interval_weak_connectivity; // ICE checks (STUN pings) will not be sent at higher rate (lower interval) // than this, no matter what other settings there are. // Measure in milliseconds. @@ -123,23 +123,23 @@ struct IceConfig { // Note that this parameter overrides both the above check intervals for // candidate pairs with strong or weak connectivity, if either of the above // interval is shorter than the min interval. - rtc::Optional ice_check_min_interval; + absl::optional ice_check_min_interval; // The min time period for which a candidate pair must wait for response to // connectivity checks before it becomes unwritable. This parameter // overrides the default value given by |CONNECTION_WRITE_CONNECT_TIMEOUT| // in port.h if set, when determining the writability of a candidate pair. - rtc::Optional ice_unwritable_timeout; + absl::optional ice_unwritable_timeout; // The min number of connectivity checks that a candidate pair must sent // without receiving response before it becomes unwritable. This parameter // overrides the default value given by |CONNECTION_WRITE_CONNECT_FAILURES| in // port.h if set, when determining the writability of a candidate pair. - rtc::Optional ice_unwritable_min_checks; + absl::optional ice_unwritable_min_checks; // The interval in milliseconds at which STUN candidates will resend STUN // binding requests to keep NAT bindings open. - rtc::Optional stun_keepalive_interval; + absl::optional stun_keepalive_interval; - rtc::Optional network_preference; + absl::optional network_preference; IceConfig(); IceConfig(int receiving_timeout_ms, @@ -154,7 +154,7 @@ struct IceConfig { // Helper getters for parameters with implementation-specific default value. // By convention, parameters with default value are represented by - // rtc::Optional and setting a parameter to null restores its default value. + // absl::optional and setting a parameter to null restores its default value. int receiving_timeout_or_default() const; int backup_connection_ping_interval_or_default() const; int stable_writable_connection_ping_interval_or_default() const; @@ -240,8 +240,8 @@ class IceTransportInternal : public rtc::PacketTransportInternal { CandidateStatsList* candidate_stats_list) = 0; // Returns RTT estimate over the currently active connection, or an empty - // rtc::Optional if there is none. - virtual rtc::Optional GetRttEstimate() = 0; + // absl::optional if there is none. + virtual absl::optional GetRttEstimate() = 0; sigslot::signal1 SignalGatheringState; diff --git a/p2p/base/mockicetransport.h b/p2p/base/mockicetransport.h index c30d797fdf..8baab37808 100644 --- a/p2p/base/mockicetransport.h +++ b/p2p/base/mockicetransport.h @@ -57,7 +57,7 @@ class MockIceTransport : public IceTransportInternal { void SetRemoteIceParameters(const IceParameters& ice_params) override {} void SetRemoteIceMode(IceMode mode) override {} void SetIceConfig(const IceConfig& config) override {} - rtc::Optional GetRttEstimate() override { return rtc::nullopt; } + absl::optional GetRttEstimate() override { return absl::nullopt; } void MaybeStartGathering() override {} void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override { } diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc index d1c58c2162..dca8d6374c 100644 --- a/p2p/base/p2ptransportchannel.cc +++ b/p2p/base/p2ptransportchannel.cc @@ -61,7 +61,7 @@ static constexpr int a_and_b_equal = 0; bool LocalCandidateUsesPreferredNetwork( const cricket::Connection* conn, - rtc::Optional network_preference) { + absl::optional network_preference) { rtc::AdapterType network_type = conn->port()->Network()->type(); return network_preference.has_value() && (network_type == network_preference); } @@ -69,7 +69,7 @@ bool LocalCandidateUsesPreferredNetwork( int CompareCandidatePairsByNetworkPreference( const cricket::Connection* a, const cricket::Connection* b, - rtc::Optional network_preference) { + absl::optional network_preference) { bool a_uses_preferred_network = LocalCandidateUsesPreferredNetwork(a, network_preference); bool b_uses_preferred_network = @@ -236,7 +236,7 @@ bool P2PTransportChannel::ShouldSwitchSelectedConnection( return false; } - rtc::Optional receiving_unchanged_threshold( + absl::optional receiving_unchanged_threshold( rtc::TimeMillis() - config_.receiving_switching_delay_or_default()); int cmp = CompareConnections(selected_connection_, new_connection, receiving_unchanged_threshold, @@ -331,12 +331,12 @@ IceGatheringState P2PTransportChannel::gathering_state() const { return gathering_state_; } -rtc::Optional P2PTransportChannel::GetRttEstimate() { +absl::optional P2PTransportChannel::GetRttEstimate() { if (selected_connection_ != nullptr && selected_connection_->rtt_samples() > 0) { return selected_connection_->rtt(); } else { - return rtc::nullopt; + return absl::nullopt; } } @@ -419,9 +419,9 @@ void P2PTransportChannel::SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; } -// TODO(qingsi): We apply the convention that setting a rtc::Optional parameter +// TODO(qingsi): We apply the convention that setting a absl::optional parameter // to null restores its default value in the implementation. However, some -// rtc::Optional parameters are only processed below if non-null, e.g., +// absl::optional parameters are only processed below if non-null, e.g., // regather_on_failed_networks_interval, and thus there is no way to restore the // defaults. Fix this issue later for consistency. void P2PTransportChannel::SetIceConfig(const IceConfig& config) { @@ -1261,7 +1261,7 @@ bool P2PTransportChannel::GetStats(ConnectionInfos* candidate_pair_stats_list, return true; } -rtc::Optional P2PTransportChannel::network_route() const { +absl::optional P2PTransportChannel::network_route() const { return network_route_; } @@ -1319,7 +1319,7 @@ void P2PTransportChannel::MaybeStartPinging() { int P2PTransportChannel::CompareCandidatePairNetworks( const Connection* a, const Connection* b, - rtc::Optional network_preference) const { + absl::optional network_preference) const { int compare_a_b_by_network_preference = CompareCandidatePairsByNetworkPreference(a, b, config_.network_preference); @@ -1345,7 +1345,7 @@ int P2PTransportChannel::CompareCandidatePairNetworks( int P2PTransportChannel::CompareConnectionStates( const Connection* a, const Connection* b, - rtc::Optional receiving_unchanged_threshold, + absl::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const { // First, prefer a connection that's writable or presumed writable over // one that's not writable. @@ -1474,7 +1474,7 @@ bool P2PTransportChannel::IsRemoteCandidatePruned(const Candidate& cand) const { int P2PTransportChannel::CompareConnections( const Connection* a, const Connection* b, - rtc::Optional receiving_unchanged_threshold, + absl::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const { RTC_CHECK(a != nullptr); RTC_CHECK(b != nullptr); @@ -1538,7 +1538,7 @@ void P2PTransportChannel::SortConnectionsAndUpdateState( // TODO(honghaiz): Don't sort; Just use std::max_element in the right places. std::stable_sort(connections_.begin(), connections_.end(), [this](const Connection* a, const Connection* b) { - int cmp = CompareConnections(a, b, rtc::nullopt, nullptr); + int cmp = CompareConnections(a, b, absl::nullopt, nullptr); if (cmp != 0) { return cmp > 0; } diff --git a/p2p/base/p2ptransportchannel.h b/p2p/base/p2ptransportchannel.h index 8e3b06ce3e..421bf8f8f2 100644 --- a/p2p/base/p2ptransportchannel.h +++ b/p2p/base/p2ptransportchannel.h @@ -104,7 +104,7 @@ class P2PTransportChannel : public IceTransportInternal { // only update the parameter if it is considered set in |config|. For example, // a negative value of receiving_timeout will be considered "not set" and we // will not use it to update the respective parameter in |config_|. - // TODO(deadbeef): Use rtc::Optional instead of negative values. + // TODO(deadbeef): Use absl::optional instead of negative values. void SetIceConfig(const IceConfig& config) override; const IceConfig& config() const; static webrtc::RTCError ValidateIceConfig(const IceConfig& config); @@ -120,7 +120,7 @@ class P2PTransportChannel : public IceTransportInternal { int GetError() override; bool GetStats(std::vector* candidate_pair_stats_list, std::vector* candidate_stats_list) override; - rtc::Optional GetRttEstimate() override; + absl::optional GetRttEstimate() override; // TODO(honghaiz): Remove this method once the reference of it in // Chromoting is removed. @@ -138,7 +138,7 @@ class P2PTransportChannel : public IceTransportInternal { void PruneAllPorts(); int check_receiving_interval() const; - rtc::Optional network_route() const override; + absl::optional network_route() const override; // Helper method used only in unittest. rtc::DiffServCodePoint DefaultDscpValue() const; @@ -202,7 +202,7 @@ class P2PTransportChannel : public IceTransportInternal { int CompareCandidatePairNetworks( const Connection* a, const Connection* b, - rtc::Optional network_preference) const; + absl::optional network_preference) const; // The methods below return a positive value if |a| is preferable to |b|, // a negative value if |b| is preferable, and 0 if they're equally preferable. @@ -214,7 +214,7 @@ class P2PTransportChannel : public IceTransportInternal { int CompareConnectionStates( const cricket::Connection* a, const cricket::Connection* b, - rtc::Optional receiving_unchanged_threshold, + absl::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; int CompareConnectionCandidates(const cricket::Connection* a, const cricket::Connection* b) const; @@ -225,7 +225,7 @@ class P2PTransportChannel : public IceTransportInternal { // Returns a positive value if |a| is better than |b|. int CompareConnections(const cricket::Connection* a, const cricket::Connection* b, - rtc::Optional receiving_unchanged_threshold, + absl::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; bool PresumedWritable(const cricket::Connection* conn) const; @@ -408,7 +408,7 @@ class P2PTransportChannel : public IceTransportInternal { rtc::AsyncInvoker invoker_; webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; - rtc::Optional network_route_; + absl::optional network_route_; webrtc::IceEventLog ice_event_log_; RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc index fb44e51d93..39dfaa3507 100644 --- a/p2p/base/p2ptransportchannel_unittest.cc +++ b/p2p/base/p2ptransportchannel_unittest.cc @@ -113,7 +113,7 @@ enum { MSG_ADD_CANDIDATES, MSG_REMOVE_CANDIDATES }; cricket::IceConfig CreateIceConfig( int receiving_timeout, cricket::ContinualGatheringPolicy continual_gathering_policy, - rtc::Optional backup_ping_interval = rtc::nullopt) { + absl::optional backup_ping_interval = absl::nullopt) { cricket::IceConfig config; config.receiving_timeout = receiving_timeout; config.continual_gathering_policy = continual_gathering_policy; @@ -709,7 +709,7 @@ class P2PTransportChannelTestBase : public testing::Test, } } - void OnNetworkRouteChanged(rtc::Optional network_route) { + void OnNetworkRouteChanged(absl::optional network_route) { // If the |network_route| is unset, don't count. This is used in the case // when the network on remote side is down, the signal will be fired with an // unset network route and it shouldn't trigger a connection switch. @@ -3153,7 +3153,7 @@ class P2PTransportChannelPingTest : public testing::Test, conn->SignalNominated(conn); } - void OnNetworkRouteChanged(rtc::Optional network_route) { + void OnNetworkRouteChanged(absl::optional network_route) { last_network_route_ = network_route; if (last_network_route_) { last_sent_packet_id_ = last_network_route_->last_sent_packet_id; @@ -3220,7 +3220,7 @@ class P2PTransportChannelPingTest : public testing::Test, int last_sent_packet_id_ = -1; bool channel_ready_to_send_ = false; IceTransportState channel_state_ = IceTransportState::STATE_INIT; - rtc::Optional last_network_route_; + absl::optional last_network_route_; }; TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { diff --git a/p2p/base/packettransportinternal.cc b/p2p/base/packettransportinternal.cc index 2d28ffbd1e..ba5f1e9068 100644 --- a/p2p/base/packettransportinternal.cc +++ b/p2p/base/packettransportinternal.cc @@ -24,8 +24,8 @@ bool PacketTransportInternal::GetOption(rtc::Socket::Option opt, int* value) { return false; } -rtc::Optional PacketTransportInternal::network_route() const { - return rtc::Optional(); +absl::optional PacketTransportInternal::network_route() const { + return absl::optional(); } } // namespace rtc diff --git a/p2p/base/packettransportinternal.h b/p2p/base/packettransportinternal.h index a5b9772c27..dfa65776b7 100644 --- a/p2p/base/packettransportinternal.h +++ b/p2p/base/packettransportinternal.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" // This is included for PacketOptions. #include "api/ortc/packettransportinterface.h" #include "p2p/base/port.h" @@ -66,7 +66,7 @@ class PacketTransportInternal : public virtual webrtc::PacketTransportInterface, // Returns the current network route with transport overhead. // TODO(zhihuang): Make it pure virtual once the Chrome/remoting is updated. - virtual rtc::Optional network_route() const; + virtual absl::optional network_route() const; // Emitted when the writable state, represented by |writable()|, changes. sigslot::signal1 SignalWritableState; @@ -94,7 +94,7 @@ class PacketTransportInternal : public virtual webrtc::PacketTransportInterface, SignalSentPacket; // Signalled when the current network route has changed. - sigslot::signal1> SignalNetworkRouteChanged; + sigslot::signal1> SignalNetworkRouteChanged; protected: PacketTransportInternal(); diff --git a/p2p/base/port.cc b/p2p/base/port.cc index a0bf51d756..e77baf5256 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -1740,7 +1740,7 @@ void Connection::MaybeSetRemoteIceParametersAndGeneration( } // TODO(deadbeef): A value of '0' for the generation is used for both // generation 0 and "generation unknown". It should be changed to an - // rtc::Optional to fix this. + // absl::optional to fix this. if (remote_candidate_.username() == ice_params.ufrag && remote_candidate_.password() == ice_params.pwd && remote_candidate_.generation() == 0) { diff --git a/p2p/base/port.h b/p2p/base/port.h index 81554e80ce..de025e6fc0 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -17,8 +17,8 @@ #include #include +#include "absl/types/optional.h" #include "api/candidate.h" -#include "api/optional.h" #include "api/rtcerror.h" #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h" #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h" @@ -107,7 +107,7 @@ class CandidateStats { Candidate candidate; // STUN port stats if this candidate is a STUN candidate. - rtc::Optional stun_stats; + absl::optional stun_stats; }; typedef std::vector CandidateStatsList; @@ -152,7 +152,7 @@ struct ConnectionInfo { // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime uint64_t total_round_trip_time_ms; // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime - rtc::Optional current_round_trip_time_ms; + absl::optional current_round_trip_time_ms; }; // Information about all the candidate pairs of a channel. @@ -379,7 +379,7 @@ class Port : public PortInterface, public rtc::MessageHandler, int16_t network_cost() const { return network_cost_; } - void GetStunStats(rtc::Optional* stats) override{}; + void GetStunStats(absl::optional* stats) override{}; protected: enum { MSG_DESTROY_IF_DEAD = 0, MSG_FIRST_AVAILABLE }; @@ -554,11 +554,11 @@ class Connection : public CandidatePairInterface, int rtt() const { return rtt_; } int unwritable_timeout() const; - void set_unwritable_timeout(const rtc::Optional& value_ms) { + void set_unwritable_timeout(const absl::optional& value_ms) { unwritable_timeout_ = value_ms; } int unwritable_min_checks() const; - void set_unwritable_min_checks(const rtc::Optional& value) { + void set_unwritable_min_checks(const absl::optional& value) { unwritable_min_checks_ = value; } @@ -626,7 +626,7 @@ class Connection : public CandidatePairInterface, } int receiving_timeout() const; - void set_receiving_timeout(rtc::Optional receiving_timeout_ms) { + void set_receiving_timeout(absl::optional receiving_timeout_ms) { receiving_timeout_ = receiving_timeout_ms; } @@ -801,7 +801,7 @@ class Connection : public CandidatePairInterface, // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime uint64_t total_round_trip_time_ms_ = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime - rtc::Optional current_round_trip_time_ms_; + absl::optional current_round_trip_time_ms_; int64_t last_ping_sent_; // last time we sent a ping to the other side int64_t last_ping_received_; // last time we received a ping from the other // side @@ -812,17 +812,17 @@ class Connection : public CandidatePairInterface, PacketLossEstimator packet_loss_estimator_; - rtc::Optional unwritable_timeout_; - rtc::Optional unwritable_min_checks_; + absl::optional unwritable_timeout_; + absl::optional unwritable_min_checks_; bool reported_; IceCandidatePairState state_; // Time duration to switch from receiving to not receiving. - rtc::Optional receiving_timeout_; + absl::optional receiving_timeout_; int64_t time_created_ms_; int num_pings_sent_ = 0; - rtc::Optional log_description_; + absl::optional log_description_; uint32_t hash_; webrtc::IceEventLog* ice_event_log_ = nullptr; diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 5a0dc1a25e..55887055ec 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -502,7 +502,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { PacketSocketFactory* socket_factory) { return UDPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0, username_, password_, std::string(), true, - rtc::nullopt); + absl::nullopt); } TCPPort* CreateTcpPort(const SocketAddress& addr) { return CreateTcpPort(addr, &socket_factory_); @@ -518,7 +518,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { stun_servers.insert(kStunAddr); return StunPort::Create(&main_, factory, MakeNetwork(addr), 0, 0, username_, password_, stun_servers, std::string(), - rtc::nullopt); + absl::nullopt); } Port* CreateRelayPort(const SocketAddress& addr, RelayType rtype, ProtocolType int_proto, ProtocolType ext_proto) { diff --git a/p2p/base/portallocator.cc b/p2p/base/portallocator.cc index d9383610d6..ee0466f796 100644 --- a/p2p/base/portallocator.cc +++ b/p2p/base/portallocator.cc @@ -127,7 +127,7 @@ bool PortAllocator::SetConfiguration( int candidate_pool_size, bool prune_turn_ports, webrtc::TurnCustomizer* turn_customizer, - const rtc::Optional& stun_candidate_keepalive_interval) { + const absl::optional& stun_candidate_keepalive_interval) { CheckRunOnValidThreadIfInitialized(); bool ice_servers_changed = (stun_servers != stun_servers_ || turn_servers != turn_servers_); diff --git a/p2p/base/portallocator.h b/p2p/base/portallocator.h index 30ace5eba7..4d128b0b91 100644 --- a/p2p/base/portallocator.h +++ b/p2p/base/portallocator.h @@ -250,7 +250,7 @@ class PortAllocatorSession : public sigslot::has_slots<> { // The default value of the interval in implementation is restored if a null // optional value is passed. virtual void SetStunKeepaliveIntervalForReadyPorts( - const rtc::Optional& stun_keepalive_interval) {} + const absl::optional& stun_keepalive_interval) {} // Another way of getting the information provided by the signals below. // // Ports and candidates are not guaranteed to be in the same order as the @@ -353,8 +353,8 @@ class PortAllocator : public sigslot::has_slots<> { int candidate_pool_size, bool prune_turn_ports, webrtc::TurnCustomizer* turn_customizer = nullptr, - const rtc::Optional& - stun_candidate_keepalive_interval = rtc::nullopt); + const absl::optional& + stun_candidate_keepalive_interval = absl::nullopt); const ServerAddresses& stun_servers() const { CheckRunOnValidThreadIfInitialized(); @@ -371,7 +371,7 @@ class PortAllocator : public sigslot::has_slots<> { return candidate_pool_size_; } - const rtc::Optional& stun_candidate_keepalive_interval() const { + const absl::optional& stun_candidate_keepalive_interval() const { CheckRunOnValidThreadIfInitialized(); return stun_candidate_keepalive_interval_; } @@ -607,7 +607,7 @@ class PortAllocator : public sigslot::has_slots<> { // all TurnPort(s) created. webrtc::TurnCustomizer* turn_customizer_ = nullptr; - rtc::Optional stun_candidate_keepalive_interval_; + absl::optional stun_candidate_keepalive_interval_; }; } // namespace cricket diff --git a/p2p/base/portinterface.h b/p2p/base/portinterface.h index 49a41647cd..7df4543e6e 100644 --- a/p2p/base/portinterface.h +++ b/p2p/base/portinterface.h @@ -14,8 +14,8 @@ #include #include +#include "absl/types/optional.h" #include "api/candidate.h" -#include "api/optional.h" #include "p2p/base/transportdescription.h" #include "rtc_base/asyncpacketsocket.h" #include "rtc_base/socketaddress.h" @@ -127,7 +127,7 @@ class PortInterface { virtual std::string ToString() const = 0; - virtual void GetStunStats(rtc::Optional* stats) = 0; + virtual void GetStunStats(absl::optional* stats) = 0; protected: PortInterface(); diff --git a/p2p/base/regatheringcontroller.cc b/p2p/base/regatheringcontroller.cc index c358e6ab19..6d4c4fd978 100644 --- a/p2p/base/regatheringcontroller.cc +++ b/p2p/base/regatheringcontroller.cc @@ -14,7 +14,7 @@ namespace webrtc { using Config = BasicRegatheringController::Config; -Config::Config(const rtc::Optional& +Config::Config(const absl::optional& regather_on_all_networks_interval_range, int regather_on_failed_networks_interval) : regather_on_all_networks_interval_range( diff --git a/p2p/base/regatheringcontroller.h b/p2p/base/regatheringcontroller.h index e030ff097c..891ec85b88 100644 --- a/p2p/base/regatheringcontroller.h +++ b/p2p/base/regatheringcontroller.h @@ -46,13 +46,13 @@ namespace webrtc { class BasicRegatheringController : public sigslot::has_slots<> { public: struct Config { - Config(const rtc::Optional& + Config(const absl::optional& regather_on_all_networks_interval_range, int regather_on_failed_networks_interval); Config(const Config& other); ~Config(); Config& operator=(const Config& other); - rtc::Optional regather_on_all_networks_interval_range; + absl::optional regather_on_all_networks_interval_range; int regather_on_failed_networks_interval; }; @@ -82,7 +82,7 @@ class BasicRegatheringController : public sigslot::has_slots<> { void OnIceTransportStateChanged(cricket::IceTransportInternal*) {} void OnIceTransportWritableState(rtc::PacketTransportInternal*) {} void OnIceTransportReceivingState(rtc::PacketTransportInternal*) {} - void OnIceTransportNetworkRouteChanged(rtc::Optional) {} + void OnIceTransportNetworkRouteChanged(absl::optional) {} // Schedules delayed and repeated regathering of local candidates on all // networks, where the delay in milliseconds is randomly sampled from the // range in the config. The delay of each repetition is independently sampled diff --git a/p2p/base/regatheringcontroller_unittest.cc b/p2p/base/regatheringcontroller_unittest.cc index 798611b1ed..18b23e0536 100644 --- a/p2p/base/regatheringcontroller_unittest.cc +++ b/p2p/base/regatheringcontroller_unittest.cc @@ -54,7 +54,7 @@ class RegatheringControllerTest : public testing::Test, ice_transport_(new cricket::MockIceTransport()), allocator_( new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)) { - BasicRegatheringController::Config regathering_config(rtc::nullopt, 0); + BasicRegatheringController::Config regathering_config(absl::nullopt, 0); regathering_controller_.reset(new BasicRegatheringController( regathering_config, ice_transport_.get(), rtc::Thread::Current())); } @@ -171,7 +171,7 @@ TEST_F(RegatheringControllerTest, rtc::ScopedFakeClock clock; InitializeAndGatherOnceWithSessionCleared(); - BasicRegatheringController::Config config(rtc::nullopt, 2000); + BasicRegatheringController::Config config(absl::nullopt, 2000); regathering_controller()->SetConfig(config); regathering_controller()->Start(); SIMULATED_WAIT(false, 3000, clock); diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc index 2f6bf614c6..1705d1d68f 100644 --- a/p2p/base/stunport.cc +++ b/p2p/base/stunport.cc @@ -314,11 +314,11 @@ ProtocolType UDPPort::GetProtocol() const { return PROTO_UDP; } -void UDPPort::GetStunStats(rtc::Optional* stats) { +void UDPPort::GetStunStats(absl::optional* stats) { *stats = stats_; } -void UDPPort::set_stun_keepalive_delay(const rtc::Optional& delay) { +void UDPPort::set_stun_keepalive_delay(const absl::optional& delay) { stun_keepalive_delay_ = delay.value_or(STUN_KEEPALIVE_INTERVAL); } @@ -555,7 +555,7 @@ StunPort* StunPort::Create(rtc::Thread* thread, const std::string& password, const ServerAddresses& servers, const std::string& origin, - rtc::Optional stun_keepalive_interval) { + absl::optional stun_keepalive_interval) { StunPort* port = new StunPort(thread, factory, network, min_port, max_port, username, password, servers, origin); port->set_stun_keepalive_delay(stun_keepalive_interval); diff --git a/p2p/base/stunport.h b/p2p/base/stunport.h index bdaa31b7f5..9cb479df0e 100644 --- a/p2p/base/stunport.h +++ b/p2p/base/stunport.h @@ -43,7 +43,7 @@ class UDPPort : public Port { const std::string& password, const std::string& origin, bool emit_local_for_anyaddress, - rtc::Optional stun_keepalive_interval) { + absl::optional stun_keepalive_interval) { UDPPort* port = new UDPPort(thread, factory, network, socket, username, password, origin, emit_local_for_anyaddress); port->set_stun_keepalive_delay(stun_keepalive_interval); @@ -63,7 +63,7 @@ class UDPPort : public Port { const std::string& password, const std::string& origin, bool emit_local_for_anyaddress, - rtc::Optional stun_keepalive_interval) { + absl::optional stun_keepalive_interval) { UDPPort* port = new UDPPort(thread, factory, network, min_port, max_port, username, password, origin, emit_local_for_anyaddress); @@ -105,9 +105,9 @@ class UDPPort : public Port { bool SupportsProtocol(const std::string& protocol) const override; ProtocolType GetProtocol() const override; - void GetStunStats(rtc::Optional* stats) override; + void GetStunStats(absl::optional* stats) override; - void set_stun_keepalive_delay(const rtc::Optional& delay); + void set_stun_keepalive_delay(const absl::optional& delay); int stun_keepalive_delay() const { return stun_keepalive_delay_; } @@ -267,7 +267,7 @@ class StunPort : public UDPPort { const std::string& password, const ServerAddresses& servers, const std::string& origin, - rtc::Optional stun_keepalive_interval); + absl::optional stun_keepalive_interval); void PrepareAddress() override; diff --git a/p2p/base/stunport_unittest.cc b/p2p/base/stunport_unittest.cc index ef47db1bcf..c7ced3a33e 100644 --- a/p2p/base/stunport_unittest.cc +++ b/p2p/base/stunport_unittest.cc @@ -74,7 +74,7 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> { stun_port_.reset(cricket::StunPort::Create( rtc::Thread::Current(), &socket_factory_, &network_, 0, 0, rtc::CreateRandomString(16), rtc::CreateRandomString(22), stun_servers, - std::string(), rtc::nullopt)); + std::string(), absl::nullopt)); stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_); // If |stun_keepalive_lifetime_| is negative, let the stun port // choose its lifetime from the network type. @@ -94,7 +94,7 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> { stun_port_.reset(cricket::UDPPort::Create( rtc::Thread::Current(), &socket_factory_, &network_, socket_.get(), rtc::CreateRandomString(16), rtc::CreateRandomString(22), std::string(), - false, rtc::nullopt)); + false, absl::nullopt)); ASSERT_TRUE(stun_port_ != NULL); ServerAddresses stun_servers; stun_servers.insert(server_addr); diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc index a09c6403c5..2dd67bc9ae 100644 --- a/p2p/base/turnport.cc +++ b/p2p/base/turnport.cc @@ -15,7 +15,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "p2p/base/stun.h" #include "rtc_base/asyncpacketsocket.h" #include "rtc_base/byteorder.h" @@ -151,7 +151,7 @@ class TurnEntry : public sigslot::has_slots<> { // If the destruction timestamp is set, that means destruction has been // scheduled (will occur TURN_PERMISSION_TIMEOUT after it's scheduled). - rtc::Optional destruction_timestamp() { + absl::optional destruction_timestamp() { return destruction_timestamp_; } void set_destruction_timestamp(int64_t destruction_timestamp) { @@ -185,7 +185,7 @@ class TurnEntry : public sigslot::has_slots<> { // is also used as an ID of the event scheduling. When the destruction event // actually fires, the TurnEntry will be destroyed only if the timestamp here // matches the one in the firing event. - rtc::Optional destruction_timestamp_; + absl::optional destruction_timestamp_; }; TurnPort::TurnPort(rtc::Thread* thread, diff --git a/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc index bd88bd107c..68654f4192 100644 --- a/p2p/base/turnport_unittest.cc +++ b/p2p/base/turnport_unittest.cc @@ -336,7 +336,7 @@ class TurnPortTest : public testing::Test, void CreateUdpPort(const SocketAddress& address) { udp_port_.reset(UDPPort::Create( &main_, &socket_factory_, MakeNetwork(address), 0, 0, kIceUfrag2, - kIcePwd2, std::string(), false, rtc::nullopt)); + kIcePwd2, std::string(), false, absl::nullopt)); // UDP port will be controlled. udp_port_->SetIceRole(ICEROLE_CONTROLLED); udp_port_->SignalPortComplete.connect( diff --git a/p2p/base/udptransport.cc b/p2p/base/udptransport.cc index 8b4ce00689..c21e5b8769 100644 --- a/p2p/base/udptransport.cc +++ b/p2p/base/udptransport.cc @@ -96,11 +96,11 @@ int UdpTransport::SendPacket(const char* data, return result; } -rtc::Optional UdpTransport::network_route() const { +absl::optional UdpTransport::network_route() const { rtc::NetworkRoute network_route; network_route.packet_overhead = /*kUdpOverhead=*/8 + GetIpOverhead(GetLocalAddress().family()); - return rtc::Optional(network_route); + return absl::optional(network_route); } int UdpTransport::SetOption(rtc::Socket::Option opt, int value) { diff --git a/p2p/base/udptransport.h b/p2p/base/udptransport.h index 118b596e91..541910e793 100644 --- a/p2p/base/udptransport.h +++ b/p2p/base/udptransport.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "api/ortc/udptransportinterface.h" #include "p2p/base/packettransportinternal.h" #include "rtc_base/asyncpacketsocket.h" // For PacketOptions. @@ -61,7 +61,7 @@ class UdpTransport : public rtc::PacketTransportInternal, int GetError() override; - rtc::Optional network_route() const override; + absl::optional network_route() const override; protected: PacketTransportInternal* GetInternal() override; diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index bca979beec..6a0c02ba87 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -456,7 +456,7 @@ void BasicPortAllocatorSession::Regather( } void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts( - const rtc::Optional& stun_keepalive_interval) { + const absl::optional& stun_keepalive_interval) { auto ports = ReadyPorts(); for (PortInterface* port : ports) { // The port type and protocol can be used to identify different subclasses diff --git a/p2p/client/basicportallocator.h b/p2p/client/basicportallocator.h index 1822b7da2f..0925ea3655 100644 --- a/p2p/client/basicportallocator.h +++ b/p2p/client/basicportallocator.h @@ -138,7 +138,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession, void RegatherOnFailedNetworks() override; void RegatherOnAllNetworks() override; void SetStunKeepaliveIntervalForReadyPorts( - const rtc::Optional& stun_keepalive_interval) override; + const absl::optional& stun_keepalive_interval) override; void PruneAllPorts() override; protected: