Replace rtc::Optional with absl::optional in api

This is a no-op change because rtc::Optional is an alias to absl::optional

This CL generated by running script with parameter 'api'
Then undo changes to optional target itself and optional_unittests

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: I44093da213369d6a502e33792c694f620f53b779
Reviewed-on: https://webrtc-review.googlesource.com/84621
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23707}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 6e79b27..41e1ad8 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -101,13 +101,13 @@
     ":callfactory_api",
     ":fec_controller_api",
     ":libjingle_logging_api",
-    ":optional",
     ":rtc_stats_api",
     "audio:audio_mixer_api",
     "audio_codecs:audio_codecs_api",
     "transport:bitrate_settings",
     "transport:network_control",
     "video:video_frame",
+    "//third_party/abseil-cpp/absl/types:optional",
 
     # Basically, don't add stuff here. You might break sensitive downstream
     # targets like pnacl. API should not depend on anything outside of this
@@ -160,9 +160,9 @@
   # libjingle_peerconnection_api.
   deps = [
     ":libjingle_peerconnection_api",
-    ":optional",
     "..:webrtc_common",
     "../rtc_base:rtc_base",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
   if (!build_with_chromium && is_clang) {
     # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
@@ -194,8 +194,8 @@
   ]
 
   deps = [
-    ":optional",
     "../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
diff --git a/api/audio/audio_frame.h b/api/audio/audio_frame.h
index d80868a..4c9aa9c 100644
--- a/api/audio/audio_frame.h
+++ b/api/audio/audio_frame.h
@@ -110,7 +110,7 @@
   // Monotonically increasing timestamp intended for profiling of audio frames.
   // Typically used for measuring elapsed time between two different points in
   // the audio path. No lock is used to save resources and we are thread safe
-  // by design. Also, rtc::Optional is not used since it will cause a "complex
+  // by design. Also, absl::optional is not used since it will cause a "complex
   // class/struct needs an explicit out-of-line destructor" build error.
   int64_t profile_timestamp_ms_ = 0;
 
diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn
index 3206a74..7895a93 100644
--- a/api/audio_codecs/BUILD.gn
+++ b/api/audio_codecs/BUILD.gn
@@ -30,13 +30,13 @@
   ]
   deps = [
     "..:array_view",
-    "..:optional",
     "../..:webrtc_common",
     "../../:typedefs",
     "../../rtc_base:checks",
     "../../rtc_base:deprecation",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:sanitizer",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn
index 01554aa..043d659 100644
--- a/api/audio_codecs/L16/BUILD.gn
+++ b/api/audio_codecs/L16/BUILD.gn
@@ -21,10 +21,10 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:pcm16b",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -37,9 +37,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:pcm16b",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/L16/audio_decoder_L16.cc b/api/audio_codecs/L16/audio_decoder_L16.cc
index 7c6a9ee..a17dc58 100644
--- a/api/audio_codecs/L16/audio_decoder_L16.cc
+++ b/api/audio_codecs/L16/audio_decoder_L16.cc
@@ -18,14 +18,14 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig(
+absl::optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig(
     const SdpAudioFormat& format) {
   Config config;
   config.sample_rate_hz = format.clockrate_hz;
   config.num_channels = rtc::checked_cast<int>(format.num_channels);
   return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk()
-             ? rtc::Optional<Config>(config)
-             : rtc::nullopt;
+             ? absl::optional<Config>(config)
+             : absl::nullopt;
 }
 
 void AudioDecoderL16::AppendSupportedDecoders(
@@ -35,7 +35,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder(
     const Config& config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   return config.IsOk() ? rtc::MakeUnique<AudioDecoderPcm16B>(
                              config.sample_rate_hz, config.num_channels)
                        : nullptr;
diff --git a/api/audio_codecs/L16/audio_decoder_L16.h b/api/audio_codecs/L16/audio_decoder_L16.h
index deef909..184ec24 100644
--- a/api/audio_codecs/L16/audio_decoder_L16.h
+++ b/api/audio_codecs/L16/audio_decoder_L16.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -35,11 +35,11 @@
     int sample_rate_hz = 8000;
     int num_channels = 1;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const Config& config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/L16/audio_encoder_L16.cc b/api/audio_codecs/L16/audio_encoder_L16.cc
index 5022993..d80e6bf 100644
--- a/api/audio_codecs/L16/audio_encoder_L16.cc
+++ b/api/audio_codecs/L16/audio_encoder_L16.cc
@@ -18,17 +18,17 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderL16::Config> AudioEncoderL16::SdpToConfig(
+absl::optional<AudioEncoderL16::Config> AudioEncoderL16::SdpToConfig(
     const SdpAudioFormat& format) {
   if (!rtc::IsValueInRangeForNumericType<int>(format.num_channels)) {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
   Config config;
   config.sample_rate_hz = format.clockrate_hz;
   config.num_channels = rtc::dchecked_cast<int>(format.num_channels);
   return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk()
-             ? rtc::Optional<Config>(config)
-             : rtc::nullopt;
+             ? absl::optional<Config>(config)
+             : absl::nullopt;
 }
 
 void AudioEncoderL16::AppendSupportedEncoders(
@@ -47,7 +47,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderL16::MakeAudioEncoder(
     const AudioEncoderL16::Config& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   AudioEncoderPcm16B::Config c;
   c.sample_rate_hz = config.sample_rate_hz;
diff --git a/api/audio_codecs/L16/audio_encoder_L16.h b/api/audio_codecs/L16/audio_encoder_L16.h
index 08d7ef1..340e3af 100644
--- a/api/audio_codecs/L16/audio_encoder_L16.h
+++ b/api/audio_codecs/L16/audio_encoder_L16.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -37,13 +37,13 @@
     int num_channels = 1;
     int frame_size_ms = 10;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const Config& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const Config& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc
index 4903fb6..00e45d9 100644
--- a/api/audio_codecs/audio_decoder.cc
+++ b/api/audio_codecs/audio_decoder.cc
@@ -33,14 +33,14 @@
     return ret < 0 ? 0 : static_cast<size_t>(ret);
   }
 
-  rtc::Optional<DecodeResult> Decode(
+  absl::optional<DecodeResult> Decode(
       rtc::ArrayView<int16_t> decoded) const override {
     auto speech_type = AudioDecoder::kSpeech;
     const int ret = decoder_->Decode(
         payload_.data(), payload_.size(), decoder_->SampleRateHz(),
         decoded.size() * sizeof(int16_t), decoded.data(), &speech_type);
-    return ret < 0 ? rtc::nullopt
-                   : rtc::Optional<DecodeResult>(
+    return ret < 0 ? absl::nullopt
+                   : absl::optional<DecodeResult>(
                          {static_cast<size_t>(ret), speech_type});
   }
 
diff --git a/api/audio_codecs/audio_decoder.h b/api/audio_codecs/audio_decoder.h
index 021288f..4852ad7 100644
--- a/api/audio_codecs/audio_decoder.h
+++ b/api/audio_codecs/audio_decoder.h
@@ -14,8 +14,8 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/array_view.h"
-#include "api/optional.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/constructormagic.h"
 #include "typedefs.h"  // NOLINT(build/include)
@@ -53,11 +53,11 @@
 
     // Decodes this frame of audio and writes the result in |decoded|.
     // |decoded| must be large enough to store as many samples as indicated by a
-    // call to Duration() . On success, returns an rtc::Optional containing the
+    // call to Duration() . On success, returns an absl::optional containing the
     // total number of samples across all channels, as well as whether the
     // decoder produced comfort noise or speech. On failure, returns an empty
-    // rtc::Optional. Decode may be called at most once per frame object.
-    virtual rtc::Optional<DecodeResult> Decode(
+    // absl::optional. Decode may be called at most once per frame object.
+    virtual absl::optional<DecodeResult> Decode(
         rtc::ArrayView<int16_t> decoded) const = 0;
   };
 
diff --git a/api/audio_codecs/audio_decoder_factory.h b/api/audio_codecs/audio_decoder_factory.h
index fb1c965..90f93f0 100644
--- a/api/audio_codecs/audio_decoder_factory.h
+++ b/api/audio_codecs/audio_decoder_factory.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 #include "rtc_base/refcount.h"
 
 namespace webrtc {
@@ -41,7 +41,7 @@
   // work.
   virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) = 0;
+      absl::optional<AudioCodecPairId> codec_pair_id) = 0;
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h
index 4adac21..cdbe8bd 100644
--- a/api/audio_codecs/audio_decoder_factory_template.h
+++ b/api/audio_codecs/audio_decoder_factory_template.h
@@ -32,7 +32,7 @@
   static bool IsSupportedDecoder(const SdpAudioFormat& format) { return false; }
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) {
+      absl::optional<AudioCodecPairId> codec_pair_id) {
     return nullptr;
   }
 };
@@ -48,14 +48,14 @@
   static bool IsSupportedDecoder(const SdpAudioFormat& format) {
     auto opt_config = T::SdpToConfig(format);
     static_assert(std::is_same<decltype(opt_config),
-                               rtc::Optional<typename T::Config>>::value,
+                               absl::optional<typename T::Config>>::value,
                   "T::SdpToConfig() must return a value of type "
-                  "rtc::Optional<T::Config>");
+                  "absl::optional<T::Config>");
     return opt_config ? true : Helper<Ts...>::IsSupportedDecoder(format);
   }
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) {
+      absl::optional<AudioCodecPairId> codec_pair_id) {
     auto opt_config = T::SdpToConfig(format);
     return opt_config ? T::MakeAudioDecoder(*opt_config, codec_pair_id)
                       : Helper<Ts...>::MakeAudioDecoder(format, codec_pair_id);
@@ -77,7 +77,7 @@
 
   std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) override {
+      absl::optional<AudioCodecPairId> codec_pair_id) override {
     return Helper<Ts...>::MakeAudioDecoder(format, codec_pair_id);
   }
 };
@@ -92,7 +92,7 @@
 //   // Converts |audio_format| to a ConfigType instance. Returns an empty
 //   // optional if |audio_format| doesn't correctly specify an decoder of our
 //   // type.
-//   rtc::Optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
+//   absl::optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
 //
 //   // Appends zero or more AudioCodecSpecs to the list that will be returned
 //   // by AudioDecoderFactory::GetSupportedDecoders().
@@ -102,7 +102,7 @@
 //   // AudioDecoderFactory::MakeAudioDecoder().
 //   std::unique_ptr<AudioDecoder> MakeAudioDecoder(
 //       const ConfigType& config,
-//       rtc::Optional<AudioCodecPairId> codec_pair_id);
+//       absl::optional<AudioCodecPairId> codec_pair_id);
 //
 // ConfigType should be a type that encapsulates all the settings needed to
 // create an AudioDecoder. T::Config (where T is the decoder struct) should
diff --git a/api/audio_codecs/audio_encoder.cc b/api/audio_codecs/audio_encoder.cc
index 4f9b9f0..595c111 100644
--- a/api/audio_codecs/audio_encoder.cc
+++ b/api/audio_codecs/audio_encoder.cc
@@ -85,12 +85,12 @@
     float uplink_recoverable_packet_loss_fraction) {}
 
 void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
-  OnReceivedUplinkBandwidth(target_audio_bitrate_bps, rtc::nullopt);
+  OnReceivedUplinkBandwidth(target_audio_bitrate_bps, absl::nullopt);
 }
 
 void AudioEncoder::OnReceivedUplinkBandwidth(
     int target_audio_bitrate_bps,
-    rtc::Optional<int64_t> bwe_period_ms) {}
+    absl::optional<int64_t> bwe_period_ms) {}
 
 void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
 
diff --git a/api/audio_codecs/audio_encoder.h b/api/audio_codecs/audio_encoder.h
index d277a19..2509401 100644
--- a/api/audio_codecs/audio_encoder.h
+++ b/api/audio_codecs/audio_encoder.h
@@ -16,8 +16,8 @@
 #include <string>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/array_view.h"
-#include "api/optional.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/deprecation.h"
 #include "typedefs.h"  // NOLINT(build/include)
@@ -34,30 +34,30 @@
   // Number of actions taken by the ANA bitrate controller since the start of
   // the call. If this value is not set, it indicates that the bitrate
   // controller is disabled.
-  rtc::Optional<uint32_t> bitrate_action_counter;
+  absl::optional<uint32_t> bitrate_action_counter;
   // Number of actions taken by the ANA channel controller since the start of
   // the call. If this value is not set, it indicates that the channel
   // controller is disabled.
-  rtc::Optional<uint32_t> channel_action_counter;
+  absl::optional<uint32_t> channel_action_counter;
   // Number of actions taken by the ANA DTX controller since the start of the
   // call. If this value is not set, it indicates that the DTX controller is
   // disabled.
-  rtc::Optional<uint32_t> dtx_action_counter;
+  absl::optional<uint32_t> dtx_action_counter;
   // Number of actions taken by the ANA FEC controller since the start of the
   // call. If this value is not set, it indicates that the FEC controller is
   // disabled.
-  rtc::Optional<uint32_t> fec_action_counter;
+  absl::optional<uint32_t> fec_action_counter;
   // Number of times the ANA frame length controller decided to increase the
   // frame length since the start of the call. If this value is not set, it
   // indicates that the frame length controller is disabled.
-  rtc::Optional<uint32_t> frame_length_increase_counter;
+  absl::optional<uint32_t> frame_length_increase_counter;
   // Number of times the ANA frame length controller decided to decrease the
   // frame length since the start of the call. If this value is not set, it
   // indicates that the frame length controller is disabled.
-  rtc::Optional<uint32_t> frame_length_decrease_counter;
+  absl::optional<uint32_t> frame_length_decrease_counter;
   // The uplink packet loss fractions as set by the ANA FEC controller. If this
   // value is not set, it indicates that the ANA FEC controller is not active.
-  rtc::Optional<float> uplink_packet_loss_fraction;
+  absl::optional<float> uplink_packet_loss_fraction;
 };
 
 // This is the interface class for encoders in AudioCoding module. Each codec
@@ -221,7 +221,7 @@
   // Provides target audio bitrate and corresponding probing interval of
   // the bandwidth estimator to this encoder to allow it to adapt.
   virtual void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps,
-                                         rtc::Optional<int64_t> bwe_period_ms);
+                                         absl::optional<int64_t> bwe_period_ms);
 
   // Provides RTT to this encoder to allow it to adapt.
   virtual void OnReceivedRtt(int rtt_ms);
diff --git a/api/audio_codecs/audio_encoder_factory.h b/api/audio_codecs/audio_encoder_factory.h
index 7825953..fb4e23f 100644
--- a/api/audio_codecs/audio_encoder_factory.h
+++ b/api/audio_codecs/audio_encoder_factory.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 #include "rtc_base/refcount.h"
 
 namespace webrtc {
@@ -32,7 +32,7 @@
   // Returns information about how this format would be encoded, provided it's
   // supported. More format and format variations may be supported than those
   // returned by GetSupportedEncoders().
-  virtual rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
+  virtual absl::optional<AudioCodecInfo> QueryAudioEncoder(
       const SdpAudioFormat& format) = 0;
 
   // Creates an AudioEncoder for the specified format. The encoder will tags
@@ -50,7 +50,7 @@
   virtual std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       int payload_type,
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) = 0;
+      absl::optional<AudioCodecPairId> codec_pair_id) = 0;
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/audio_encoder_factory_template.h b/api/audio_codecs/audio_encoder_factory_template.h
index f76677d..376b39e 100644
--- a/api/audio_codecs/audio_encoder_factory_template.h
+++ b/api/audio_codecs/audio_encoder_factory_template.h
@@ -29,14 +29,14 @@
 template <>
 struct Helper<> {
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {}
-  static rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
+  static absl::optional<AudioCodecInfo> QueryAudioEncoder(
       const SdpAudioFormat& format) {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       int payload_type,
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) {
+      absl::optional<AudioCodecPairId> codec_pair_id) {
     return nullptr;
   }
 };
@@ -49,21 +49,21 @@
     T::AppendSupportedEncoders(specs);
     Helper<Ts...>::AppendSupportedEncoders(specs);
   }
-  static rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
+  static absl::optional<AudioCodecInfo> QueryAudioEncoder(
       const SdpAudioFormat& format) {
     auto opt_config = T::SdpToConfig(format);
     static_assert(std::is_same<decltype(opt_config),
-                               rtc::Optional<typename T::Config>>::value,
+                               absl::optional<typename T::Config>>::value,
                   "T::SdpToConfig() must return a value of type "
-                  "rtc::Optional<T::Config>");
-    return opt_config ? rtc::Optional<AudioCodecInfo>(
+                  "absl::optional<T::Config>");
+    return opt_config ? absl::optional<AudioCodecInfo>(
                             T::QueryAudioEncoder(*opt_config))
                       : Helper<Ts...>::QueryAudioEncoder(format);
   }
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       int payload_type,
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) {
+      absl::optional<AudioCodecPairId> codec_pair_id) {
     auto opt_config = T::SdpToConfig(format);
     if (opt_config) {
       return T::MakeAudioEncoder(*opt_config, payload_type, codec_pair_id);
@@ -83,7 +83,7 @@
     return specs;
   }
 
-  rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
+  absl::optional<AudioCodecInfo> QueryAudioEncoder(
       const SdpAudioFormat& format) override {
     return Helper<Ts...>::QueryAudioEncoder(format);
   }
@@ -91,7 +91,7 @@
   std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       int payload_type,
       const SdpAudioFormat& format,
-      rtc::Optional<AudioCodecPairId> codec_pair_id) override {
+      absl::optional<AudioCodecPairId> codec_pair_id) override {
     return Helper<Ts...>::MakeAudioEncoder(payload_type, format, codec_pair_id);
   }
 };
@@ -106,7 +106,7 @@
 //   // Converts |audio_format| to a ConfigType instance. Returns an empty
 //   // optional if |audio_format| doesn't correctly specify an encoder of our
 //   // type.
-//   rtc::Optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
+//   absl::optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
 //
 //   // Appends zero or more AudioCodecSpecs to the list that will be returned
 //   // by AudioEncoderFactory::GetSupportedEncoders().
@@ -121,7 +121,7 @@
 //   std::unique_ptr<AudioDecoder> MakeAudioEncoder(
 //       const ConfigType& config,
 //       int payload_type,
-//       rtc::Optional<AudioCodecPairId> codec_pair_id);
+//       absl::optional<AudioCodecPairId> codec_pair_id);
 //
 // ConfigType should be a type that encapsulates all the settings needed to
 // create an AudioEncoder. T::Config (where T is the encoder struct) should
diff --git a/api/audio_codecs/audio_format.h b/api/audio_codecs/audio_format.h
index 553ab8f..d132067d 100644
--- a/api/audio_codecs/audio_format.h
+++ b/api/audio_codecs/audio_format.h
@@ -15,7 +15,7 @@
 #include <string>
 #include <utility>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/checks.h"
 
 namespace webrtc {
diff --git a/api/audio_codecs/builtin_audio_decoder_factory.cc b/api/audio_codecs/builtin_audio_decoder_factory.cc
index c3e5d50..e3ca1b0 100644
--- a/api/audio_codecs/builtin_audio_decoder_factory.cc
+++ b/api/audio_codecs/builtin_audio_decoder_factory.cc
@@ -33,7 +33,8 @@
 template <typename T>
 struct NotAdvertised {
   using Config = typename T::Config;
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
+  static absl::optional<Config> SdpToConfig(
+      const SdpAudioFormat& audio_format) {
     return T::SdpToConfig(audio_format);
   }
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
@@ -41,7 +42,7 @@
   }
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const Config& config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt) {
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
     return T::MakeAudioDecoder(config, codec_pair_id);
   }
 };
diff --git a/api/audio_codecs/builtin_audio_encoder_factory.cc b/api/audio_codecs/builtin_audio_encoder_factory.cc
index 5395404..c0caff4 100644
--- a/api/audio_codecs/builtin_audio_encoder_factory.cc
+++ b/api/audio_codecs/builtin_audio_encoder_factory.cc
@@ -33,7 +33,8 @@
 template <typename T>
 struct NotAdvertised {
   using Config = typename T::Config;
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
+  static absl::optional<Config> SdpToConfig(
+      const SdpAudioFormat& audio_format) {
     return T::SdpToConfig(audio_format);
   }
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
@@ -45,7 +46,7 @@
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const Config& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt) {
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
     return T::MakeAudioEncoder(config, payload_type, codec_pair_id);
   }
 };
diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn
index 7026abb..52e1ee9 100644
--- a/api/audio_codecs/g711/BUILD.gn
+++ b/api/audio_codecs/g711/BUILD.gn
@@ -21,11 +21,11 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:g711",
     "../../../rtc_base:rtc_base_approved",
     "../../../rtc_base:safe_minmax",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -38,9 +38,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:g711",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/g711/audio_decoder_g711.cc b/api/audio_codecs/g711/audio_decoder_g711.cc
index c715e80..e8afa60 100644
--- a/api/audio_codecs/g711/audio_decoder_g711.cc
+++ b/api/audio_codecs/g711/audio_decoder_g711.cc
@@ -20,7 +20,7 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderG711::Config> AudioDecoderG711::SdpToConfig(
+absl::optional<AudioDecoderG711::Config> AudioDecoderG711::SdpToConfig(
     const SdpAudioFormat& format) {
   const bool is_pcmu = STR_CASE_CMP(format.name.c_str(), "PCMU") == 0;
   const bool is_pcma = STR_CASE_CMP(format.name.c_str(), "PCMA") == 0;
@@ -32,7 +32,7 @@
     RTC_DCHECK(config.IsOk());
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -45,7 +45,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderG711::MakeAudioDecoder(
     const Config& config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   switch (config.type) {
     case Config::Type::kPcmU:
diff --git a/api/audio_codecs/g711/audio_decoder_g711.h b/api/audio_codecs/g711/audio_decoder_g711.h
index 5085283..8275a8c 100644
--- a/api/audio_codecs/g711/audio_decoder_g711.h
+++ b/api/audio_codecs/g711/audio_decoder_g711.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -34,11 +34,11 @@
     Type type;
     int num_channels;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const Config& config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc
index e5abc33..95595fa 100644
--- a/api/audio_codecs/g711/audio_encoder_g711.cc
+++ b/api/audio_codecs/g711/audio_encoder_g711.cc
@@ -22,7 +22,7 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderG711::Config> AudioEncoderG711::SdpToConfig(
+absl::optional<AudioEncoderG711::Config> AudioEncoderG711::SdpToConfig(
     const SdpAudioFormat& format) {
   const bool is_pcmu = STR_CASE_CMP(format.name.c_str(), "PCMU") == 0;
   const bool is_pcma = STR_CASE_CMP(format.name.c_str(), "PCMA") == 0;
@@ -42,7 +42,7 @@
     RTC_DCHECK(config.IsOk());
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -62,7 +62,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderG711::MakeAudioEncoder(
     const Config& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   switch (config.type) {
     case Config::Type::kPcmU: {
diff --git a/api/audio_codecs/g711/audio_encoder_g711.h b/api/audio_codecs/g711/audio_encoder_g711.h
index 22a74b4..6b6eb5f 100644
--- a/api/audio_codecs/g711/audio_encoder_g711.h
+++ b/api/audio_codecs/g711/audio_encoder_g711.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -36,14 +36,14 @@
     int num_channels = 1;
     int frame_size_ms = 20;
   };
-  static rtc::Optional<AudioEncoderG711::Config> SdpToConfig(
+  static absl::optional<AudioEncoderG711::Config> SdpToConfig(
       const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const Config& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const Config& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn
index 7078aa4..85a8274 100644
--- a/api/audio_codecs/g722/BUILD.gn
+++ b/api/audio_codecs/g722/BUILD.gn
@@ -29,11 +29,11 @@
   deps = [
     ":audio_encoder_g722_config",
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:g722",
     "../../../rtc_base:rtc_base_approved",
     "../../../rtc_base:safe_minmax",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -46,9 +46,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:g722",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/g722/audio_decoder_g722.cc b/api/audio_codecs/g722/audio_decoder_g722.cc
index 6f72037..04a0a4c 100644
--- a/api/audio_codecs/g722/audio_decoder_g722.cc
+++ b/api/audio_codecs/g722/audio_decoder_g722.cc
@@ -20,14 +20,14 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig(
+absl::optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig(
     const SdpAudioFormat& format) {
   return STR_CASE_CMP(format.name.c_str(), "G722") == 0 &&
                  format.clockrate_hz == 8000 &&
                  (format.num_channels == 1 || format.num_channels == 2)
-             ? rtc::Optional<Config>(
+             ? absl::optional<Config>(
                    Config{rtc::dchecked_cast<int>(format.num_channels)})
-             : rtc::nullopt;
+             : absl::nullopt;
 }
 
 void AudioDecoderG722::AppendSupportedDecoders(
@@ -37,7 +37,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder(
     Config config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   switch (config.num_channels) {
     case 1:
       return rtc::MakeUnique<AudioDecoderG722Impl>();
diff --git a/api/audio_codecs/g722/audio_decoder_g722.h b/api/audio_codecs/g722/audio_decoder_g722.h
index 34235dc..b7bb089 100644
--- a/api/audio_codecs/g722/audio_decoder_g722.h
+++ b/api/audio_codecs/g722/audio_decoder_g722.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -30,11 +30,11 @@
     bool IsOk() const { return num_channels == 1 || num_channels == 2; }
     int num_channels;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       Config config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/g722/audio_encoder_g722.cc b/api/audio_codecs/g722/audio_encoder_g722.cc
index 04074b1..d1f5258 100644
--- a/api/audio_codecs/g722/audio_encoder_g722.cc
+++ b/api/audio_codecs/g722/audio_encoder_g722.cc
@@ -22,11 +22,11 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderG722Config> AudioEncoderG722::SdpToConfig(
+absl::optional<AudioEncoderG722Config> AudioEncoderG722::SdpToConfig(
     const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "g722") != 0 ||
       format.clockrate_hz != 8000) {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 
   AudioEncoderG722Config config;
@@ -39,8 +39,8 @@
       config.frame_size_ms = rtc::SafeClamp<int>(whole_packets * 10, 10, 60);
     }
   }
-  return config.IsOk() ? rtc::Optional<AudioEncoderG722Config>(config)
-                       : rtc::nullopt;
+  return config.IsOk() ? absl::optional<AudioEncoderG722Config>(config)
+                       : absl::nullopt;
 }
 
 void AudioEncoderG722::AppendSupportedEncoders(
@@ -60,7 +60,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderG722::MakeAudioEncoder(
     const AudioEncoderG722Config& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   return rtc::MakeUnique<AudioEncoderG722Impl>(config, payload_type);
 }
diff --git a/api/audio_codecs/g722/audio_encoder_g722.h b/api/audio_codecs/g722/audio_encoder_g722.h
index 08cd304..b97fe1b 100644
--- a/api/audio_codecs/g722/audio_encoder_g722.h
+++ b/api/audio_codecs/g722/audio_encoder_g722.h
@@ -14,11 +14,11 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
 #include "api/audio_codecs/g722/audio_encoder_g722_config.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -28,14 +28,14 @@
 // NOTE: This struct is still under development and may change without notice.
 struct AudioEncoderG722 {
   using Config = AudioEncoderG722Config;
-  static rtc::Optional<AudioEncoderG722Config> SdpToConfig(
+  static absl::optional<AudioEncoderG722Config> SdpToConfig(
       const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const AudioEncoderG722Config& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const AudioEncoderG722Config& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn
index 52dac5f..e1b2731 100644
--- a/api/audio_codecs/ilbc/BUILD.gn
+++ b/api/audio_codecs/ilbc/BUILD.gn
@@ -29,11 +29,11 @@
   deps = [
     ":audio_encoder_ilbc_config",
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:ilbc",
     "../../../rtc_base:rtc_base_approved",
     "../../../rtc_base:safe_minmax",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -46,9 +46,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:ilbc",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc
index 88a2471..f1ecbdc 100644
--- a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc
+++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc
@@ -19,12 +19,12 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderIlbc::Config> AudioDecoderIlbc::SdpToConfig(
+absl::optional<AudioDecoderIlbc::Config> AudioDecoderIlbc::SdpToConfig(
     const SdpAudioFormat& format) {
   return STR_CASE_CMP(format.name.c_str(), "ILBC") == 0 &&
                  format.clockrate_hz == 8000 && format.num_channels == 1
-             ? rtc::Optional<Config>(Config())
-             : rtc::nullopt;
+             ? absl::optional<Config>(Config())
+             : absl::nullopt;
 }
 
 void AudioDecoderIlbc::AppendSupportedDecoders(
@@ -34,7 +34,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderIlbc::MakeAudioDecoder(
     Config config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   return rtc::MakeUnique<AudioDecoderIlbcImpl>();
 }
 
diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/api/audio_codecs/ilbc/audio_decoder_ilbc.h
index c233c4b..20f6ffd 100644
--- a/api/audio_codecs/ilbc/audio_decoder_ilbc.h
+++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -27,11 +27,11 @@
 // NOTE: This struct is still under development and may change without notice.
 struct AudioDecoderIlbc {
   struct Config {};  // Empty---no config values needed!
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       Config config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc
index 53dfdd3..59a16b5 100644
--- a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc
+++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc
@@ -38,11 +38,11 @@
 }
 }  // namespace
 
-rtc::Optional<AudioEncoderIlbcConfig> AudioEncoderIlbc::SdpToConfig(
+absl::optional<AudioEncoderIlbcConfig> AudioEncoderIlbc::SdpToConfig(
     const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "ILBC") != 0 ||
       format.clockrate_hz != 8000 || format.num_channels != 1) {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 
   AudioEncoderIlbcConfig config;
@@ -54,8 +54,8 @@
       config.frame_size_ms = rtc::SafeClamp<int>(whole_packets * 10, 20, 60);
     }
   }
-  return config.IsOk() ? rtc::Optional<AudioEncoderIlbcConfig>(config)
-                       : rtc::nullopt;
+  return config.IsOk() ? absl::optional<AudioEncoderIlbcConfig>(config)
+                       : absl::nullopt;
 }
 
 void AudioEncoderIlbc::AppendSupportedEncoders(
@@ -74,7 +74,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderIlbc::MakeAudioEncoder(
     const AudioEncoderIlbcConfig& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   return rtc::MakeUnique<AudioEncoderIlbcImpl>(config, payload_type);
 }
diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/api/audio_codecs/ilbc/audio_encoder_ilbc.h
index 85cdab0..0a86b16 100644
--- a/api/audio_codecs/ilbc/audio_encoder_ilbc.h
+++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.h
@@ -14,11 +14,11 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
 #include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -28,14 +28,14 @@
 // NOTE: This struct is still under development and may change without notice.
 struct AudioEncoderIlbc {
   using Config = AudioEncoderIlbcConfig;
-  static rtc::Optional<AudioEncoderIlbcConfig> SdpToConfig(
+  static absl::optional<AudioEncoderIlbcConfig> SdpToConfig(
       const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const AudioEncoderIlbcConfig& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const AudioEncoderIlbcConfig& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/isac/BUILD.gn b/api/audio_codecs/isac/BUILD.gn
index 08cabc5..e8e6d23 100644
--- a/api/audio_codecs/isac/BUILD.gn
+++ b/api/audio_codecs/isac/BUILD.gn
@@ -77,10 +77,10 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:isac_fix",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -93,10 +93,10 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:isac_fix",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -109,10 +109,10 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:isac",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -125,9 +125,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:isac",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.cc b/api/audio_codecs/isac/audio_decoder_isac_fix.cc
index ab220f0..8435d05 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_fix.cc
+++ b/api/audio_codecs/isac/audio_decoder_isac_fix.cc
@@ -16,12 +16,12 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderIsacFix::Config> AudioDecoderIsacFix::SdpToConfig(
+absl::optional<AudioDecoderIsacFix::Config> AudioDecoderIsacFix::SdpToConfig(
     const SdpAudioFormat& format) {
   return STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 &&
                  format.clockrate_hz == 16000 && format.num_channels == 1
-             ? rtc::Optional<Config>(Config())
-             : rtc::nullopt;
+             ? absl::optional<Config>(Config())
+             : absl::nullopt;
 }
 
 void AudioDecoderIsacFix::AppendSupportedDecoders(
@@ -31,7 +31,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderIsacFix::MakeAudioDecoder(
     Config config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   return rtc::MakeUnique<AudioDecoderIsacFixImpl>(16000);
 }
 
diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.h b/api/audio_codecs/isac/audio_decoder_isac_fix.h
index 115486c..a4ce685 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_fix.h
+++ b/api/audio_codecs/isac/audio_decoder_isac_fix.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -27,11 +27,11 @@
 // NOTE: This struct is still under development and may change without notice.
 struct AudioDecoderIsacFix {
   struct Config {};  // Empty---no config values needed!
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       Config config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.cc b/api/audio_codecs/isac/audio_decoder_isac_float.cc
index e568f07..2e08e55 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_float.cc
+++ b/api/audio_codecs/isac/audio_decoder_isac_float.cc
@@ -16,8 +16,8 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderIsacFloat::Config> AudioDecoderIsacFloat::SdpToConfig(
-    const SdpAudioFormat& format) {
+absl::optional<AudioDecoderIsacFloat::Config>
+AudioDecoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 &&
       (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) &&
       format.num_channels == 1) {
@@ -25,7 +25,7 @@
     config.sample_rate_hz = format.clockrate_hz;
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -37,7 +37,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderIsacFloat::MakeAudioDecoder(
     Config config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   return rtc::MakeUnique<AudioDecoderIsacFloatImpl>(config.sample_rate_hz);
 }
diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.h b/api/audio_codecs/isac/audio_decoder_isac_float.h
index 47c2c60..cc13963 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_float.h
+++ b/api/audio_codecs/isac/audio_decoder_isac_float.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -32,11 +32,11 @@
     }
     int sample_rate_hz = 16000;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       Config config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.cc b/api/audio_codecs/isac/audio_encoder_isac_fix.cc
index e2c7958..cb41214 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_fix.cc
+++ b/api/audio_codecs/isac/audio_encoder_isac_fix.cc
@@ -17,7 +17,7 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderIsacFix::Config> AudioEncoderIsacFix::SdpToConfig(
+absl::optional<AudioEncoderIsacFix::Config> AudioEncoderIsacFix::SdpToConfig(
     const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 &&
       format.clockrate_hz == 16000 && format.num_channels == 1) {
@@ -31,7 +31,7 @@
     }
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -51,7 +51,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderIsacFix::MakeAudioEncoder(
     AudioEncoderIsacFix::Config config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   AudioEncoderIsacFixImpl::Config c;
   c.frame_size_ms = config.frame_size_ms;
diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.h b/api/audio_codecs/isac/audio_encoder_isac_fix.h
index 7f2743c..731e48d0 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_fix.h
+++ b/api/audio_codecs/isac/audio_encoder_isac_fix.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -30,13 +30,13 @@
     bool IsOk() const { return frame_size_ms == 30 || frame_size_ms == 60; }
     int frame_size_ms = 30;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(Config config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       Config config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.cc b/api/audio_codecs/isac/audio_encoder_isac_float.cc
index 5fbbe2b..510244c 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_float.cc
+++ b/api/audio_codecs/isac/audio_encoder_isac_float.cc
@@ -17,8 +17,8 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderIsacFloat::Config> AudioEncoderIsacFloat::SdpToConfig(
-    const SdpAudioFormat& format) {
+absl::optional<AudioEncoderIsacFloat::Config>
+AudioEncoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 &&
       (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) &&
       format.num_channels == 1) {
@@ -37,7 +37,7 @@
     }
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -62,7 +62,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderIsacFloat::MakeAudioEncoder(
     const AudioEncoderIsacFloat::Config& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   RTC_DCHECK(config.IsOk());
   AudioEncoderIsacFloatImpl::Config c;
   c.sample_rate_hz = config.sample_rate_hz;
diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.h b/api/audio_codecs/isac/audio_encoder_isac_float.h
index b6043f2..6d98bf9 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_float.h
+++ b/api/audio_codecs/isac/audio_encoder_isac_float.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -35,13 +35,13 @@
     int sample_rate_hz = 16000;
     int frame_size_ms = 30;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const Config& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const Config& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn
index d235d1a..953482e 100644
--- a/api/audio_codecs/opus/BUILD.gn
+++ b/api/audio_codecs/opus/BUILD.gn
@@ -19,8 +19,8 @@
     "audio_encoder_opus_config.h",
   ]
   deps = [
-    "../..:optional",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
   defines = []
   if (rtc_opus_variable_complexity) {
@@ -42,9 +42,9 @@
   deps = [
     ":audio_encoder_opus_config",
     "..:audio_codecs_api",
-    "../..:optional",
     "../../../modules/audio_coding:webrtc_opus",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -57,9 +57,9 @@
   ]
   deps = [
     "..:audio_codecs_api",
-    "../..:optional",
     "../../..:webrtc_common",
     "../../../modules/audio_coding:webrtc_opus",
     "../../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/audio_codecs/opus/audio_decoder_opus.cc b/api/audio_codecs/opus/audio_decoder_opus.cc
index 73a0a3f..81bee77 100644
--- a/api/audio_codecs/opus/audio_decoder_opus.cc
+++ b/api/audio_codecs/opus/audio_decoder_opus.cc
@@ -20,9 +20,9 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioDecoderOpus::Config> AudioDecoderOpus::SdpToConfig(
+absl::optional<AudioDecoderOpus::Config> AudioDecoderOpus::SdpToConfig(
     const SdpAudioFormat& format) {
-  const auto num_channels = [&]() -> rtc::Optional<int> {
+  const auto num_channels = [&]() -> absl::optional<int> {
     auto stereo = format.parameters.find("stereo");
     if (stereo != format.parameters.end()) {
       if (stereo->second == "0") {
@@ -30,7 +30,7 @@
       } else if (stereo->second == "1") {
         return 2;
       } else {
-        return rtc::nullopt;  // Bad stereo parameter.
+        return absl::nullopt;  // Bad stereo parameter.
       }
     }
     return 1;  // Default to mono.
@@ -40,7 +40,7 @@
       num_channels) {
     return Config{*num_channels};
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
@@ -56,7 +56,7 @@
 
 std::unique_ptr<AudioDecoder> AudioDecoderOpus::MakeAudioDecoder(
     Config config,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   return rtc::MakeUnique<AudioDecoderOpusImpl>(config.num_channels);
 }
 
diff --git a/api/audio_codecs/opus/audio_decoder_opus.h b/api/audio_codecs/opus/audio_decoder_opus.h
index f76d244..de26026 100644
--- a/api/audio_codecs/opus/audio_decoder_opus.h
+++ b/api/audio_codecs/opus/audio_decoder_opus.h
@@ -14,10 +14,10 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -29,11 +29,11 @@
   struct Config {
     int num_channels;
   };
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+  static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
   static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       Config config,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/opus/audio_encoder_opus.cc b/api/audio_codecs/opus/audio_encoder_opus.cc
index 8ba66fb..36d82b3 100644
--- a/api/audio_codecs/opus/audio_encoder_opus.cc
+++ b/api/audio_codecs/opus/audio_encoder_opus.cc
@@ -14,7 +14,7 @@
 
 namespace webrtc {
 
-rtc::Optional<AudioEncoderOpusConfig> AudioEncoderOpus::SdpToConfig(
+absl::optional<AudioEncoderOpusConfig> AudioEncoderOpus::SdpToConfig(
     const SdpAudioFormat& format) {
   return AudioEncoderOpusImpl::SdpToConfig(format);
 }
@@ -32,7 +32,7 @@
 std::unique_ptr<AudioEncoder> AudioEncoderOpus::MakeAudioEncoder(
     const AudioEncoderOpusConfig& config,
     int payload_type,
-    rtc::Optional<AudioCodecPairId> /*codec_pair_id*/) {
+    absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
   return AudioEncoderOpusImpl::MakeAudioEncoder(config, payload_type);
 }
 
diff --git a/api/audio_codecs/opus/audio_encoder_opus.h b/api/audio_codecs/opus/audio_encoder_opus.h
index 6325269..20aaaf7 100644
--- a/api/audio_codecs/opus/audio_encoder_opus.h
+++ b/api/audio_codecs/opus/audio_encoder_opus.h
@@ -14,11 +14,11 @@
 #include <memory>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/audio_codecs/audio_codec_pair_id.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/audio_format.h"
 #include "api/audio_codecs/opus/audio_encoder_opus_config.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -28,14 +28,14 @@
 // NOTE: This struct is still under development and may change without notice.
 struct AudioEncoderOpus {
   using Config = AudioEncoderOpusConfig;
-  static rtc::Optional<AudioEncoderOpusConfig> SdpToConfig(
+  static absl::optional<AudioEncoderOpusConfig> SdpToConfig(
       const SdpAudioFormat& audio_format);
   static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
   static AudioCodecInfo QueryAudioEncoder(const AudioEncoderOpusConfig& config);
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const AudioEncoderOpusConfig& config,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> codec_pair_id = rtc::nullopt);
+      absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt);
 };
 
 }  // namespace webrtc
diff --git a/api/audio_codecs/opus/audio_encoder_opus_config.h b/api/audio_codecs/opus/audio_encoder_opus_config.h
index d586592..c7067bb 100644
--- a/api/audio_codecs/opus/audio_encoder_opus_config.h
+++ b/api/audio_codecs/opus/audio_encoder_opus_config.h
@@ -15,7 +15,7 @@
 
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace webrtc {
 
@@ -42,7 +42,7 @@
 
   // NOTE: This member must always be set.
   // TODO(kwiberg): Turn it into just an int.
-  rtc::Optional<int> bitrate_bps;
+  absl::optional<int> bitrate_bps;
 
   bool fec_enabled;
   bool cbr_enabled;
diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc
index 5fa4344..e4f09d4 100644
--- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc
+++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc
@@ -43,12 +43,13 @@
     SdpAudioFormat audio_format;
   };
 
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
+  static absl::optional<Config> SdpToConfig(
+      const SdpAudioFormat& audio_format) {
     if (Params::AudioFormat() == audio_format) {
       Config config = {audio_format};
       return config;
     } else {
-      return rtc::nullopt;
+      return absl::nullopt;
     }
   }
 
@@ -62,7 +63,7 @@
 
   static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
       const Config&,
-      rtc::Optional<AudioCodecPairId> /*codec_pair_id*/ = rtc::nullopt) {
+      absl::optional<AudioCodecPairId> /*codec_pair_id*/ = absl::nullopt) {
     auto dec = rtc::MakeUnique<testing::StrictMock<MockAudioDecoder>>();
     EXPECT_CALL(*dec, SampleRateHz())
         .WillOnce(testing::Return(Params::CodecInfo().sample_rate_hz));
@@ -80,7 +81,7 @@
   EXPECT_THAT(factory->GetSupportedDecoders(), testing::IsEmpty());
   EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"bar", 16000, 1}, rtc::nullopt));
+            factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
 }
 
 TEST(AudioDecoderFactoryTemplateTest, OneDecoderType) {
@@ -91,8 +92,8 @@
   EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"bogus", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"bar", 16000, 1}, rtc::nullopt));
-  auto dec = factory->MakeAudioDecoder({"bogus", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+  auto dec = factory->MakeAudioDecoder({"bogus", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec);
   EXPECT_EQ(8000, dec->SampleRateHz());
 }
@@ -110,14 +111,14 @@
   EXPECT_TRUE(
       factory->IsSupportedDecoder({"sham", 16000, 2, {{"param", "value"}}}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"bar", 16000, 1}, rtc::nullopt));
-  auto dec1 = factory->MakeAudioDecoder({"bogus", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+  auto dec1 = factory->MakeAudioDecoder({"bogus", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec1);
   EXPECT_EQ(8000, dec1->SampleRateHz());
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"sham", 16000, 2}, rtc::nullopt));
+            factory->MakeAudioDecoder({"sham", 16000, 2}, absl::nullopt));
   auto dec2 = factory->MakeAudioDecoder(
-      {"sham", 16000, 2, {{"param", "value"}}}, rtc::nullopt);
+      {"sham", 16000, 2, {{"param", "value"}}}, absl::nullopt);
   ASSERT_NE(nullptr, dec2);
   EXPECT_EQ(16000, dec2->SampleRateHz());
 }
@@ -132,11 +133,11 @@
   EXPECT_TRUE(factory->IsSupportedDecoder({"PCMU", 8000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"pcma", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"pcmu", 16000, 1}, rtc::nullopt));
-  auto dec1 = factory->MakeAudioDecoder({"pcmu", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"pcmu", 16000, 1}, absl::nullopt));
+  auto dec1 = factory->MakeAudioDecoder({"pcmu", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec1);
   EXPECT_EQ(8000, dec1->SampleRateHz());
-  auto dec2 = factory->MakeAudioDecoder({"PCMA", 8000, 1}, rtc::nullopt);
+  auto dec2 = factory->MakeAudioDecoder({"PCMA", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec2);
   EXPECT_EQ(8000, dec2->SampleRateHz());
 }
@@ -149,16 +150,16 @@
   EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"G722", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"bar", 16000, 1}, rtc::nullopt));
-  auto dec1 = factory->MakeAudioDecoder({"G722", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+  auto dec1 = factory->MakeAudioDecoder({"G722", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec1);
   EXPECT_EQ(16000, dec1->SampleRateHz());
   EXPECT_EQ(1u, dec1->Channels());
-  auto dec2 = factory->MakeAudioDecoder({"G722", 8000, 2}, rtc::nullopt);
+  auto dec2 = factory->MakeAudioDecoder({"G722", 8000, 2}, absl::nullopt);
   ASSERT_NE(nullptr, dec2);
   EXPECT_EQ(16000, dec2->SampleRateHz());
   EXPECT_EQ(2u, dec2->Channels());
-  auto dec3 = factory->MakeAudioDecoder({"G722", 8000, 3}, rtc::nullopt);
+  auto dec3 = factory->MakeAudioDecoder({"G722", 8000, 3}, absl::nullopt);
   ASSERT_EQ(nullptr, dec3);
 }
 
@@ -169,8 +170,9 @@
                   AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}}));
   EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1}));
-  EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 8000, 1}, rtc::nullopt));
-  auto dec = factory->MakeAudioDecoder({"ilbc", 8000, 1}, rtc::nullopt);
+  EXPECT_EQ(nullptr,
+            factory->MakeAudioDecoder({"bar", 8000, 1}, absl::nullopt));
+  auto dec = factory->MakeAudioDecoder({"ilbc", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec);
   EXPECT_EQ(8000, dec->SampleRateHz());
 }
@@ -184,8 +186,8 @@
   EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1}));
   EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 32000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"isac", 8000, 1}, rtc::nullopt));
-  auto dec = factory->MakeAudioDecoder({"isac", 16000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"isac", 8000, 1}, absl::nullopt));
+  auto dec = factory->MakeAudioDecoder({"isac", 16000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec);
   EXPECT_EQ(16000, dec->SampleRateHz());
 }
@@ -201,11 +203,11 @@
   EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 32000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"isac", 8000, 1}, rtc::nullopt));
-  auto dec1 = factory->MakeAudioDecoder({"isac", 16000, 1}, rtc::nullopt);
+            factory->MakeAudioDecoder({"isac", 8000, 1}, absl::nullopt));
+  auto dec1 = factory->MakeAudioDecoder({"isac", 16000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec1);
   EXPECT_EQ(16000, dec1->SampleRateHz());
-  auto dec2 = factory->MakeAudioDecoder({"isac", 32000, 1}, rtc::nullopt);
+  auto dec2 = factory->MakeAudioDecoder({"isac", 32000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, dec2);
   EXPECT_EQ(32000, dec2->SampleRateHz());
 }
@@ -224,8 +226,9 @@
   EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"L16", 48000, 1}));
   EXPECT_FALSE(factory->IsSupportedDecoder({"L16", 96000, 1}));
-  EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"L16", 8000, 0}, rtc::nullopt));
-  auto dec = factory->MakeAudioDecoder({"L16", 48000, 2}, rtc::nullopt);
+  EXPECT_EQ(nullptr,
+            factory->MakeAudioDecoder({"L16", 8000, 0}, absl::nullopt));
+  auto dec = factory->MakeAudioDecoder({"L16", 48000, 2}, absl::nullopt);
   ASSERT_NE(nullptr, dec);
   EXPECT_EQ(48000, dec->SampleRateHz());
 }
@@ -242,8 +245,8 @@
   EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1}));
   EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioDecoder({"bar", 16000, 1}, rtc::nullopt));
-  auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}, rtc::nullopt);
+            factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+  auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}, absl::nullopt);
   ASSERT_NE(nullptr, dec);
   EXPECT_EQ(48000, dec->SampleRateHz());
 }
diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
index 3da588d..46781ce 100644
--- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
+++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
@@ -43,12 +43,13 @@
     SdpAudioFormat audio_format;
   };
 
-  static rtc::Optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
+  static absl::optional<Config> SdpToConfig(
+      const SdpAudioFormat& audio_format) {
     if (Params::AudioFormat() == audio_format) {
       Config config = {audio_format};
       return config;
     } else {
-      return rtc::nullopt;
+      return absl::nullopt;
     }
   }
 
@@ -63,7 +64,7 @@
   static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
       const Config&,
       int payload_type,
-      rtc::Optional<AudioCodecPairId> /*codec_pair_id*/ = rtc::nullopt) {
+      absl::optional<AudioCodecPairId> /*codec_pair_id*/ = absl::nullopt) {
     auto enc = rtc::MakeUnique<testing::StrictMock<MockAudioEncoder>>();
     EXPECT_CALL(*enc, SampleRateHz())
         .WillOnce(testing::Return(Params::CodecInfo().sample_rate_hz));
@@ -78,9 +79,9 @@
       new rtc::RefCountedObject<
           audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>());
   EXPECT_THAT(factory->GetSupportedEncoders(), testing::IsEmpty());
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, rtc::nullopt));
+            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
 }
 
 TEST(AudioEncoderFactoryTemplateTest, OneEncoderType) {
@@ -88,12 +89,12 @@
   EXPECT_THAT(factory->GetSupportedEncoders(),
               testing::ElementsAre(
                   AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(AudioCodecInfo(8000, 1, 12345),
             factory->QueryAudioEncoder({"bogus", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, rtc::nullopt));
-  auto enc = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+  auto enc = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc);
   EXPECT_EQ(8000, enc->SampleRateHz());
 }
@@ -106,21 +107,21 @@
                   AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}},
                   AudioCodecSpec{{"sham", 16000, 2, {{"param", "value"}}},
                                  {16000, 2, 23456}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(AudioCodecInfo(8000, 1, 12345),
             factory->QueryAudioEncoder({"bogus", 8000, 1}));
   EXPECT_EQ(
       AudioCodecInfo(16000, 2, 23456),
       factory->QueryAudioEncoder({"sham", 16000, 2, {{"param", "value"}}}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, rtc::nullopt));
-  auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+  auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc1);
   EXPECT_EQ(8000, enc1->SampleRateHz());
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"sham", 16000, 2}, rtc::nullopt));
+            factory->MakeAudioEncoder(17, {"sham", 16000, 2}, absl::nullopt));
   auto enc2 = factory->MakeAudioEncoder(
-      17, {"sham", 16000, 2, {{"param", "value"}}}, rtc::nullopt);
+      17, {"sham", 16000, 2, {{"param", "value"}}}, absl::nullopt);
   ASSERT_NE(nullptr, enc2);
   EXPECT_EQ(16000, enc2->SampleRateHz());
 }
@@ -131,15 +132,15 @@
               testing::ElementsAre(
                   AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}},
                   AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"PCMA", 16000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"PCMA", 16000, 1}));
   EXPECT_EQ(AudioCodecInfo(8000, 1, 64000),
             factory->QueryAudioEncoder({"PCMA", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"PCMU", 16000, 1}, rtc::nullopt));
-  auto enc1 = factory->MakeAudioEncoder(17, {"PCMU", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"PCMU", 16000, 1}, absl::nullopt));
+  auto enc1 = factory->MakeAudioEncoder(17, {"PCMU", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc1);
   EXPECT_EQ(8000, enc1->SampleRateHz());
-  auto enc2 = factory->MakeAudioEncoder(17, {"PCMA", 8000, 1}, rtc::nullopt);
+  auto enc2 = factory->MakeAudioEncoder(17, {"PCMA", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc2);
   EXPECT_EQ(8000, enc2->SampleRateHz());
 }
@@ -149,12 +150,12 @@
   EXPECT_THAT(factory->GetSupportedEncoders(),
               testing::ElementsAre(
                   AudioCodecSpec{{"G722", 8000, 1}, {16000, 1, 64000}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(AudioCodecInfo(16000, 1, 64000),
             factory->QueryAudioEncoder({"G722", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, rtc::nullopt));
-  auto enc = factory->MakeAudioEncoder(17, {"G722", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+  auto enc = factory->MakeAudioEncoder(17, {"G722", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc);
   EXPECT_EQ(16000, enc->SampleRateHz());
 }
@@ -164,12 +165,12 @@
   EXPECT_THAT(factory->GetSupportedEncoders(),
               testing::ElementsAre(
                   AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13333}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(AudioCodecInfo(8000, 1, 13333),
             factory->QueryAudioEncoder({"ilbc", 8000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 8000, 1}, rtc::nullopt));
-  auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"bar", 8000, 1}, absl::nullopt));
+  auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc);
   EXPECT_EQ(8000, enc->SampleRateHz());
 }
@@ -179,18 +180,18 @@
   EXPECT_THAT(factory->GetSupportedEncoders(),
               testing::ElementsAre(AudioCodecSpec{
                   {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
   EXPECT_EQ(AudioCodecInfo(16000, 1, 32000, 10000, 32000),
             factory->QueryAudioEncoder({"isac", 16000, 1}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"isac", 32000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 32000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"isac", 8000, 1}, rtc::nullopt));
-  auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"isac", 8000, 1}, absl::nullopt));
+  auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc1);
   EXPECT_EQ(16000, enc1->SampleRateHz());
   EXPECT_EQ(3u, enc1->Num10MsFramesInNextPacket());
   auto enc2 = factory->MakeAudioEncoder(
-      17, {"isac", 16000, 1, {{"ptime", "60"}}}, rtc::nullopt);
+      17, {"isac", 16000, 1, {{"ptime", "60"}}}, absl::nullopt);
   ASSERT_NE(nullptr, enc2);
   EXPECT_EQ(6u, enc2->Num10MsFramesInNextPacket());
 }
@@ -202,17 +203,17 @@
       testing::ElementsAre(
           AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}},
           AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
   EXPECT_EQ(AudioCodecInfo(16000, 1, 32000, 10000, 32000),
             factory->QueryAudioEncoder({"isac", 16000, 1}));
   EXPECT_EQ(AudioCodecInfo(32000, 1, 56000, 10000, 56000),
             factory->QueryAudioEncoder({"isac", 32000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"isac", 8000, 1}, rtc::nullopt));
-  auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"isac", 8000, 1}, absl::nullopt));
+  auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc1);
   EXPECT_EQ(16000, enc1->SampleRateHz());
-  auto enc2 = factory->MakeAudioEncoder(17, {"isac", 32000, 1}, rtc::nullopt);
+  auto enc2 = factory->MakeAudioEncoder(17, {"isac", 32000, 1}, absl::nullopt);
   ASSERT_NE(nullptr, enc2);
   EXPECT_EQ(32000, enc2->SampleRateHz());
 }
@@ -228,12 +229,12 @@
           AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}},
           AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}},
           AudioCodecSpec{{"L16", 32000, 2}, {32000, 2, 32000 * 16 * 2}}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"L16", 8000, 0}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"L16", 8000, 0}));
   EXPECT_EQ(AudioCodecInfo(48000, 1, 48000 * 16),
             factory->QueryAudioEncoder({"L16", 48000, 1}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"L16", 8000, 0}, rtc::nullopt));
-  auto enc = factory->MakeAudioEncoder(17, {"L16", 48000, 2}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"L16", 8000, 0}, absl::nullopt));
+  auto enc = factory->MakeAudioEncoder(17, {"L16", 48000, 2}, absl::nullopt);
   ASSERT_NE(nullptr, enc);
   EXPECT_EQ(48000, enc->SampleRateHz());
 }
@@ -248,14 +249,14 @@
       testing::ElementsAre(AudioCodecSpec{
           {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}},
           info}));
-  EXPECT_EQ(rtc::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+  EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
   EXPECT_EQ(
       info,
       factory->QueryAudioEncoder(
           {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}));
   EXPECT_EQ(nullptr,
-            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, rtc::nullopt));
-  auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}, rtc::nullopt);
+            factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+  auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}, absl::nullopt);
   ASSERT_NE(nullptr, enc);
   EXPECT_EQ(48000, enc->SampleRateHz());
 }
diff --git a/api/audio_options.h b/api/audio_options.h
index 28f03b6..df66d36 100644
--- a/api/audio_options.h
+++ b/api/audio_options.h
@@ -13,7 +13,7 @@
 
 #include <string>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/stringencode.h"
 
 namespace cricket {
@@ -126,53 +126,53 @@
 
   // Audio processing that attempts to filter away the output signal from
   // later inbound pickup.
-  rtc::Optional<bool> echo_cancellation;
+  absl::optional<bool> echo_cancellation;
 #if defined(WEBRTC_IOS)
   // Forces software echo cancellation on iOS. This is a temporary workaround
   // (until Apple fixes the bug) for a device with non-functioning AEC. May
   // improve performance on that particular device, but will cause unpredictable
   // behavior in all other cases. See http://bugs.webrtc.org/8682.
-  rtc::Optional<bool> ios_force_software_aec_HACK;
+  absl::optional<bool> ios_force_software_aec_HACK;
 #endif
   // Audio processing to adjust the sensitivity of the local mic dynamically.
-  rtc::Optional<bool> auto_gain_control;
+  absl::optional<bool> auto_gain_control;
   // Audio processing to filter out background noise.
-  rtc::Optional<bool> noise_suppression;
+  absl::optional<bool> noise_suppression;
   // Audio processing to remove background noise of lower frequencies.
-  rtc::Optional<bool> highpass_filter;
+  absl::optional<bool> highpass_filter;
   // Audio processing to swap the left and right channels.
-  rtc::Optional<bool> stereo_swapping;
+  absl::optional<bool> stereo_swapping;
   // Audio receiver jitter buffer (NetEq) max capacity in number of packets.
-  rtc::Optional<int> audio_jitter_buffer_max_packets;
+  absl::optional<int> audio_jitter_buffer_max_packets;
   // Audio receiver jitter buffer (NetEq) fast accelerate mode.
-  rtc::Optional<bool> audio_jitter_buffer_fast_accelerate;
+  absl::optional<bool> audio_jitter_buffer_fast_accelerate;
   // Audio processing to detect typing.
-  rtc::Optional<bool> typing_detection;
-  rtc::Optional<bool> aecm_generate_comfort_noise;
-  rtc::Optional<bool> experimental_agc;
-  rtc::Optional<bool> extended_filter_aec;
-  rtc::Optional<bool> delay_agnostic_aec;
-  rtc::Optional<bool> experimental_ns;
-  rtc::Optional<bool> intelligibility_enhancer;
+  absl::optional<bool> typing_detection;
+  absl::optional<bool> aecm_generate_comfort_noise;
+  absl::optional<bool> experimental_agc;
+  absl::optional<bool> extended_filter_aec;
+  absl::optional<bool> delay_agnostic_aec;
+  absl::optional<bool> experimental_ns;
+  absl::optional<bool> intelligibility_enhancer;
   // Note that tx_agc_* only applies to non-experimental AGC.
-  rtc::Optional<bool> residual_echo_detector;
-  rtc::Optional<uint16_t> tx_agc_target_dbov;
-  rtc::Optional<uint16_t> tx_agc_digital_compression_gain;
-  rtc::Optional<bool> tx_agc_limiter;
+  absl::optional<bool> residual_echo_detector;
+  absl::optional<uint16_t> tx_agc_target_dbov;
+  absl::optional<uint16_t> tx_agc_digital_compression_gain;
+  absl::optional<bool> tx_agc_limiter;
   // Enable combined audio+bandwidth BWE.
   // TODO(pthatcher): This flag is set from the
   // "googCombinedAudioVideoBwe", but not used anywhere. So delete it,
   // and check if any other AudioOptions members are unused.
-  rtc::Optional<bool> combined_audio_video_bwe;
+  absl::optional<bool> combined_audio_video_bwe;
   // Enable audio network adaptor.
-  rtc::Optional<bool> audio_network_adaptor;
+  absl::optional<bool> audio_network_adaptor;
   // Config string for audio network adaptor.
-  rtc::Optional<std::string> audio_network_adaptor_config;
+  absl::optional<std::string> audio_network_adaptor_config;
 
  private:
   template <class T>
   static std::string ToStringIfSet(const char* key,
-                                   const rtc::Optional<T>& val) {
+                                   const absl::optional<T>& val) {
     std::string str;
     if (val) {
       str = key;
@@ -184,7 +184,7 @@
   }
 
   template <typename T>
-  static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) {
+  static void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) {
     if (o) {
       *s = o;
     }
diff --git a/api/datachannelinterface.h b/api/datachannelinterface.h
index 85e6fa6..5cbe717 100644
--- a/api/datachannelinterface.h
+++ b/api/datachannelinterface.h
@@ -23,7 +23,7 @@
 namespace webrtc {
 
 // C++ version of: https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannelinit
-// TODO(deadbeef): Use rtc::Optional for the "-1 if unset" things.
+// TODO(deadbeef): Use absl::optional for the "-1 if unset" things.
 struct DataChannelInit {
   // Deprecated. Reliability is assumed, and channel will be unreliable if
   // maxRetransmitTime or MaxRetransmits is set.
diff --git a/api/jsep.h b/api/jsep.h
index 0118490..dbf97f6 100644
--- a/api/jsep.h
+++ b/api/jsep.h
@@ -26,7 +26,7 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/rtcerror.h"
 #include "rtc_base/refcount.h"
 
@@ -107,7 +107,7 @@
 // Returns the SdpType from its string form. The string form can be one of the
 // constants defined in SessionDescriptionInterface. Passing in any other string
 // results in nullopt.
-rtc::Optional<SdpType> SdpTypeFromString(const std::string& type_str);
+absl::optional<SdpType> SdpTypeFromString(const std::string& type_str);
 
 // Class representation of an SDP session description.
 //
diff --git a/api/mediaconstraintsinterface.cc b/api/mediaconstraintsinterface.cc
index 50a26de..fb4481f 100644
--- a/api/mediaconstraintsinterface.cc
+++ b/api/mediaconstraintsinterface.cc
@@ -59,11 +59,11 @@
 }
 
 // Converts a constraint (mandatory takes precedence over optional) to an
-// rtc::Optional.
+// absl::optional.
 template <typename T>
 void ConstraintToOptional(const webrtc::MediaConstraintsInterface* constraints,
                           const std::string& key,
-                          rtc::Optional<T>* value_out) {
+                          absl::optional<T>* value_out) {
   T value;
   bool present = FindConstraint<T>(constraints, key, &value, nullptr);
   if (present) {
diff --git a/api/mediaconstraintsinterface.h b/api/mediaconstraintsinterface.h
index 91043d2..54ab706 100644
--- a/api/mediaconstraintsinterface.h
+++ b/api/mediaconstraintsinterface.h
@@ -23,7 +23,7 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/peerconnectioninterface.h"
 
 namespace webrtc {
diff --git a/api/mediastreaminterface.h b/api/mediastreaminterface.h
index 416073d..b661351 100644
--- a/api/mediastreaminterface.h
+++ b/api/mediastreaminterface.h
@@ -22,7 +22,7 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/video/video_frame.h"
 // TODO(zhihuang): Remove unrelated headers once downstream applications stop
 // relying on them; they were previously transitively included by
@@ -132,7 +132,7 @@
   // depending on video codec.
   // TODO(perkj): Remove this once denoising is done by the source, and not by
   // the encoder.
-  virtual rtc::Optional<bool> needs_denoising() const = 0;
+  virtual absl::optional<bool> needs_denoising() const = 0;
 
   // Returns false if no stats are available, e.g, for a remote source, or a
   // source which has not seen its first frame yet.
diff --git a/api/ortc/mediadescription.h b/api/ortc/mediadescription.h
index 1a6d0e9..5cf1d1a 100644
--- a/api/ortc/mediadescription.h
+++ b/api/ortc/mediadescription.h
@@ -15,8 +15,8 @@
 #include <utility>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/cryptoparams.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -31,7 +31,7 @@
   // The mid(media stream identification) is used for identifying media streams
   // within a session description.
   // https://tools.ietf.org/html/rfc5888#section-6
-  rtc::Optional<std::string> mid() const { return mid_; }
+  absl::optional<std::string> mid() const { return mid_; }
   void set_mid(std::string mid) { mid_.emplace(std::move(mid)); }
 
   // Security keys and parameters for this media stream. Can be used to
@@ -43,7 +43,7 @@
   }
 
  private:
-  rtc::Optional<std::string> mid_;
+  absl::optional<std::string> mid_;
 
   std::vector<cricket::CryptoParams> sdes_params_;
 };
diff --git a/api/ortc/rtptransportinterface.h b/api/ortc/rtptransportinterface.h
index 8822300..b0d30e8 100644
--- a/api/ortc/rtptransportinterface.h
+++ b/api/ortc/rtptransportinterface.h
@@ -13,7 +13,7 @@
 
 #include <string>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/ortc/packettransportinterface.h"
 #include "api/rtcerror.h"
 #include "api/rtp_headers.h"
diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h
index 683a597..cdc3266 100644
--- a/api/peerconnectioninterface.h
+++ b/api/peerconnectioninterface.h
@@ -361,7 +361,7 @@
     // The below fields correspond to constraints from the deprecated
     // constraints interface for constructing a PeerConnection.
     //
-    // rtc::Optional fields can be "missing", in which case the implementation
+    // absl::optional fields can be "missing", in which case the implementation
     // default will be used.
     //////////////////////////////////////////////////////////////////////////
 
@@ -396,15 +396,15 @@
     // Minimum bitrate at which screencast video tracks will be encoded at.
     // This means adding padding bits up to this bitrate, which can help
     // when switching from a static scene to one with motion.
-    rtc::Optional<int> screencast_min_bitrate;
+    absl::optional<int> screencast_min_bitrate;
 
     // Use new combined audio/video bandwidth estimation?
-    rtc::Optional<bool> combined_audio_video_bwe;
+    absl::optional<bool> combined_audio_video_bwe;
 
     // Can be used to disable DTLS-SRTP. This should never be done, but can be
     // useful for testing purposes, for example in setting up a loopback call
     // with a single PeerConnection.
-    rtc::Optional<bool> enable_dtls_srtp;
+    absl::optional<bool> enable_dtls_srtp;
 
     /////////////////////////////////////////////////
     // The below fields are not part of the standard.
@@ -504,29 +504,29 @@
     // 3) ice_check_min_interval defines the minimal interval (equivalently the
     // maximum rate) that overrides the above two intervals when either of them
     // is less.
-    rtc::Optional<int> ice_check_interval_strong_connectivity;
-    rtc::Optional<int> ice_check_interval_weak_connectivity;
-    rtc::Optional<int> ice_check_min_interval;
+    absl::optional<int> ice_check_interval_strong_connectivity;
+    absl::optional<int> ice_check_interval_weak_connectivity;
+    absl::optional<int> 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 in the ICE implementation if set.
-    rtc::Optional<int> ice_unwritable_timeout;
+    absl::optional<int> 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 in the ICE implementation if set.
-    rtc::Optional<int> ice_unwritable_min_checks;
+    absl::optional<int> ice_unwritable_min_checks;
 
     // The interval in milliseconds at which STUN candidates will resend STUN
     // binding requests to keep NAT bindings open.
-    rtc::Optional<int> stun_candidate_keepalive_interval;
+    absl::optional<int> stun_candidate_keepalive_interval;
 
     // ICE Periodic Regathering
     // If set, WebRTC will periodically create and propose candidates without
     // starting a new ICE generation. The regathering happens continuously with
     // interval specified in milliseconds by the uniform distribution [a, b].
-    rtc::Optional<rtc::IntervalRange> ice_regather_interval_range;
+    absl::optional<rtc::IntervalRange> ice_regather_interval_range;
 
     // Optional TurnCustomizer.
     // With this class one can modify outgoing TURN messages.
@@ -538,7 +538,7 @@
     // A candidate pair on a preferred network has a higher precedence in ICE
     // than one on an un-preferred network, regardless of priority or network
     // cost.
-    rtc::Optional<rtc::AdapterType> network_preference;
+    absl::optional<rtc::AdapterType> network_preference;
 
     // Configure the SDP semantics used by this PeerConnection. Note that the
     // WebRTC 1.0 specification requires kUnifiedPlan semantics. The
@@ -979,9 +979,9 @@
 
   // 0 <= min <= current <= max should hold for set parameters.
   struct BitrateParameters {
-    rtc::Optional<int> min_bitrate_bps;
-    rtc::Optional<int> current_bitrate_bps;
-    rtc::Optional<int> max_bitrate_bps;
+    absl::optional<int> min_bitrate_bps;
+    absl::optional<int> current_bitrate_bps;
+    absl::optional<int> max_bitrate_bps;
   };
 
   // SetBitrate limits the bandwidth allocated for all RTP streams sent by
diff --git a/api/rtp_headers.h b/api/rtp_headers.h
index 3318e60..ded6c4b 100644
--- a/api/rtp_headers.h
+++ b/api/rtp_headers.h
@@ -16,8 +16,8 @@
 #include <string>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/array_view.h"
-#include "api/optional.h"
 #include "api/video/video_content_type.h"
 #include "api/video/video_rotation.h"
 #include "api/video/video_timing.h"
@@ -102,7 +102,7 @@
   bool hasVideoRotation;
   VideoRotation videoRotation;
 
-  // TODO(ilnik): Refactor this and one above to be rtc::Optional() and remove
+  // TODO(ilnik): Refactor this and one above to be absl::optional() and remove
   // a corresponding bool flag.
   bool hasVideoContentType;
   VideoContentType videoContentType;
diff --git a/api/rtpparameters.h b/api/rtpparameters.h
index e2405d3..84da811 100644
--- a/api/rtpparameters.h
+++ b/api/rtpparameters.h
@@ -15,8 +15,8 @@
 #include <unordered_map>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/mediatypes.h"
-#include "api/optional.h"
 
 namespace webrtc {
 
@@ -94,7 +94,7 @@
   // 1. It's an enum instead of a string.
   // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
   //    rather than an unset "parameter" value.
-  rtc::Optional<RtcpFeedbackMessageType> message_type;
+  absl::optional<RtcpFeedbackMessageType> message_type;
 
   // Constructors for convenience.
   RtcpFeedback();
@@ -125,23 +125,23 @@
   cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
 
   // Clock rate in Hertz. If unset, the codec is applicable to any clock rate.
-  rtc::Optional<int> clock_rate;
+  absl::optional<int> clock_rate;
 
   // Default payload type for this codec. Mainly needed for codecs that use
   // that have statically assigned payload types.
-  rtc::Optional<int> preferred_payload_type;
+  absl::optional<int> preferred_payload_type;
 
   // Maximum packetization time supported by an RtpReceiver for this codec.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<int> max_ptime;
+  absl::optional<int> max_ptime;
 
   // Preferred packetization time for an RtpReceiver or RtpSender of this
   // codec.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<int> ptime;
+  absl::optional<int> ptime;
 
   // The number of audio channels supported. Unused for video codecs.
-  rtc::Optional<int> num_channels;
+  absl::optional<int> num_channels;
 
   // Feedback mechanisms supported for this codec.
   std::vector<RtcpFeedback> rtcp_feedback;
@@ -204,7 +204,7 @@
   std::string uri;
 
   // Preferred value of ID that goes in the packet.
-  rtc::Optional<int> preferred_id;
+  absl::optional<int> preferred_id;
 
   // If true, it's preferred that the value in the header is encrypted.
   // TODO(deadbeef): Not implemented.
@@ -313,7 +313,7 @@
 struct RtpFecParameters {
   // If unset, a value is chosen by the implementation.
   // Works just like RtpEncodingParameters::ssrc.
-  rtc::Optional<uint32_t> ssrc;
+  absl::optional<uint32_t> ssrc;
 
   FecMechanism mechanism = FecMechanism::RED;
 
@@ -332,7 +332,7 @@
 struct RtpRtxParameters {
   // If unset, a value is chosen by the implementation.
   // Works just like RtpEncodingParameters::ssrc.
-  rtc::Optional<uint32_t> ssrc;
+  absl::optional<uint32_t> ssrc;
 
   // Constructors for convenience.
   RtpRtxParameters();
@@ -353,7 +353,7 @@
   // may change due to an SSRC conflict, in which case the conflict is handled
   // internally without any event. Another way of looking at this is that an
   // unset SSRC acts as a "wildcard" SSRC.
-  rtc::Optional<uint32_t> ssrc;
+  absl::optional<uint32_t> ssrc;
 
   // Can be used to reference a codec in the |codecs| member of the
   // RtpParameters that contains this RtpEncodingParameters. If unset, the
@@ -361,23 +361,23 @@
   // prepare to receive any codec (for a receiver).
   // TODO(deadbeef): Not implemented. Implementation of RtpSender will always
   // choose the first codec from the list.
-  rtc::Optional<int> codec_payload_type;
+  absl::optional<int> codec_payload_type;
 
   // Specifies the FEC mechanism, if set.
   // TODO(deadbeef): Not implemented. Current implementation will use whatever
   // FEC codecs are available, including red+ulpfec.
-  rtc::Optional<RtpFecParameters> fec;
+  absl::optional<RtpFecParameters> fec;
 
   // Specifies the RTX parameters, if set.
   // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
-  rtc::Optional<RtpRtxParameters> rtx;
+  absl::optional<RtpRtxParameters> rtx;
 
   // Only used for audio. If set, determines whether or not discontinuous
   // transmission will be used, if an available codec supports it. If not
   // set, the implementation default setting will be used.
   // TODO(deadbeef): Not implemented. Current implementation will use a CN
   // codec as long as it's present.
-  rtc::Optional<DtxStatus> dtx;
+  absl::optional<DtxStatus> dtx;
 
   // The relative bitrate priority of this encoding. Currently this is
   // implemented for the entire rtp sender by using the value of the first
@@ -394,7 +394,7 @@
   // creates a ptime for a specific codec, which is later changed in the
   // RtpEncodingParameters by the application.
   // TODO(bugs.webrtc.org/8819): Not implemented.
-  rtc::Optional<int> ptime;
+  absl::optional<int> ptime;
 
   // If set, this represents the Transport Independent Application Specific
   // maximum bandwidth defined in RFC3890. If unset, there is no maximum
@@ -407,23 +407,23 @@
   // bandwidth for the entire bandwidth estimator (audio and video). This is
   // just always how "b=AS" was handled, but it's not correct and should be
   // fixed.
-  rtc::Optional<int> max_bitrate_bps;
+  absl::optional<int> max_bitrate_bps;
 
   // Specifies the minimum bitrate in bps for video.
   // TODO(asapersson): Not implemented for ORTC API.
   // TODO(asapersson): Not implemented for single layer.
-  rtc::Optional<int> min_bitrate_bps;
+  absl::optional<int> min_bitrate_bps;
 
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<int> max_framerate;
+  absl::optional<int> max_framerate;
 
   // For video, scale the resolution down by this factor.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<double> scale_resolution_down_by;
+  absl::optional<double> scale_resolution_down_by;
 
   // Scale the framerate down by this factor.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<double> scale_framerate_down_by;
+  absl::optional<double> scale_framerate_down_by;
 
   // For an RtpSender, set to true to cause this encoding to be encoded and
   // sent, and false for it not to be encoded and sent. This allows control
@@ -478,24 +478,24 @@
   int payload_type = 0;
 
   // If unset, the implementation default is used.
-  rtc::Optional<int> clock_rate;
+  absl::optional<int> clock_rate;
 
   // The number of audio channels used. Unset for video codecs. If unset for
   // audio, the implementation default is used.
   // TODO(deadbeef): The "implementation default" part isn't fully implemented.
   // Only defaults to 1, even though some codecs (such as opus) should really
   // default to 2.
-  rtc::Optional<int> num_channels;
+  absl::optional<int> num_channels;
 
   // The maximum packetization time to be used by an RtpSender.
   // If |ptime| is also set, this will be ignored.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<int> max_ptime;
+  absl::optional<int> max_ptime;
 
   // The packetization time to be used by an RtpSender.
   // If unset, will use any time up to max_ptime.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<int> ptime;
+  absl::optional<int> ptime;
 
   // Feedback mechanisms to be used for this codec.
   // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
@@ -551,7 +551,7 @@
   // The SSRC to be used in the "SSRC of packet sender" field. If not set, one
   // will be chosen by the implementation.
   // TODO(deadbeef): Not implemented.
-  rtc::Optional<uint32_t> ssrc;
+  absl::optional<uint32_t> ssrc;
 
   // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages).
   //
diff --git a/api/rtpreceiverinterface.h b/api/rtpreceiverinterface.h
index 30eb667..1801dc1 100644
--- a/api/rtpreceiverinterface.h
+++ b/api/rtpreceiverinterface.h
@@ -57,8 +57,8 @@
   // The source can be either a contributing source or a synchronization source.
   RtpSourceType source_type() const { return source_type_; }
 
-  rtc::Optional<uint8_t> audio_level() const { return audio_level_; }
-  void set_audio_level(const rtc::Optional<uint8_t>& level) {
+  absl::optional<uint8_t> audio_level() const { return audio_level_; }
+  void set_audio_level(const absl::optional<uint8_t>& level) {
     audio_level_ = level;
   }
 
@@ -71,7 +71,7 @@
   int64_t timestamp_ms_;
   uint32_t source_id_;
   RtpSourceType source_type_;
-  rtc::Optional<uint8_t> audio_level_;
+  absl::optional<uint8_t> audio_level_;
 };
 
 class RtpReceiverObserverInterface {
diff --git a/api/rtpsenderinterface.h b/api/rtpsenderinterface.h
index 66267c7..6003aa0 100644
--- a/api/rtpsenderinterface.h
+++ b/api/rtpsenderinterface.h
@@ -38,7 +38,7 @@
 
   // Returns primary SSRC used by this sender for sending media.
   // Returns 0 if not yet determined.
-  // TODO(deadbeef): Change to rtc::Optional.
+  // TODO(deadbeef): Change to absl::optional.
   // TODO(deadbeef): Remove? With GetParameters this should be redundant.
   virtual uint32_t ssrc() const = 0;
 
diff --git a/api/rtptransceiverinterface.h b/api/rtptransceiverinterface.h
index 7d2a1df..8cb3bd5 100644
--- a/api/rtptransceiverinterface.h
+++ b/api/rtptransceiverinterface.h
@@ -14,8 +14,8 @@
 #include <string>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "api/array_view.h"
-#include "api/optional.h"
 #include "api/rtpreceiverinterface.h"
 #include "api/rtpsenderinterface.h"
 #include "rtc_base/refcount.h"
@@ -68,7 +68,7 @@
   // remote descriptions. Before negotiation is complete, the mid value may be
   // null. After rollbacks, the value may change from a non-null value to null.
   // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid
-  virtual rtc::Optional<std::string> mid() const = 0;
+  virtual absl::optional<std::string> mid() const = 0;
 
   // The sender attribute exposes the RtpSender corresponding to the RTP media
   // that may be sent with the transceiver's mid. The sender is always present,
@@ -105,7 +105,7 @@
   // for this transceiver. If this transceiver has never been represented in an
   // offer/answer exchange, or if the transceiver is stopped, the value is null.
   // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection
-  virtual rtc::Optional<RtpTransceiverDirection> current_direction() const = 0;
+  virtual absl::optional<RtpTransceiverDirection> current_direction() const = 0;
 
   // The Stop method irreversibly stops the RtpTransceiver. The sender of this
   // transceiver will no longer send, the receiver will no longer receive.
diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn
index bd5dcac..f473179 100644
--- a/api/transport/BUILD.gn
+++ b/api/transport/BUILD.gn
@@ -15,7 +15,7 @@
     "bitrate_settings.h",
   ]
   deps = [
-    "..:optional",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -27,11 +27,11 @@
   ]
 
   deps = [
-    "..:optional",
     "../units:data_rate",
     "../units:data_size",
     "../units:time_delta",
     "../units:timestamp",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -45,10 +45,10 @@
     ]
     deps = [
       ":network_control",
-      "../:optional",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
       "../../test:test_support",
+      "//third_party/abseil-cpp/absl/types:optional",
     ]
   }
 }
diff --git a/api/transport/bitrate_settings.h b/api/transport/bitrate_settings.h
index 1a24d90..77654bc 100644
--- a/api/transport/bitrate_settings.h
+++ b/api/transport/bitrate_settings.h
@@ -11,7 +11,7 @@
 #ifndef API_TRANSPORT_BITRATE_SETTINGS_H_
 #define API_TRANSPORT_BITRATE_SETTINGS_H_
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace webrtc {
 
@@ -25,9 +25,9 @@
   ~BitrateSettings();
   BitrateSettings(const BitrateSettings&);
   // 0 <= min <= start <= max should hold for set parameters.
-  rtc::Optional<int> min_bitrate_bps;
-  rtc::Optional<int> start_bitrate_bps;
-  rtc::Optional<int> max_bitrate_bps;
+  absl::optional<int> min_bitrate_bps;
+  absl::optional<int> start_bitrate_bps;
+  absl::optional<int> max_bitrate_bps;
 };
 
 }  // namespace webrtc
diff --git a/api/transport/network_types.h b/api/transport/network_types.h
index 155d4ec..a389716 100644
--- a/api/transport/network_types.h
+++ b/api/transport/network_types.h
@@ -13,7 +13,7 @@
 #include <stdint.h>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/units/data_rate.h"
 #include "api/units/data_size.h"
 #include "api/units/time_delta.h"
@@ -32,10 +32,10 @@
   ~StreamsConfig();
   Timestamp at_time = Timestamp::Infinity();
   bool requests_alr_probing = false;
-  rtc::Optional<double> pacing_factor;
-  rtc::Optional<DataRate> min_pacing_rate;
-  rtc::Optional<DataRate> max_padding_rate;
-  rtc::Optional<DataRate> max_total_allocated_bitrate;
+  absl::optional<double> pacing_factor;
+  absl::optional<DataRate> min_pacing_rate;
+  absl::optional<DataRate> max_padding_rate;
+  absl::optional<DataRate> max_total_allocated_bitrate;
 };
 
 struct TargetRateConstraints {
@@ -43,8 +43,8 @@
   TargetRateConstraints(const TargetRateConstraints&);
   ~TargetRateConstraints();
   Timestamp at_time = Timestamp::Infinity();
-  rtc::Optional<DataRate> min_data_rate;
-  rtc::Optional<DataRate> max_data_rate;
+  absl::optional<DataRate> min_data_rate;
+  absl::optional<DataRate> max_data_rate;
 };
 
 // Send side information
@@ -62,7 +62,7 @@
   // The TargetRateConstraints are set here so they can be changed synchronously
   // when network route changes.
   TargetRateConstraints constraints;
-  rtc::Optional<DataRate> starting_rate;
+  absl::optional<DataRate> starting_rate;
 };
 
 struct PacedPacketInfo {
@@ -121,7 +121,7 @@
   PacketResult(const PacketResult&);
   ~PacketResult();
 
-  rtc::Optional<SentPacket> sent_packet;
+  absl::optional<SentPacket> sent_packet;
   Timestamp receive_time = Timestamp::Infinity();
 };
 
@@ -185,10 +185,10 @@
   NetworkControlUpdate();
   NetworkControlUpdate(const NetworkControlUpdate&);
   ~NetworkControlUpdate();
-  rtc::Optional<DataSize> congestion_window;
-  rtc::Optional<PacerConfig> pacer_config;
+  absl::optional<DataSize> congestion_window;
+  absl::optional<PacerConfig> pacer_config;
   std::vector<ProbeClusterConfig> probe_cluster_configs;
-  rtc::Optional<TargetTransferRate> target_rate;
+  absl::optional<TargetTransferRate> target_rate;
 };
 
 // Process control
diff --git a/api/transport/test/network_control_tester.h b/api/transport/test/network_control_tester.h
index 2e9fc02..4dfcc14 100644
--- a/api/transport/test/network_control_tester.h
+++ b/api/transport/test/network_control_tester.h
@@ -15,7 +15,7 @@
 #include <functional>
 #include <memory>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/transport/network_control.h"
 
 namespace webrtc {
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index ec07584..b65fa18 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -26,9 +26,9 @@
   ]
 
   deps = [
-    "..:optional",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base_approved",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -66,11 +66,11 @@
     "video_bitrate_allocation.h",
   ]
   deps = [
-    "..:optional",
     "../..:typedefs",
     "../../rtc_base:checks",
     "../../rtc_base:safe_conversions",
     "../../rtc_base:stringutils",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -83,8 +83,8 @@
   deps = [
     ":encoded_frame",
     ":video_frame",
-    "..:optional",
     "../video_codecs:video_codecs_api",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
diff --git a/api/video/video_bitrate_allocation.cc b/api/video/video_bitrate_allocation.cc
index 059eb8f..d5a1db5 100644
--- a/api/video/video_bitrate_allocation.cc
+++ b/api/video/video_bitrate_allocation.cc
@@ -27,7 +27,7 @@
   RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
   RTC_CHECK_LT(temporal_index, kMaxTemporalStreams);
   int64_t new_bitrate_sum_bps = sum_;
-  rtc::Optional<uint32_t>& layer_bitrate =
+  absl::optional<uint32_t>& layer_bitrate =
       bitrates_[spatial_index][temporal_index];
   if (layer_bitrate) {
     RTC_DCHECK_LE(*layer_bitrate, sum_);
diff --git a/api/video/video_bitrate_allocation.h b/api/video/video_bitrate_allocation.h
index b748b67..ab5bfae 100644
--- a/api/video/video_bitrate_allocation.h
+++ b/api/video/video_bitrate_allocation.h
@@ -15,7 +15,7 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "typedefs.h"  // NOLINT(build/include)
 
 namespace webrtc {
@@ -77,7 +77,7 @@
 
  private:
   uint32_t sum_;
-  rtc::Optional<uint32_t> bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
+  absl::optional<uint32_t> bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
 };
 
 }  // namespace webrtc
diff --git a/api/video/video_source_interface.h b/api/video/video_source_interface.h
index d4e2d3a..4ee4719 100644
--- a/api/video/video_source_interface.h
+++ b/api/video/video_source_interface.h
@@ -13,7 +13,7 @@
 
 #include <limits>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/video/video_sink_interface.h"
 
 namespace rtc {
@@ -38,7 +38,7 @@
   // have improved after an earlier downgrade. The source should select the
   // closest resolution to this pixel count, but if max_pixel_count is set, it
   // still sets the absolute upper bound.
-  rtc::Optional<int> target_pixel_count;
+  absl::optional<int> target_pixel_count;
   // Tells the source the maximum framerate the sink wants.
   int max_framerate_fps = std::numeric_limits<int>::max();
 };
diff --git a/api/video/video_stream_decoder.h b/api/video/video_stream_decoder.h
index 1c4c5ff..dff60d8 100644
--- a/api/video/video_stream_decoder.h
+++ b/api/video/video_stream_decoder.h
@@ -37,8 +37,8 @@
 
     // Called with the decoded frame.
     virtual void OnDecodedFrame(VideoFrame decodedImage,
-                                rtc::Optional<int> decode_time_ms,
-                                rtc::Optional<int> qp) = 0;
+                                absl::optional<int> decode_time_ms,
+                                absl::optional<int> qp) = 0;
   };
 
   virtual ~VideoStreamDecoder() = default;
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index 079df98..fa62518 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -30,13 +30,13 @@
   ]
 
   deps = [
-    "..:optional",
     "../..:webrtc_common",
     "../../common_video",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base_approved",
     "../video:video_bitrate_allocation",
     "../video:video_frame",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
diff --git a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
index 29f005a..d2d0e2b 100644
--- a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
+++ b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
@@ -178,8 +178,8 @@
       return -1;
     }
     void Decoded(webrtc::VideoFrame& decodedImage,
-                 rtc::Optional<int32_t> decode_time_ms,
-                 rtc::Optional<uint8_t> qp) override {
+                 absl::optional<int32_t> decode_time_ms,
+                 absl::optional<uint8_t> qp) override {
       RTC_NOTREACHED();
     }
   } callback;
diff --git a/api/video_codecs/video_decoder.cc b/api/video_codecs/video_decoder.cc
index 4e8db88..b5fff32 100644
--- a/api/video_codecs/video_decoder.cc
+++ b/api/video_codecs/video_decoder.cc
@@ -19,8 +19,8 @@
 }
 
 void DecodedImageCallback::Decoded(VideoFrame& decodedImage,
-                                   rtc::Optional<int32_t> decode_time_ms,
-                                   rtc::Optional<uint8_t> qp) {
+                                   absl::optional<int32_t> decode_time_ms,
+                                   absl::optional<uint8_t> qp) {
   Decoded(decodedImage, decode_time_ms.value_or(-1));
 }
 
diff --git a/api/video_codecs/video_decoder.h b/api/video_codecs/video_decoder.h
index 190d794..7995fcc 100644
--- a/api/video_codecs/video_decoder.h
+++ b/api/video_codecs/video_decoder.h
@@ -39,8 +39,8 @@
   // TODO(sakal): Remove other implementations when upstream projects have been
   // updated.
   virtual void Decoded(VideoFrame& decodedImage,
-                       rtc::Optional<int32_t> decode_time_ms,
-                       rtc::Optional<uint8_t> qp);
+                       absl::optional<int32_t> decode_time_ms,
+                       absl::optional<uint8_t> qp);
 
   virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
 
diff --git a/api/video_codecs/video_encoder.h b/api/video_codecs/video_encoder.h
index b2f9a39..68d9b44 100644
--- a/api/video_codecs/video_encoder.h
+++ b/api/video_codecs/video_encoder.h
@@ -15,7 +15,7 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/video/video_bitrate_allocation.h"
 #include "api/video/video_frame.h"
 #include "api/video_codecs/video_codec.h"
@@ -90,7 +90,7 @@
 
    public:
     // TODO(nisse): Would be nicer if kOff were a constant ScalingSettings
-    // rather than a magic value. However, rtc::Optional is not trivially copy
+    // rather than a magic value. However, absl::optional is not trivially copy
     // constructible, and hence a constant ScalingSettings needs a static
     // initializer, which is strongly discouraged in Chrome. We can hopefully
     // fix this when we switch to absl::optional or std::optional.
@@ -102,7 +102,7 @@
     ScalingSettings(KOff);  // NOLINT(runtime/explicit)
     ~ScalingSettings();
 
-    const rtc::Optional<QpThresholds> thresholds;
+    const absl::optional<QpThresholds> thresholds;
 
     // We will never ask for a resolution lower than this.
     // TODO(kthelgason): Lower this limit when better testing
diff --git a/api/video_codecs/video_encoder_config.h b/api/video_codecs/video_encoder_config.h
index 636c0e7..47ff925 100644
--- a/api/video_codecs/video_encoder_config.h
+++ b/api/video_codecs/video_encoder_config.h
@@ -14,9 +14,9 @@
 #include <string>
 #include <vector>
 
-#include "api/optional.h"
-#include "api/video_codecs/video_codec.h"
+#include "absl/types/optional.h"
 #include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_codec.h"
 #include "rtc_base/refcount.h"
 #include "rtc_base/scoped_ref_ptr.h"
 
@@ -37,9 +37,9 @@
   int max_bitrate_bps;
   int max_qp;
 
-  rtc::Optional<size_t> num_temporal_layers;
+  absl::optional<size_t> num_temporal_layers;
 
-  rtc::Optional<double> bitrate_priority;
+  absl::optional<double> bitrate_priority;
 
   // TODO(bugs.webrtc.org/8653): Support active per-simulcast layer.
   bool active;
@@ -50,7 +50,7 @@
   // These are reference counted to permit copying VideoEncoderConfig and be
   // kept alive until all encoder_specific_settings go out of scope.
   // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig
-  // and use rtc::Optional for encoder_specific_settings instead.
+  // and use absl::optional for encoder_specific_settings instead.
   class EncoderSpecificSettings : public rtc::RefCountInterface {
    public:
     // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is
diff --git a/api/videosourceproxy.h b/api/videosourceproxy.h
index 0bb6d48..dbd9045 100644
--- a/api/videosourceproxy.h
+++ b/api/videosourceproxy.h
@@ -25,7 +25,7 @@
 PROXY_CONSTMETHOD0(SourceState, state)
 PROXY_CONSTMETHOD0(bool, remote)
 PROXY_CONSTMETHOD0(bool, is_screencast)
-PROXY_CONSTMETHOD0(rtc::Optional<bool>, needs_denoising)
+PROXY_CONSTMETHOD0(absl::optional<bool>, needs_denoising)
 PROXY_METHOD1(bool, GetStats, Stats*)
 PROXY_WORKER_METHOD2(void,
                      AddOrUpdateSink,