Move optional.h to webrtc/api/
We use Optional in our public API, so its header should be in
webrtc/api/.
BUG=webrtc:8205
Review-Url: https://codereview.webrtc.org/3011943002
Cr-Original-Commit-Position: refs/heads/master@{#19693}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 84f6a3fc6b7759e98889a38ab74980efbf418ce7
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 2e3d77a..86a63e4 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -207,6 +207,17 @@
]
}
+rtc_source_set("optional") {
+ sources = [
+ "optional.cc",
+ "optional.h",
+ ]
+ deps = [
+ ":array_view",
+ "../rtc_base:rtc_base_approved",
+ ]
+}
+
rtc_source_set("libjingle_peerconnection_test_api") {
testonly = true
sources = [
@@ -266,6 +277,7 @@
}
sources = [
"array_view_unittest.cc",
+ "optional_unittest.cc",
"ortc/mediadescription_unittest.cc",
"ortc/sessiondescription_unittest.cc",
"rtcerror_unittest.cc",
@@ -280,6 +292,7 @@
deps = [
":array_view",
":libjingle_peerconnection_api",
+ ":optional",
":ortc_api",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_utils",
diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn
index 29238e6..04a5238 100644
--- a/api/audio_codecs/BUILD.gn
+++ b/api/audio_codecs/BUILD.gn
@@ -27,6 +27,7 @@
]
deps = [
"..:array_view",
+ "..:optional",
"../..:webrtc_common",
"../../rtc_base:rtc_base_approved",
]
diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn
index db61713..8f06a8f 100644
--- a/api/audio_codecs/L16/BUILD.gn
+++ b/api/audio_codecs/L16/BUILD.gn
@@ -19,6 +19,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:pcm16b",
"../../../rtc_base:rtc_base_approved",
@@ -32,6 +33,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:pcm16b",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/L16/audio_decoder_L16.h b/api/audio_codecs/L16/audio_decoder_L16.h
index 478da16..39b389a 100644
--- a/api/audio_codecs/L16/audio_decoder_L16.h
+++ b/api/audio_codecs/L16/audio_decoder_L16.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/L16/audio_encoder_L16.h b/api/audio_codecs/L16/audio_encoder_L16.h
index e2e4019..3ac0423 100644
--- a/api/audio_codecs/L16/audio_encoder_L16.h
+++ b/api/audio_codecs/L16/audio_encoder_L16.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/audio_decoder.h b/api/audio_codecs/audio_decoder.h
index 0d15e6d..2d850fd 100644
--- a/api/audio_codecs/audio_decoder.h
+++ b/api/audio_codecs/audio_decoder.h
@@ -15,9 +15,9 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/buffer.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/api/audio_codecs/audio_encoder.h b/api/audio_codecs/audio_encoder.h
index 37a03d0..7406d7d 100644
--- a/api/audio_codecs/audio_encoder.h
+++ b/api/audio_codecs/audio_encoder.h
@@ -17,9 +17,9 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/buffer.h"
#include "webrtc/rtc_base/deprecation.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/api/audio_codecs/audio_format.h b/api/audio_codecs/audio_format.h
index c442972..ab825bb 100644
--- a/api/audio_codecs/audio_format.h
+++ b/api/audio_codecs/audio_format.h
@@ -16,7 +16,7 @@
#include <string>
#include <utility>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn
index fbf9248..aa86490 100644
--- a/api/audio_codecs/g711/BUILD.gn
+++ b/api/audio_codecs/g711/BUILD.gn
@@ -19,6 +19,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:g711",
"../../../rtc_base:rtc_base_approved",
@@ -32,6 +33,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:g711",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/g711/audio_decoder_g711.h b/api/audio_codecs/g711/audio_decoder_g711.h
index b9650c9..2824c32 100644
--- a/api/audio_codecs/g711/audio_decoder_g711.h
+++ b/api/audio_codecs/g711/audio_decoder_g711.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/g711/audio_encoder_g711.h b/api/audio_codecs/g711/audio_encoder_g711.h
index a22650d..5750100 100644
--- a/api/audio_codecs/g711/audio_encoder_g711.h
+++ b/api/audio_codecs/g711/audio_encoder_g711.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn
index f3108e7..5af7e5c 100644
--- a/api/audio_codecs/g722/BUILD.gn
+++ b/api/audio_codecs/g722/BUILD.gn
@@ -26,6 +26,7 @@
deps = [
":audio_encoder_g722_config",
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:g722",
"../../../rtc_base:rtc_base_approved",
@@ -39,6 +40,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:g722",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/g722/audio_decoder_g722.h b/api/audio_codecs/g722/audio_decoder_g722.h
index 9b063c2..cf0dfa9 100644
--- a/api/audio_codecs/g722/audio_decoder_g722.h
+++ b/api/audio_codecs/g722/audio_decoder_g722.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/g722/audio_encoder_g722.h b/api/audio_codecs/g722/audio_encoder_g722.h
index 458a6c5..37cb968 100644
--- a/api/audio_codecs/g722/audio_encoder_g722.h
+++ b/api/audio_codecs/g722/audio_encoder_g722.h
@@ -17,7 +17,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
#include "webrtc/api/audio_codecs/g722/audio_encoder_g722_config.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn
index ab9681a..0f5f80d 100644
--- a/api/audio_codecs/ilbc/BUILD.gn
+++ b/api/audio_codecs/ilbc/BUILD.gn
@@ -26,6 +26,7 @@
deps = [
":audio_encoder_ilbc_config",
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:ilbc",
"../../../rtc_base:rtc_base_approved",
@@ -39,6 +40,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:ilbc",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/api/audio_codecs/ilbc/audio_decoder_ilbc.h
index 65a67e2..343308d 100644
--- a/api/audio_codecs/ilbc/audio_decoder_ilbc.h
+++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/api/audio_codecs/ilbc/audio_encoder_ilbc.h
index 6f7a9f6..a30d109 100644
--- a/api/audio_codecs/ilbc/audio_encoder_ilbc.h
+++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.h
@@ -17,7 +17,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
#include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/isac/BUILD.gn b/api/audio_codecs/isac/BUILD.gn
index 3340e28..b22eb95 100644
--- a/api/audio_codecs/isac/BUILD.gn
+++ b/api/audio_codecs/isac/BUILD.gn
@@ -19,6 +19,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:isac_fix",
"../../../rtc_base:rtc_base_approved",
@@ -32,6 +33,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:isac_fix",
"../../../rtc_base:rtc_base_approved",
@@ -45,6 +47,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:isac",
"../../../rtc_base:rtc_base_approved",
@@ -58,6 +61,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:isac",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.h b/api/audio_codecs/isac/audio_decoder_isac_fix.h
index 71e7cc4..7662002 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_fix.h
+++ b/api/audio_codecs/isac/audio_decoder_isac_fix.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.h b/api/audio_codecs/isac/audio_decoder_isac_float.h
index c0dc880..f0232e9 100644
--- a/api/audio_codecs/isac/audio_decoder_isac_float.h
+++ b/api/audio_codecs/isac/audio_decoder_isac_float.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.h b/api/audio_codecs/isac/audio_encoder_isac_fix.h
index 5f0e8fe..ce4a1d0 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_fix.h
+++ b/api/audio_codecs/isac/audio_encoder_isac_fix.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.h b/api/audio_codecs/isac/audio_encoder_isac_float.h
index 35bc94b..244e59b 100644
--- a/api/audio_codecs/isac/audio_encoder_isac_float.h
+++ b/api/audio_codecs/isac/audio_encoder_isac_float.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn
index 658d151..faa5956 100644
--- a/api/audio_codecs/opus/BUILD.gn
+++ b/api/audio_codecs/opus/BUILD.gn
@@ -18,6 +18,7 @@
"audio_encoder_opus_config.h",
]
deps = [
+ "../..:optional",
"../../../rtc_base:rtc_base_approved",
]
defines = []
@@ -51,6 +52,7 @@
]
deps = [
"..:audio_codecs_api",
+ "../..:optional",
"../../..:webrtc_common",
"../../../modules/audio_coding:webrtc_opus",
"../../../rtc_base:rtc_base_approved",
diff --git a/api/audio_codecs/opus/audio_decoder_opus.h b/api/audio_codecs/opus/audio_decoder_opus.h
index 6a9d6da..272503d 100644
--- a/api/audio_codecs/opus/audio_decoder_opus.h
+++ b/api/audio_codecs/opus/audio_decoder_opus.h
@@ -16,7 +16,7 @@
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
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 c3fe17b..d07f784 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 "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/mediaconstraintsinterface.h b/api/mediaconstraintsinterface.h
index 72fdd97..eb89b3e 100644
--- a/api/mediaconstraintsinterface.h
+++ b/api/mediaconstraintsinterface.h
@@ -23,8 +23,8 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/peerconnectioninterface.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/api/mediastreaminterface.h b/api/mediastreaminterface.h
index aaf5b62..5d65447 100644
--- a/api/mediastreaminterface.h
+++ b/api/mediastreaminterface.h
@@ -22,8 +22,8 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_frame.h"
-#include "webrtc/rtc_base/optional.h"
// TODO(zhihuang): Remove unrelated headers once downstream applications stop
// relying on them; they were previously transitively included by
// mediachannel.h, which is no longer a dependency of this file.
diff --git a/rtc_base/optional.cc b/api/optional.cc
similarity index 84%
rename from rtc_base/optional.cc
rename to api/optional.cc
index 4b41a2d..ec86966 100644
--- a/rtc_base/optional.cc
+++ b/api/optional.cc
@@ -8,14 +8,16 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace rtc {
namespace optional_internal {
#if RTC_HAS_ASAN
-void* FunctionThatDoesNothingImpl(void* x) { return x; }
+void* FunctionThatDoesNothingImpl(void* x) {
+ return x;
+}
#endif
diff --git a/api/optional.h b/api/optional.h
new file mode 100644
index 0000000..de1ec76
--- /dev/null
+++ b/api/optional.h
@@ -0,0 +1,407 @@
+/*
+ * Copyright 2015 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_OPTIONAL_H_
+#define WEBRTC_API_OPTIONAL_H_
+
+#include <algorithm>
+#include <memory>
+#include <utility>
+
+#ifdef UNIT_TEST
+#include <iomanip>
+#include <ostream>
+#endif // UNIT_TEST
+
+#include "webrtc/api/array_view.h"
+#include "webrtc/rtc_base/checks.h"
+#include "webrtc/rtc_base/sanitizer.h"
+
+namespace rtc {
+
+namespace optional_internal {
+
+#if RTC_HAS_ASAN
+
+// This is a non-inlined function. The optimizer can't see inside it. It
+// prevents the compiler from generating optimized code that reads value_ even
+// if it is unset. Although safe, this causes memory sanitizers to complain.
+void* FunctionThatDoesNothingImpl(void*);
+
+template <typename T>
+inline T* FunctionThatDoesNothing(T* x) {
+ return reinterpret_cast<T*>(
+ FunctionThatDoesNothingImpl(reinterpret_cast<void*>(x)));
+}
+
+#else
+
+template <typename T>
+inline T* FunctionThatDoesNothing(T* x) {
+ return x;
+}
+
+#endif
+
+} // namespace optional_internal
+
+// Simple std::optional-wannabe. It either contains a T or not.
+//
+// A moved-from Optional<T> may only be destroyed, and assigned to if T allows
+// being assigned to after having been moved from. Specifically, you may not
+// assume that it just doesn't contain a value anymore.
+//
+// Examples of good places to use Optional:
+//
+// - As a class or struct member, when the member doesn't always have a value:
+// struct Prisoner {
+// std::string name;
+// Optional<int> cell_number; // Empty if not currently incarcerated.
+// };
+//
+// - As a return value for functions that may fail to return a value on all
+// allowed inputs. For example, a function that searches an array might
+// return an Optional<size_t> (the index where it found the element, or
+// nothing if it didn't find it); and a function that parses numbers might
+// return Optional<double> (the parsed number, or nothing if parsing failed).
+//
+// Examples of bad places to use Optional:
+//
+// - As a return value for functions that may fail because of disallowed
+// inputs. For example, a string length function should not return
+// Optional<size_t> so that it can return nothing in case the caller passed
+// it a null pointer; the function should probably use RTC_[D]CHECK instead,
+// and return plain size_t.
+//
+// - As a return value for functions that may fail to return a value on all
+// allowed inputs, but need to tell the caller what went wrong. Returning
+// Optional<double> when parsing a single number as in the example above
+// might make sense, but any larger parse job is probably going to need to
+// tell the caller what the problem was, not just that there was one.
+//
+// - As a non-mutable function argument. When you want to pass a value of a
+// type T that can fail to be there, const T* is almost always both fastest
+// and cleanest. (If you're *sure* that the the caller will always already
+// have an Optional<T>, const Optional<T>& is slightly faster than const T*,
+// but this is a micro-optimization. In general, stick to const T*.)
+//
+// TODO(kwiberg): Get rid of this class when the standard library has
+// std::optional (and we're allowed to use it).
+template <typename T>
+class Optional final {
+ public:
+ // Construct an empty Optional.
+ Optional() : has_value_(false), empty_('\0') { PoisonValue(); }
+
+ // Construct an Optional that contains a value.
+ explicit Optional(const T& value) : has_value_(true) {
+ new (&value_) T(value);
+ }
+ explicit Optional(T&& value) : has_value_(true) {
+ new (&value_) T(std::move(value));
+ }
+
+ // Copy constructor: copies the value from m if it has one.
+ Optional(const Optional& m) : has_value_(m.has_value_) {
+ if (has_value_)
+ new (&value_) T(m.value_);
+ else
+ PoisonValue();
+ }
+
+ // Move constructor: if m has a value, moves the value from m, leaving m
+ // still in a state where it has a value, but a moved-from one (the
+ // properties of which depends on T; the only general guarantee is that we
+ // can destroy m).
+ Optional(Optional&& m) : has_value_(m.has_value_) {
+ if (has_value_)
+ new (&value_) T(std::move(m.value_));
+ else
+ PoisonValue();
+ }
+
+ ~Optional() {
+ if (has_value_)
+ value_.~T();
+ else
+ UnpoisonValue();
+ }
+
+ // Copy assignment. Uses T's copy assignment if both sides have a value, T's
+ // copy constructor if only the right-hand side has a value.
+ Optional& operator=(const Optional& m) {
+ if (m.has_value_) {
+ if (has_value_) {
+ value_ = m.value_; // T's copy assignment.
+ } else {
+ UnpoisonValue();
+ new (&value_) T(m.value_); // T's copy constructor.
+ has_value_ = true;
+ }
+ } else {
+ reset();
+ }
+ return *this;
+ }
+
+ // Move assignment. Uses T's move assignment if both sides have a value, T's
+ // move constructor if only the right-hand side has a value. The state of m
+ // after it's been moved from is as for the move constructor.
+ Optional& operator=(Optional&& m) {
+ if (m.has_value_) {
+ if (has_value_) {
+ value_ = std::move(m.value_); // T's move assignment.
+ } else {
+ UnpoisonValue();
+ new (&value_) T(std::move(m.value_)); // T's move constructor.
+ has_value_ = true;
+ }
+ } else {
+ reset();
+ }
+ return *this;
+ }
+
+ // Swap the values if both m1 and m2 have values; move the value if only one
+ // of them has one.
+ friend void swap(Optional& m1, Optional& m2) {
+ if (m1.has_value_) {
+ if (m2.has_value_) {
+ // Both have values: swap.
+ using std::swap;
+ swap(m1.value_, m2.value_);
+ } else {
+ // Only m1 has a value: move it to m2.
+ m2.UnpoisonValue();
+ new (&m2.value_) T(std::move(m1.value_));
+ m1.value_.~T(); // Destroy the moved-from value.
+ m1.has_value_ = false;
+ m2.has_value_ = true;
+ m1.PoisonValue();
+ }
+ } else if (m2.has_value_) {
+ // Only m2 has a value: move it to m1.
+ m1.UnpoisonValue();
+ new (&m1.value_) T(std::move(m2.value_));
+ m2.value_.~T(); // Destroy the moved-from value.
+ m1.has_value_ = true;
+ m2.has_value_ = false;
+ m2.PoisonValue();
+ }
+ }
+
+ // Destroy any contained value. Has no effect if we have no value.
+ void reset() {
+ if (!has_value_)
+ return;
+ value_.~T();
+ has_value_ = false;
+ PoisonValue();
+ }
+
+ template <class... Args>
+ void emplace(Args&&... args) {
+ if (has_value_)
+ value_.~T();
+ else
+ UnpoisonValue();
+ new (&value_) T(std::forward<Args>(args)...);
+ has_value_ = true;
+ }
+
+ // Conversion to bool to test if we have a value.
+ explicit operator bool() const { return has_value_; }
+ bool has_value() const { return has_value_; }
+
+ // Dereferencing. Only allowed if we have a value.
+ const T* operator->() const {
+ RTC_DCHECK(has_value_);
+ return &value_;
+ }
+ T* operator->() {
+ RTC_DCHECK(has_value_);
+ return &value_;
+ }
+ const T& operator*() const {
+ RTC_DCHECK(has_value_);
+ return value_;
+ }
+ T& operator*() {
+ RTC_DCHECK(has_value_);
+ return value_;
+ }
+ const T& value() const {
+ RTC_DCHECK(has_value_);
+ return value_;
+ }
+ T& value() {
+ RTC_DCHECK(has_value_);
+ return value_;
+ }
+
+ // Dereference with a default value in case we don't have a value.
+ const T& value_or(const T& default_val) const {
+ // The no-op call prevents the compiler from generating optimized code that
+ // reads value_ even if !has_value_, but only if FunctionThatDoesNothing is
+ // not completely inlined; see its declaration.).
+ return has_value_ ? *optional_internal::FunctionThatDoesNothing(&value_)
+ : default_val;
+ }
+
+ // Dereference and move value.
+ T MoveValue() {
+ RTC_DCHECK(has_value_);
+ return std::move(value_);
+ }
+
+ // Equality tests. Two Optionals are equal if they contain equivalent values,
+ // or if they're both empty.
+ friend bool operator==(const Optional& m1, const Optional& m2) {
+ return m1.has_value_ && m2.has_value_ ? m1.value_ == m2.value_
+ : m1.has_value_ == m2.has_value_;
+ }
+ friend bool operator==(const Optional& opt, const T& value) {
+ return opt.has_value_ && opt.value_ == value;
+ }
+ friend bool operator==(const T& value, const Optional& opt) {
+ return opt.has_value_ && value == opt.value_;
+ }
+
+ friend bool operator!=(const Optional& m1, const Optional& m2) {
+ return m1.has_value_ && m2.has_value_ ? m1.value_ != m2.value_
+ : m1.has_value_ != m2.has_value_;
+ }
+ friend bool operator!=(const Optional& opt, const T& value) {
+ return !opt.has_value_ || opt.value_ != value;
+ }
+ friend bool operator!=(const T& value, const Optional& opt) {
+ return !opt.has_value_ || value != opt.value_;
+ }
+
+ private:
+ // Tell sanitizers that value_ shouldn't be touched.
+ void PoisonValue() {
+ rtc::AsanPoison(rtc::MakeArrayView(&value_, 1));
+ rtc::MsanMarkUninitialized(rtc::MakeArrayView(&value_, 1));
+ }
+
+ // Tell sanitizers that value_ is OK to touch again.
+ void UnpoisonValue() { rtc::AsanUnpoison(rtc::MakeArrayView(&value_, 1)); }
+
+ bool has_value_; // True iff value_ contains a live value.
+ union {
+ // empty_ exists only to make it possible to initialize the union, even when
+ // it doesn't contain any data. If the union goes uninitialized, it may
+ // trigger compiler warnings.
+ char empty_;
+ // By placing value_ in a union, we get to manage its construction and
+ // destruction manually: the Optional constructors won't automatically
+ // construct it, and the Optional destructor won't automatically destroy
+ // it. Basically, this just allocates a properly sized and aligned block of
+ // memory in which we can manually put a T with placement new.
+ T value_;
+ };
+};
+
+#ifdef UNIT_TEST
+namespace optional_internal {
+
+// Checks if there's a valid PrintTo(const T&, std::ostream*) call for T.
+template <typename T>
+struct HasPrintTo {
+ private:
+ struct No {};
+
+ template <typename T2>
+ static auto Test(const T2& obj)
+ -> decltype(PrintTo(obj, std::declval<std::ostream*>()));
+
+ template <typename>
+ static No Test(...);
+
+ public:
+ static constexpr bool value =
+ !std::is_same<decltype(Test<T>(std::declval<const T&>())), No>::value;
+};
+
+// Checks if there's a valid operator<<(std::ostream&, const T&) call for T.
+template <typename T>
+struct HasOstreamOperator {
+ private:
+ struct No {};
+
+ template <typename T2>
+ static auto Test(const T2& obj)
+ -> decltype(std::declval<std::ostream&>() << obj);
+
+ template <typename>
+ static No Test(...);
+
+ public:
+ static constexpr bool value =
+ !std::is_same<decltype(Test<T>(std::declval<const T&>())), No>::value;
+};
+
+// Prefer using PrintTo to print the object.
+template <typename T>
+typename std::enable_if<HasPrintTo<T>::value, void>::type OptionalPrintToHelper(
+ const T& value,
+ std::ostream* os) {
+ PrintTo(value, os);
+}
+
+// Fall back to operator<<(std::ostream&, ...) if it exists.
+template <typename T>
+typename std::enable_if<HasOstreamOperator<T>::value && !HasPrintTo<T>::value,
+ void>::type
+OptionalPrintToHelper(const T& value, std::ostream* os) {
+ *os << value;
+}
+
+inline void OptionalPrintObjectBytes(const unsigned char* bytes,
+ size_t size,
+ std::ostream* os) {
+ *os << "<optional with " << size << "-byte object [";
+ for (size_t i = 0; i != size; ++i) {
+ *os << (i == 0 ? "" : ((i & 1) ? "-" : " "));
+ *os << std::hex << std::setw(2) << std::setfill('0')
+ << static_cast<int>(bytes[i]);
+ }
+ *os << "]>";
+}
+
+// As a final back-up, just print the contents of the objcets byte-wise.
+template <typename T>
+typename std::enable_if<!HasOstreamOperator<T>::value && !HasPrintTo<T>::value,
+ void>::type
+OptionalPrintToHelper(const T& value, std::ostream* os) {
+ OptionalPrintObjectBytes(reinterpret_cast<const unsigned char*>(&value),
+ sizeof(value), os);
+}
+
+} // namespace optional_internal
+
+// PrintTo is used by gtest to print out the results of tests. We want to ensure
+// the object contained in an Optional can be printed out if it's set, while
+// avoiding touching the object's storage if it is undefined.
+template <typename T>
+void PrintTo(const rtc::Optional<T>& opt, std::ostream* os) {
+ if (opt) {
+ optional_internal::OptionalPrintToHelper(*opt, os);
+ } else {
+ *os << "<empty optional>";
+ }
+}
+
+#endif // UNIT_TEST
+
+} // namespace rtc
+
+#endif // WEBRTC_API_OPTIONAL_H_
diff --git a/rtc_base/optional_unittest.cc b/api/optional_unittest.cc
similarity index 98%
rename from rtc_base/optional_unittest.cc
rename to api/optional_unittest.cc
index 8f2f7fd..f8f9cf3 100644
--- a/rtc_base/optional_unittest.cc
+++ b/api/optional_unittest.cc
@@ -14,8 +14,8 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/gunit.h"
-#include "webrtc/rtc_base/optional.h"
namespace rtc {
@@ -37,14 +37,12 @@
*os << "The value is " << mpt.value;
}
-std::ostream& operator<<(std::ostream& os,
- const MyPrintableType& mpt) {
+std::ostream& operator<<(std::ostream& os, const MyPrintableType& mpt) {
os << mpt.value;
return os;
}
-std::ostream& operator<<(std::ostream& os,
- const MyOstreamPrintableType& mpt) {
+std::ostream& operator<<(std::ostream& os, const MyOstreamPrintableType& mpt) {
os << mpt.value;
return os;
}
diff --git a/api/ortc/mediadescription.h b/api/ortc/mediadescription.h
index efee662..d638dfc 100644
--- a/api/ortc/mediadescription.h
+++ b/api/ortc/mediadescription.h
@@ -15,8 +15,8 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/cryptoparams.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/api/ortc/rtptransportinterface.h b/api/ortc/rtptransportinterface.h
index 165daad..1fdc12c 100644
--- a/api/ortc/rtptransportinterface.h
+++ b/api/ortc/rtptransportinterface.h
@@ -13,10 +13,10 @@
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/api/ortc/packettransportinterface.h"
#include "webrtc/api/rtcerror.h"
#include "webrtc/common_types.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/api/rtpparameters.h b/api/rtpparameters.h
index 46f7139..ce61b15 100644
--- a/api/rtpparameters.h
+++ b/api/rtpparameters.h
@@ -16,7 +16,7 @@
#include <vector>
#include "webrtc/api/mediatypes.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index 7fad43d..be7194e 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -20,6 +20,7 @@
]
deps = [
+ "..:optional",
"..:video_frame_api",
"../..:webrtc_common",
"../../common_video",
diff --git a/api/video_codecs/video_encoder.h b/api/video_codecs/video_encoder.h
index 7a319d7..4ec6e45 100644
--- a/api/video_codecs/video_encoder.h
+++ b/api/video_codecs/video_encoder.h
@@ -15,11 +15,11 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_frame.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/include/video_frame.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 2c62584..42b74ff 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -37,6 +37,7 @@
"..:webrtc_common",
"../api:audio_mixer_api",
"../api:call_api",
+ "../api:optional",
"../api/audio_codecs:audio_codecs_api",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../call:call_interfaces",
diff --git a/audio/time_interval.h b/audio/time_interval.h
index 069127d..4481843 100644
--- a/audio/time_interval.h
+++ b/audio/time_interval.h
@@ -13,7 +13,7 @@
#include <stdint.h>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 580d606..706d502 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -26,6 +26,7 @@
"..:webrtc_common",
"../api:audio_mixer_api",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:transport_api",
"../api/audio_codecs:audio_codecs_api",
"../rtc_base:rtc_base",
@@ -68,6 +69,7 @@
":rtp_interfaces",
"..:webrtc_common",
"../api:array_view",
+ "../api:optional",
"../modules/rtp_rtcp",
"../rtc_base:rtc_base_approved",
]
@@ -114,6 +116,7 @@
":rtp_sender",
":video_stream_api",
"..:webrtc_common",
+ "../api:optional",
"../api:transport_api",
"../audio",
"../logging:rtc_event_log_api",
@@ -144,6 +147,7 @@
":rtp_interfaces",
"../:webrtc_common",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:transport_api",
"../common_video:common_video",
"../rtc_base:rtc_base_approved",
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index 018ad35..6de62df 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -18,11 +18,11 @@
#include "webrtc/api/audio_codecs/audio_decoder_factory.h"
#include "webrtc/api/call/transport.h"
+#include "webrtc/api/optional.h"
#include "webrtc/api/rtpparameters.h"
#include "webrtc/api/rtpreceiverinterface.h"
#include "webrtc/call/rtp_config.h"
#include "webrtc/common_types.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/typedefs.h"
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index 8720249..4f7f8c0 100644
--- a/call/audio_send_stream.h
+++ b/call/audio_send_stream.h
@@ -18,9 +18,9 @@
#include "webrtc/api/audio_codecs/audio_encoder_factory.h"
#include "webrtc/api/audio_codecs/audio_format.h"
#include "webrtc/api/call/transport.h"
+#include "webrtc/api/optional.h"
#include "webrtc/api/rtpparameters.h"
#include "webrtc/call/rtp_config.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/typedefs.h"
diff --git a/call/call.cc b/call/call.cc
index edb9bf3..343b3ef 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -16,6 +16,7 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/audio/audio_receive_stream.h"
#include "webrtc/audio/audio_send_stream.h"
#include "webrtc/audio/audio_state.h"
@@ -40,7 +41,6 @@
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/location.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/ptr_util.h"
#include "webrtc/rtc_base/sequenced_task_checker.h"
#include "webrtc/rtc_base/task_queue.h"
diff --git a/call/rtp_rtcp_demuxer_helper.h b/call/rtp_rtcp_demuxer_helper.h
index 02d08aa..0a4767d 100644
--- a/call/rtp_rtcp_demuxer_helper.h
+++ b/call/rtp_rtcp_demuxer_helper.h
@@ -16,8 +16,8 @@
#include <utility>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/basictypes.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/call/syncable.h b/call/syncable.h
index 734d20e..2692a8a 100644
--- a/call/syncable.h
+++ b/call/syncable.h
@@ -16,7 +16,7 @@
#include <stdint.h>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/call/video_config.h b/call/video_config.h
index cdff513..4a98d01 100644
--- a/call/video_config.h
+++ b/call/video_config.h
@@ -14,9 +14,9 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/rtc_base/basictypes.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/refcount.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/typedefs.h"
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index a51a83c..8cfd642 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -63,6 +63,7 @@
deps = [
":sinc_resampler",
"..:webrtc_common",
+ "../api:optional",
"../rtc_base:gtest_prod",
"../rtc_base:rtc_base_approved",
"../system_wrappers",
diff --git a/common_audio/smoothing_filter.h b/common_audio/smoothing_filter.h
index c59842e..15ea3d1 100644
--- a/common_audio/smoothing_filter.h
+++ b/common_audio/smoothing_filter.h
@@ -11,8 +11,8 @@
#ifndef WEBRTC_COMMON_AUDIO_SMOOTHING_FILTER_H_
#define WEBRTC_COMMON_AUDIO_SMOOTHING_FILTER_H_
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/system_wrappers/include/clock.h"
namespace webrtc {
diff --git a/common_types.h b/common_types.h
index 229d858..49b42ac 100644
--- a/common_types.h
+++ b/common_types.h
@@ -18,12 +18,12 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_content_type.h"
#include "webrtc/api/video/video_rotation.h"
#include "webrtc/api/video/video_timing.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/deprecation.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
#if defined(_MSC_VER)
diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn
index 93906ef..f0e262f 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -57,6 +57,7 @@
deps = [
"..:webrtc_common",
+ "../api:optional",
"../media:rtc_h264_profile_id",
"../modules:module_api",
"../rtc_base:rtc_base",
diff --git a/common_video/h264/h264_bitstream_parser.h b/common_video/h264/h264_bitstream_parser.h
index 136c903..145700f 100644
--- a/common_video/h264/h264_bitstream_parser.h
+++ b/common_video/h264/h264_bitstream_parser.h
@@ -13,9 +13,9 @@
#include <stddef.h>
#include <stdint.h>
+#include "webrtc/api/optional.h"
#include "webrtc/common_video/h264/pps_parser.h"
#include "webrtc/common_video/h264/sps_parser.h"
-#include "webrtc/rtc_base/optional.h"
namespace rtc {
class BitBufferWriter;
diff --git a/common_video/h264/pps_parser.h b/common_video/h264/pps_parser.h
index 941b99e..b981d22 100644
--- a/common_video/h264/pps_parser.h
+++ b/common_video/h264/pps_parser.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_COMMON_VIDEO_H264_PPS_PARSER_H_
#define WEBRTC_COMMON_VIDEO_H264_PPS_PARSER_H_
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace rtc {
class BitBuffer;
diff --git a/common_video/h264/sps_parser.h b/common_video/h264/sps_parser.h
index ea14f79..77ad25d 100644
--- a/common_video/h264/sps_parser.h
+++ b/common_video/h264/sps_parser.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_COMMON_VIDEO_H264_SPS_PARSER_H_
#define WEBRTC_COMMON_VIDEO_H264_SPS_PARSER_H_
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace rtc {
class BitBuffer;
diff --git a/common_video/h264/sps_vui_rewriter.h b/common_video/h264/sps_vui_rewriter.h
index 6eff1ab..7875117 100644
--- a/common_video/h264/sps_vui_rewriter.h
+++ b/common_video/h264/sps_vui_rewriter.h
@@ -12,9 +12,9 @@
#ifndef WEBRTC_COMMON_VIDEO_H264_SPS_VUI_REWRITER_H_
#define WEBRTC_COMMON_VIDEO_H264_SPS_VUI_REWRITER_H_
+#include "webrtc/api/optional.h"
#include "webrtc/common_video/h264/sps_parser.h"
#include "webrtc/rtc_base/buffer.h"
-#include "webrtc/rtc_base/optional.h"
namespace rtc {
class BitBuffer;
diff --git a/common_video/video_render_frames.h b/common_video/video_render_frames.h
index 4f043e1..fe4d4f0 100644
--- a/common_video/video_render_frames.h
+++ b/common_video/video_render_frames.h
@@ -15,8 +15,8 @@
#include <list>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_frame.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 0ed8fc2..25aa1e0 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -45,6 +45,7 @@
deps = [
"..:webrtc_common",
+ "../api:optional",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
]
@@ -227,6 +228,7 @@
"..:webrtc_common",
"../api:call_api",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:transport_api",
"../api:video_frame_api",
"../api/audio_codecs:audio_codecs_api",
diff --git a/media/base/h264_profile_level_id.h b/media/base/h264_profile_level_id.h
index 7b1d8c5..acbb84e 100644
--- a/media/base/h264_profile_level_id.h
+++ b/media/base/h264_profile_level_id.h
@@ -14,8 +14,8 @@
#include <map>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace H264 {
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h
index 5aae309..ef245a1 100644
--- a/media/base/mediachannel.h
+++ b/media/base/mediachannel.h
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/rtpparameters.h"
#include "webrtc/api/rtpreceiverinterface.h"
#include "webrtc/api/video/video_timing.h"
@@ -30,7 +31,6 @@
#include "webrtc/rtc_base/dscp.h"
#include "webrtc/rtc_base/logging.h"
#include "webrtc/rtc_base/networkroute.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/sigslot.h"
#include "webrtc/rtc_base/socket.h"
#include "webrtc/rtc_base/window.h"
diff --git a/media/base/videoadapter.cc b/media/base/videoadapter.cc
index 73a5638..45868b6 100644
--- a/media/base/videoadapter.cc
+++ b/media/base/videoadapter.cc
@@ -15,12 +15,12 @@
#include <cstdlib>
#include <limits>
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/mediaconstants.h"
#include "webrtc/media/base/videocommon.h"
#include "webrtc/rtc_base/arraysize.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
namespace {
struct Fraction {
diff --git a/media/base/videoadapter.h b/media/base/videoadapter.h
index 135f411..61de4b5 100644
--- a/media/base/videoadapter.h
+++ b/media/base/videoadapter.h
@@ -11,10 +11,10 @@
#ifndef WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_
#define WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/videocommon.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
namespace cricket {
diff --git a/media/base/videosourceinterface.h b/media/base/videosourceinterface.h
index 24b3bed..551a6ea 100644
--- a/media/base/videosourceinterface.h
+++ b/media/base/videosourceinterface.h
@@ -11,8 +11,8 @@
#ifndef WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
#define WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/videosinkinterface.h"
-#include "webrtc/rtc_base/optional.h"
namespace rtc {
diff --git a/media/engine/payload_type_mapper.h b/media/engine/payload_type_mapper.h
index 1a74f21..128f557 100644
--- a/media/engine/payload_type_mapper.h
+++ b/media/engine/payload_type_mapper.h
@@ -15,8 +15,8 @@
#include <set>
#include "webrtc/api/audio_codecs/audio_format.h"
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/codec.h"
-#include "webrtc/rtc_base/optional.h"
namespace cricket {
diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h
index 3224d00..7710c04 100644
--- a/media/engine/webrtcvideoengine.h
+++ b/media/engine/webrtcvideoengine.h
@@ -18,6 +18,7 @@
#include <vector>
#include "webrtc/api/call/transport.h"
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_frame.h"
#include "webrtc/call/call.h"
#include "webrtc/call/flexfec_receive_stream.h"
@@ -31,7 +32,6 @@
#include "webrtc/rtc_base/asyncinvoker.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/networkroute.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/rtc_base/thread_checker.h"
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 359bd8c..dd8e54b 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -36,6 +36,7 @@
]
deps = [
"..:webrtc_common",
+ "../api:optional",
"../api:video_frame_api",
"../rtc_base:rtc_base_approved",
]
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 8d92c46..4003db1 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -47,6 +47,7 @@
deps = [
"../..:webrtc_common",
"../../api:array_view",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../rtc_base:rtc_base_approved",
]
@@ -61,6 +62,7 @@
]
deps = [
"../../api:array_view",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../..:webrtc_common",
"../../rtc_base:protobuf_utils",
@@ -132,6 +134,7 @@
":neteq",
":rent_a_codec",
"../../rtc_base:rtc_base_approved",
+ "../../api:optional",
"../../logging:rtc_event_log_api",
]
defines = audio_coding_defines
@@ -814,6 +817,7 @@
deps = [
":audio_network_adaptor",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs/opus:audio_encoder_opus_config",
"../../common_audio",
@@ -908,6 +912,7 @@
deps = [
"../..:webrtc_common",
+ "../../api:optional",
"../../common_audio",
"../../logging:rtc_event_log_api",
"../../rtc_base:protobuf_utils",
@@ -934,6 +939,7 @@
"neteq/neteq_decoder_enum.h",
]
deps = [
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../rtc_base:rtc_base_approved",
]
@@ -1023,6 +1029,7 @@
":pcm16b",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../common_audio",
"../../rtc_base:gtest_prod",
@@ -1082,6 +1089,7 @@
":neteq",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
"../../rtc_base:rtc_base_approved",
@@ -1166,6 +1174,7 @@
deps = [
"../..:webrtc_common",
"../../api:array_view",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../common_audio",
"../../rtc_base:rtc_base_approved",
@@ -1290,6 +1299,7 @@
":pcm16b_c",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/audio_codecs:builtin_audio_decoder_factory",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
@@ -1396,6 +1406,7 @@
":audio_format_conversion",
"..:module_api",
"../../:webrtc_common",
+ "../../api:optional",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
"../../system_wrappers:system_wrappers_default",
@@ -1425,6 +1436,7 @@
":audio_format_conversion",
"..:module_api",
"../../:webrtc_common",
+ "../../api:optional",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
"../../system_wrappers:system_wrappers_default",
diff --git a/modules/audio_coding/acm2/acm_receiver.h b/modules/audio_coding/acm2/acm_receiver.h
index 5acb013..ebeecec 100644
--- a/modules/audio_coding/acm2/acm_receiver.h
+++ b/modules/audio_coding/acm2/acm_receiver.h
@@ -17,6 +17,7 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
#include "webrtc/modules/audio_coding/acm2/acm_resampler.h"
#include "webrtc/modules/audio_coding/acm2/call_statistics.h"
@@ -24,7 +25,6 @@
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/typedefs.h"
diff --git a/modules/audio_coding/acm2/codec_manager.h b/modules/audio_coding/acm2/codec_manager.h
index 3d45b33..b5c8d3e 100644
--- a/modules/audio_coding/acm2/codec_manager.h
+++ b/modules/audio_coding/acm2/codec_manager.h
@@ -13,12 +13,12 @@
#include <map>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_checker.h"
namespace webrtc {
diff --git a/modules/audio_coding/acm2/rent_a_codec.h b/modules/audio_coding/acm2/rent_a_codec.h
index 3dd9dc8..6dcf793 100644
--- a/modules/audio_coding/acm2/rent_a_codec.h
+++ b/modules/audio_coding/acm2/rent_a_codec.h
@@ -18,10 +18,10 @@
#include "webrtc/api/array_view.h"
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/api/audio_codecs/audio_encoder.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/typedefs.h"
diff --git a/modules/audio_coding/audio_network_adaptor/controller.h b/modules/audio_coding/audio_network_adaptor/controller.h
index ab9cfb7..38c2c21 100644
--- a/modules/audio_coding/audio_network_adaptor/controller.h
+++ b/modules/audio_coding/audio_network_adaptor/controller.h
@@ -11,8 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_
#define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
index 6d03730..fa742e6 100644
--- a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
+++ b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_
#define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/audio_coding/codecs/audio_format_conversion.cc b/modules/audio_coding/codecs/audio_format_conversion.cc
index 17f8d96..1e53bf3 100644
--- a/modules/audio_coding/codecs/audio_format_conversion.cc
+++ b/modules/audio_coding/codecs/audio_format_conversion.cc
@@ -13,8 +13,8 @@
#include <string.h>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/safe_conversions.h"
#include "webrtc/rtc_base/sanitizer.h"
diff --git a/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h b/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
index 387b34b..66f021a 100644
--- a/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
+++ b/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
@@ -14,9 +14,9 @@
#include <vector>
#include "webrtc/api/audio_codecs/audio_decoder.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
namespace webrtc {
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/modules/audio_coding/codecs/opus/audio_encoder_opus.h
index f78cf1e..588f268 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.h
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.h
@@ -19,11 +19,11 @@
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/audio_codecs/audio_format.h"
#include "webrtc/api/audio_codecs/opus/audio_encoder_opus_config.h"
+#include "webrtc/api/optional.h"
#include "webrtc/common_audio/smoothing_filter.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
#include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/protobuf_utils.h"
namespace webrtc {
diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h
index 44eec75..4ceade2 100644
--- a/modules/audio_coding/include/audio_coding_module.h
+++ b/modules/audio_coding/include/audio_coding_module.h
@@ -17,13 +17,13 @@
#include "webrtc/api/audio_codecs/audio_decoder_factory.h"
#include "webrtc/api/audio_codecs/audio_encoder.h"
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
#include "webrtc/modules/include/module.h"
#include "webrtc/rtc_base/deprecation.h"
#include "webrtc/rtc_base/function_view.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/typedefs.h"
diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h
index 56c30e5..9f5af7c 100644
--- a/modules/audio_coding/neteq/include/neteq.h
+++ b/modules/audio_coding/neteq/include/neteq.h
@@ -16,10 +16,10 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/typedefs.h"
diff --git a/modules/audio_coding/neteq/neteq_decoder_enum.h b/modules/audio_coding/neteq/neteq_decoder_enum.h
index a36034c..e108ccf 100644
--- a/modules/audio_coding/neteq/neteq_decoder_enum.h
+++ b/modules/audio_coding/neteq/neteq_decoder_enum.h
@@ -12,7 +12,7 @@
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_DECODER_ENUM_H_
#include "webrtc/api/audio_codecs/audio_format.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h
index f4b014a..fea1682 100644
--- a/modules/audio_coding/neteq/neteq_impl.h
+++ b/modules/audio_coding/neteq/neteq_impl.h
@@ -14,6 +14,7 @@
#include <memory>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
#include "webrtc/modules/audio_coding/neteq/defines.h"
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
@@ -25,7 +26,6 @@
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/typedefs.h"
diff --git a/modules/audio_coding/neteq/packet_buffer.h b/modules/audio_coding/neteq/packet_buffer.h
index afd5f04..5c2499c 100644
--- a/modules/audio_coding/neteq/packet_buffer.h
+++ b/modules/audio_coding/neteq/packet_buffer.h
@@ -11,10 +11,10 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/neteq/packet.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.h b/modules/audio_coding/neteq/tools/fake_decode_from_file.h
index d293ecd..09c2e78 100644
--- a/modules/audio_coding/neteq/tools/fake_decode_from_file.h
+++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.h
@@ -15,8 +15,8 @@
#include "webrtc/api/array_view.h"
#include "webrtc/api/audio_codecs/audio_decoder.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace test {
diff --git a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h
index b652bf2..e142a3b 100644
--- a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h
+++ b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h
@@ -16,9 +16,9 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h"
#include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/modules/audio_coding/neteq/tools/neteq_input.h b/modules/audio_coding/neteq/tools/neteq_input.h
index 1e08893..08f554b 100644
--- a/modules/audio_coding/neteq/tools/neteq_input.h
+++ b/modules/audio_coding/neteq/tools/neteq_input.h
@@ -15,11 +15,11 @@
#include <memory>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/neteq/tools/packet.h"
#include "webrtc/modules/audio_coding/neteq/tools/packet_source.h"
#include "webrtc/rtc_base/buffer.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace test {
diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h
index fd1c53a..3576dc6 100644
--- a/modules/audio_coding/test/PCMFile.h
+++ b/modules/audio_coding/test/PCMFile.h
@@ -16,8 +16,8 @@
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/include/module_common_types.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index b9716ae..2db993b 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -283,6 +283,7 @@
":audio_device",
":mock_audio_device",
"../../api:array_view",
+ "../../api:optional",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
"../../test:test_support",
diff --git a/modules/audio_device/audio_device_unittest.cc b/modules/audio_device/audio_device_unittest.cc
index 67e9f47..c65f139 100644
--- a/modules/audio_device/audio_device_unittest.cc
+++ b/modules/audio_device/audio_device_unittest.cc
@@ -13,6 +13,7 @@
#include <numeric>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_device/audio_device_impl.h"
#include "webrtc/modules/audio_device/include/audio_device.h"
#include "webrtc/modules/audio_device/include/mock_audio_transport.h"
@@ -20,7 +21,6 @@
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/event.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/race_checker.h"
#include "webrtc/rtc_base/safe_conversions.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index e0719b4..4887250 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -238,6 +238,7 @@
"..:module_api",
"../..:webrtc_common",
"../../api:array_view",
+ "../../api:optional",
"../../audio/utility:audio_frame_operations",
"../../rtc_base:gtest_prod",
"../../rtc_base:protobuf_utils",
@@ -553,6 +554,7 @@
"..:module_api",
"../..:webrtc_common",
"../../api:array_view",
+ "../../api:optional",
"../../common_audio:common_audio",
"../../rtc_base:gtest_prod",
"../../rtc_base:protobuf_utils",
@@ -747,6 +749,7 @@
":audioproc_debug_proto",
":audioproc_protobuf_utils",
":audioproc_test_utils",
+ "../../api:optional",
"../../common_audio:common_audio",
"../../rtc_base:protobuf_utils",
"../../rtc_base:rtc_base_approved",
@@ -778,6 +781,7 @@
":audio_processing",
"..:module_api",
"../../api:array_view",
+ "../../api:optional",
"../../common_audio",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h
index 8dc4530..38ed3b0 100644
--- a/modules/audio_processing/aec3/aec_state.h
+++ b/modules/audio_processing/aec3/aec_state.h
@@ -16,6 +16,7 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
#include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
#include "webrtc/modules/audio_processing/aec3/erl_estimator.h"
@@ -23,7 +24,6 @@
#include "webrtc/modules/audio_processing/aec3/render_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/block_processor.cc b/modules/audio_processing/aec3/block_processor.cc
index 536335e..7bb9e15 100644
--- a/modules/audio_processing/aec3/block_processor.cc
+++ b/modules/audio_processing/aec3/block_processor.cc
@@ -9,13 +9,13 @@
*/
#include "webrtc/modules/audio_processing/aec3/block_processor.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
#include "webrtc/modules/audio_processing/aec3/block_processor_metrics.h"
#include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
#include "webrtc/rtc_base/atomicops.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace {
diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.h b/modules/audio_processing/aec3/echo_path_delay_estimator.h
index 4b536b9..7ff1cb3 100644
--- a/modules/audio_processing/aec3/echo_path_delay_estimator.h
+++ b/modules/audio_processing/aec3/echo_path_delay_estimator.h
@@ -13,13 +13,13 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/decimator_by_4.h"
#include "webrtc/modules/audio_processing/aec3/downsampled_render_buffer.h"
#include "webrtc/modules/audio_processing/aec3/matched_filter.h"
#include "webrtc/modules/audio_processing/aec3/matched_filter_lag_aggregator.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/echo_remover.h b/modules/audio_processing/aec3/echo_remover.h
index ce43fa8..8a28729 100644
--- a/modules/audio_processing/aec3/echo_remover.h
+++ b/modules/audio_processing/aec3/echo_remover.h
@@ -13,10 +13,10 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
#include "webrtc/modules/audio_processing/aec3/render_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/matched_filter.h b/modules/audio_processing/aec3/matched_filter.h
index 0702a12..a200af1 100644
--- a/modules/audio_processing/aec3/matched_filter.h
+++ b/modules/audio_processing/aec3/matched_filter.h
@@ -15,10 +15,10 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
#include "webrtc/modules/audio_processing/aec3/downsampled_render_buffer.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace aec3 {
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
index 983ae3b..d490f0d 100644
--- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
+++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
@@ -13,9 +13,9 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/matched_filter.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/mock/mock_echo_remover.h b/modules/audio_processing/aec3/mock/mock_echo_remover.h
index 008fca6..8d2aca9 100644
--- a/modules/audio_processing/aec3/mock/mock_echo_remover.h
+++ b/modules/audio_processing/aec3/mock/mock_echo_remover.h
@@ -13,10 +13,10 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
#include "webrtc/modules/audio_processing/aec3/echo_remover.h"
#include "webrtc/modules/audio_processing/aec3/render_buffer.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/test/gmock.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h
index 46a59dc..64daef5 100644
--- a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h
+++ b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h
@@ -12,9 +12,9 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_RENDER_DELAY_CONTROLLER_H_
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/downsampled_render_buffer.h"
#include "webrtc/modules/audio_processing/aec3/render_delay_controller.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/test/gmock.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/render_delay_controller.h b/modules/audio_processing/aec3/render_delay_controller.h
index c1e2229..e840178 100644
--- a/modules/audio_processing/aec3/render_delay_controller.h
+++ b/modules/audio_processing/aec3/render_delay_controller.h
@@ -12,11 +12,11 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/downsampled_render_buffer.h"
#include "webrtc/modules/audio_processing/aec3/render_delay_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics.h b/modules/audio_processing/aec3/render_delay_controller_metrics.h
index 0cef897..625f30f 100644
--- a/modules/audio_processing/aec3/render_delay_controller_metrics.h
+++ b/modules/audio_processing/aec3/render_delay_controller_metrics.h
@@ -11,8 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc
index 5f24fe3..bb39e77 100644
--- a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc
+++ b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc
@@ -9,8 +9,8 @@
*/
#include "webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/test/gtest.h"
diff --git a/modules/audio_processing/aec3/render_signal_analyzer.h b/modules/audio_processing/aec3/render_signal_analyzer.h
index b0b56cd..48ce81e 100644
--- a/modules/audio_processing/aec3/render_signal_analyzer.h
+++ b/modules/audio_processing/aec3/render_signal_analyzer.h
@@ -14,10 +14,10 @@
#include <array>
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
#include "webrtc/modules/audio_processing/aec3/render_buffer.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/beamformer/array_util.h b/modules/audio_processing/beamformer/array_util.h
index bfb9dfd..aa18e71 100644
--- a/modules/audio_processing/beamformer/array_util.h
+++ b/modules/audio_processing/beamformer/array_util.h
@@ -14,7 +14,7 @@
#include <cmath>
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/echo_detector/circular_buffer.h b/modules/audio_processing/echo_detector/circular_buffer.h
index 9fadb0d..cf58e33 100644
--- a/modules/audio_processing/echo_detector/circular_buffer.h
+++ b/modules/audio_processing/echo_detector/circular_buffer.h
@@ -13,7 +13,7 @@
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc
index e576018..f882d10 100644
--- a/modules/audio_processing/gain_control_impl.cc
+++ b/modules/audio_processing/gain_control_impl.cc
@@ -10,11 +10,11 @@
#include "webrtc/modules/audio_processing/gain_control_impl.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/level_controller/level_controller.h b/modules/audio_processing/level_controller/level_controller.h
index e04620f..9aa5085 100644
--- a/modules/audio_processing/level_controller/level_controller.h
+++ b/modules/audio_processing/level_controller/level_controller.h
@@ -14,6 +14,7 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/level_controller/gain_applier.h"
#include "webrtc/modules/audio_processing/level_controller/gain_selector.h"
@@ -22,7 +23,6 @@
#include "webrtc/modules/audio_processing/level_controller/saturating_gain_estimator.h"
#include "webrtc/modules/audio_processing/level_controller/signal_classifier.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/audio_processing/level_controller/level_controller_unittest.cc b/modules/audio_processing/level_controller/level_controller_unittest.cc
index b7571e9..d37b580 100644
--- a/modules/audio_processing/level_controller/level_controller_unittest.cc
+++ b/modules/audio_processing/level_controller/level_controller_unittest.cc
@@ -11,12 +11,12 @@
#include <vector>
#include "webrtc/api/array_view.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/level_controller/level_controller.h"
#include "webrtc/modules/audio_processing/test/audio_buffer_tools.h"
#include "webrtc/modules/audio_processing/test/bitexactness_tools.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/test/gtest.h"
namespace webrtc {
diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h
index 4ce28a4..e0df754 100644
--- a/modules/audio_processing/rms_level.h
+++ b/modules/audio_processing/rms_level.h
@@ -12,7 +12,7 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
#include "webrtc/api/array_view.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h
index 1ae465c..8a2295f 100644
--- a/modules/audio_processing/test/audio_processing_simulator.h
+++ b/modules/audio_processing/test/audio_processing_simulator.h
@@ -17,11 +17,11 @@
#include <memory>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/test/test_utils.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/task_queue.h"
#include "webrtc/rtc_base/timeutils.h"
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn
index 1f24c09..1d492bf 100644
--- a/modules/audio_processing/test/conversational_speech/BUILD.gn
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -65,6 +65,7 @@
":lib",
"../../../..:webrtc_common",
"../../../../api:array_view",
+ "../../../../api:optional",
"../../../../common_audio",
"../../../../rtc_base:rtc_base_approved",
"../../../../test:test_support",
diff --git a/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/modules/audio_processing/test/conversational_speech/generator_unittest.cc
index 9a52e5c..e0aa43d 100644
--- a/modules/audio_processing/test/conversational_speech/generator_unittest.cc
+++ b/modules/audio_processing/test/conversational_speech/generator_unittest.cc
@@ -42,6 +42,7 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/common_audio/wav_file.h"
#include "webrtc/modules/audio_processing/test/conversational_speech/config.h"
#include "webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h"
@@ -50,7 +51,6 @@
#include "webrtc/modules/audio_processing/test/conversational_speech/timing.h"
#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/pathutils.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
diff --git a/modules/audio_processing/test/performance_timer.h b/modules/audio_processing/test/performance_timer.h
index 3e75e3f..9377f4a 100644
--- a/modules/audio_processing/test/performance_timer.h
+++ b/modules/audio_processing/test/performance_timer.h
@@ -13,7 +13,7 @@
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
#include "webrtc/system_wrappers/include/clock.h"
namespace webrtc {
diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn
index 8c3f35b..be0afd2 100644
--- a/modules/congestion_controller/BUILD.gn
+++ b/modules/congestion_controller/BUILD.gn
@@ -49,6 +49,7 @@
deps = [
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../logging:rtc_event_log_api",
"../../rtc_base:rtc_base",
"../../rtc_base:rtc_base_approved",
diff --git a/modules/congestion_controller/acknowledged_bitrate_estimator.h b/modules/congestion_controller/acknowledged_bitrate_estimator.h
index bab5d93..491acb6 100644
--- a/modules/congestion_controller/acknowledged_bitrate_estimator.h
+++ b/modules/congestion_controller/acknowledged_bitrate_estimator.h
@@ -14,8 +14,8 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/congestion_controller/bitrate_estimator.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/congestion_controller/bitrate_estimator.h b/modules/congestion_controller/bitrate_estimator.h
index f27d063..ad7bef5 100644
--- a/modules/congestion_controller/bitrate_estimator.h
+++ b/modules/congestion_controller/bitrate_estimator.h
@@ -13,7 +13,7 @@
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/congestion_controller/trendline_estimator.cc b/modules/congestion_controller/trendline_estimator.cc
index 4d25b45..e51d4fb 100644
--- a/modules/congestion_controller/trendline_estimator.cc
+++ b/modules/congestion_controller/trendline_estimator.cc
@@ -12,9 +12,9 @@
#include <algorithm>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index 1ee428d..a3ac2bb 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -17,6 +17,7 @@
#include <algorithm>
#include <limits>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/video_rotation.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/video_coding/codecs/h264/include/h264_globals.h"
@@ -24,7 +25,6 @@
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9_globals.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/deprecation.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/safe_conversions.h"
#include "webrtc/typedefs.h"
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index 7884c01..4882d4f 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -31,6 +31,7 @@
deps = [
"..:module_api",
"../../:webrtc_common",
+ "../../api:optional",
"../../logging:rtc_event_log_api",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
diff --git a/modules/pacing/alr_detector.h b/modules/pacing/alr_detector.h
index 1e124d9..0d43fbb 100644
--- a/modules/pacing/alr_detector.h
+++ b/modules/pacing/alr_detector.h
@@ -11,10 +11,10 @@
#ifndef WEBRTC_MODULES_PACING_ALR_DETECTOR_H_
#define WEBRTC_MODULES_PACING_ALR_DETECTOR_H_
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/pacing/interval_budget.h"
#include "webrtc/modules/pacing/paced_sender.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/rate_statistics.h"
#include "webrtc/typedefs.h"
diff --git a/modules/pacing/paced_sender.h b/modules/pacing/paced_sender.h
index 74b8780..a9c6233 100644
--- a/modules/pacing/paced_sender.h
+++ b/modules/pacing/paced_sender.h
@@ -15,9 +15,9 @@
#include <memory>
#include <set>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/pacing/pacer.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/typedefs.h"
diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn
index 8bcbe7b..72e6f1d 100644
--- a/modules/remote_bitrate_estimator/BUILD.gn
+++ b/modules/remote_bitrate_estimator/BUILD.gn
@@ -140,6 +140,7 @@
":remote_bitrate_estimator",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../rtc_base:gtest_prod",
"../../rtc_base:rtc_base",
"../../rtc_base:rtc_base_approved",
diff --git a/modules/remote_bitrate_estimator/include/bwe_defines.h b/modules/remote_bitrate_estimator/include/bwe_defines.h
index 21f9e57..426dbb1 100644
--- a/modules/remote_bitrate_estimator/include/bwe_defines.h
+++ b/modules/remote_bitrate_estimator/include/bwe_defines.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_BWE_DEFINES_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_BWE_DEFINES_H_
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
#include "webrtc/typedefs.h"
#define BWE_MAX(a, b) ((a) > (b) ? (a) : (b))
diff --git a/modules/remote_bitrate_estimator/test/estimators/bbr.h b/modules/remote_bitrate_estimator/test/estimators/bbr.h
index 6f4d831..cf61c57 100644
--- a/modules/remote_bitrate_estimator/test/estimators/bbr.h
+++ b/modules/remote_bitrate_estimator/test/estimators/bbr.h
@@ -17,9 +17,9 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
#include "webrtc/modules/video_coding/sequence_number_util.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/random.h"
namespace webrtc {
diff --git a/modules/remote_bitrate_estimator/test/estimators/congestion_window.h b/modules/remote_bitrate_estimator/test/estimators/congestion_window.h
index 105a748..3194d81 100644
--- a/modules/remote_bitrate_estimator/test/estimators/congestion_window.h
+++ b/modules/remote_bitrate_estimator/test/estimators/congestion_window.h
@@ -14,7 +14,7 @@
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
namespace testing {
diff --git a/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h b/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h
index f45437e..82451bd 100644
--- a/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h
+++ b/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h
@@ -16,7 +16,7 @@
#include <limits>
#include <list>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
namespace testing {
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 8d17d1a..2095aad 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -169,6 +169,7 @@
"../..:webrtc_common",
"../../api:array_view",
"../../api:libjingle_peerconnection_api",
+ "../../api:optional",
"../../api:transport_api",
"../../api/audio_codecs:audio_codecs_api",
"../../common_video",
@@ -222,6 +223,7 @@
deps = [
":rtp_rtcp",
"..:module_api",
+ "../../api:optional",
"../../rtc_base:rtc_base_approved",
"../../test:test_support",
]
diff --git a/modules/rtp_rtcp/include/rtp_rtcp.h b/modules/rtp_rtcp/include/rtp_rtcp.h
index 4272294..25d9046 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp.h
@@ -16,13 +16,13 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/deprecation.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
index 54d84d5..1d45463 100644
--- a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
+++ b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
@@ -15,12 +15,12 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/include/module.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/test/gmock.h"
namespace webrtc {
diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h
index aed304f..33a23de 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h
+++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h
@@ -13,12 +13,12 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/target_bitrate.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace rtcp {
diff --git a/modules/rtp_rtcp/source/rtcp_sender.h b/modules/rtp_rtcp/source/rtcp_sender.h
index 7b3ad49..ae06a17 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.h
+++ b/modules/rtp_rtcp/source/rtcp_sender.h
@@ -19,6 +19,7 @@
#include <vector>
#include "webrtc/api/call/transport.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
@@ -30,7 +31,6 @@
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/random.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/typedefs.h"
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 7a28be5..aa95550 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -16,6 +16,7 @@
#include <utility>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/packet_loss_stats.h"
@@ -24,7 +25,6 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/gtest_prod_util.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index 9c4fdc1..f345274 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -18,6 +18,7 @@
#include "webrtc/api/array_view.h"
#include "webrtc/api/call/transport.h"
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h"
@@ -29,7 +30,6 @@
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/deprecation.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/random.h"
#include "webrtc/rtc_base/rate_statistics.h"
#include "webrtc/rtc_base/thread_annotations.h"
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.h b/modules/rtp_rtcp/source/rtp_sender_video.h
index e4a2405..f91fa69 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video.h
@@ -14,6 +14,7 @@
#include <map>
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -24,7 +25,6 @@
#include "webrtc/modules/rtp_rtcp/source/video_codec_information.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/onetimeevent.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/rate_statistics.h"
#include "webrtc/rtc_base/sequenced_task_checker.h"
#include "webrtc/rtc_base/thread_annotations.h"
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 3af09ea..3bf221b 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -96,6 +96,7 @@
":webrtc_vp9",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../call:video_stream_api",
"../../common_video",
"../../rtc_base:rtc_base",
@@ -136,6 +137,7 @@
deps = [
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/video_codecs:video_codecs_api",
"../../common_video",
"../../modules/rtp_rtcp:rtp_rtcp",
@@ -232,6 +234,7 @@
":video_coding_utility",
"..:module_api",
"../..:webrtc_common",
+ "../../api:optional",
"../../api/video_codecs:video_codecs_api",
"../../common_video",
"../../rtc_base:rtc_base_approved",
@@ -438,6 +441,7 @@
":webrtc_h264",
":webrtc_vp8",
":webrtc_vp9",
+ "../../api:optional",
"../../api:video_frame_api",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.h b/modules/video_coding/codecs/vp8/default_temporal_layers.h
index 4762f87..985874b 100644
--- a/modules/video_coding/codecs/vp8/default_temporal_layers.h
+++ b/modules/video_coding/codecs/vp8/default_temporal_layers.h
@@ -16,7 +16,7 @@
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index 310fa3c..3eb04be 100644
--- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -12,13 +12,13 @@
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/codecs/test/video_codec_test.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/timeutils.h"
#include "webrtc/test/field_trial.h"
#include "webrtc/test/frame_utils.h"
diff --git a/modules/video_coding/frame_object.h b/modules/video_coding/frame_object.h
index 90c1c00..69ab6f0 100644
--- a/modules/video_coding/frame_object.h
+++ b/modules/video_coding/frame_object.h
@@ -11,10 +11,10 @@
#ifndef WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_
#define WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/encoded_frame.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace video_coding {
diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc
index adc4365..339e1b5 100644
--- a/modules/video_coding/generic_encoder.cc
+++ b/modules/video_coding/generic_encoder.cc
@@ -12,13 +12,13 @@
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/modules/pacing/alr_detector.h"
#include "webrtc/modules/video_coding/encoded_frame.h"
#include "webrtc/modules/video_coding/media_optimization.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/timeutils.h"
#include "webrtc/rtc_base/trace_event.h"
#include "webrtc/system_wrappers/include/field_trial.h"
diff --git a/modules/video_coding/sequence_number_util.h b/modules/video_coding/sequence_number_util.h
index 05f3367..3e7d64a 100644
--- a/modules/video_coding/sequence_number_util.h
+++ b/modules/video_coding/sequence_number_util.h
@@ -14,8 +14,8 @@
#include <limits>
#include <type_traits>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/mod_ops.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/safe_compare.h"
namespace webrtc {
diff --git a/modules/video_coding/utility/moving_average.h b/modules/video_coding/utility/moving_average.h
index bc31cd5..0f2c4cc 100644
--- a/modules/video_coding/utility/moving_average.h
+++ b/modules/video_coding/utility/moving_average.h
@@ -13,7 +13,7 @@
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
class MovingAverage {
diff --git a/modules/video_coding/utility/quality_scaler.h b/modules/video_coding/utility/quality_scaler.h
index 690d1bc..25d39cc 100644
--- a/modules/video_coding/utility/quality_scaler.h
+++ b/modules/video_coding/utility/quality_scaler.h
@@ -13,10 +13,10 @@
#include <utility>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video_codecs/video_encoder.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/video_coding/utility/moving_average.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/sequenced_task_checker.h"
namespace webrtc {
diff --git a/ortc/BUILD.gn b/ortc/BUILD.gn
index 199ee62..485771c 100644
--- a/ortc/BUILD.gn
+++ b/ortc/BUILD.gn
@@ -33,6 +33,7 @@
# PeerConnection code shares, so that ortc can depend on that instead of
# libjingle_peerconnection.
deps = [
+ "../api:optional",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../call:call_interfaces",
diff --git a/ortc/rtpparametersconversion.h b/ortc/rtpparametersconversion.h
index fe183da..072aaf2 100644
--- a/ortc/rtpparametersconversion.h
+++ b/ortc/rtpparametersconversion.h
@@ -14,11 +14,11 @@
#include <memory>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/rtcerror.h"
#include "webrtc/api/rtpparameters.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/pc/mediasession.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 588f6bd..9223f86 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -86,6 +86,7 @@
deps = [
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:ortc_api",
"../rtc_base:rtc_base",
"../system_wrappers:field_trial_api",
diff --git a/p2p/base/jseptransport.h b/p2p/base/jseptransport.h
index aee0718..f680646 100644
--- a/p2p/base/jseptransport.h
+++ b/p2p/base/jseptransport.h
@@ -16,13 +16,13 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/p2pconstants.h"
#include "webrtc/p2p/base/sessiondescription.h"
#include "webrtc/p2p/base/transportinfo.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/messagequeue.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/rtccertificate.h"
#include "webrtc/rtc_base/sigslot.h"
#include "webrtc/rtc_base/sslstreamadapter.h"
diff --git a/p2p/base/port.h b/p2p/base/port.h
index 19391b5..76a3dea 100644
--- a/p2p/base/port.h
+++ b/p2p/base/port.h
@@ -17,6 +17,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/jseptransport.h"
@@ -28,7 +29,6 @@
#include "webrtc/rtc_base/asyncpacketsocket.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/network.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/proxyinfo.h"
#include "webrtc/rtc_base/ratetracker.h"
#include "webrtc/rtc_base/sigslot.h"
diff --git a/p2p/base/udptransport.h b/p2p/base/udptransport.h
index c3c9513..823c88f 100644
--- a/p2p/base/udptransport.h
+++ b/p2p/base/udptransport.h
@@ -14,10 +14,10 @@
#include <memory>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/api/ortc/udptransportinterface.h"
#include "webrtc/p2p/base/packettransportinternal.h"
#include "webrtc/rtc_base/asyncpacketsocket.h" // For PacketOptions.
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_checker.h"
namespace rtc {
diff --git a/p2p/quic/quictransportchannel.h b/p2p/quic/quictransportchannel.h
index 4c34675..76560e9 100644
--- a/p2p/quic/quictransportchannel.h
+++ b/p2p/quic/quictransportchannel.h
@@ -17,11 +17,11 @@
#include "net/quic/quic_crypto_client_stream.h"
#include "net/quic/quic_packet_writer.h"
+#include "webrtc/api/optional.h"
#include "webrtc/p2p/base/transportchannelimpl.h"
#include "webrtc/p2p/quic/quicconnectionhelper.h"
#include "webrtc/p2p/quic/quicsession.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace cricket {
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 6473cf6..09c58ab 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -62,6 +62,7 @@
"..:webrtc_common",
"../api:call_api",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:ortc_api",
"../media:rtc_data",
"../media:rtc_h264_profile_id",
@@ -166,6 +167,7 @@
":rtc_pc_base",
"..:webrtc_common",
"../api:call_api",
+ "../api:optional",
"../api:rtc_stats_api",
"../api/video_codecs:video_codecs_api",
"../call:call_interfaces",
diff --git a/pc/mediasession.cc b/pc/mediasession.cc
index 4d4744a..2d9fd94 100644
--- a/pc/mediasession.cc
+++ b/pc/mediasession.cc
@@ -18,6 +18,7 @@
#include <unordered_map>
#include <utility>
+#include "webrtc/api/optional.h"
#include "webrtc/common_types.h"
#include "webrtc/media/base/cryptoparams.h"
#include "webrtc/media/base/h264_profile_level_id.h"
@@ -29,7 +30,6 @@
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/helpers.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/stringutils.h"
namespace {
diff --git a/pc/rtcstatscollector.h b/pc/rtcstatscollector.h
index 980edd6..5ba4bfd 100644
--- a/pc/rtcstatscollector.h
+++ b/pc/rtcstatscollector.h
@@ -16,6 +16,7 @@
#include <set>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/stats/rtcstats_objects.h"
#include "webrtc/api/stats/rtcstatscollectorcallback.h"
#include "webrtc/api/stats/rtcstatsreport.h"
@@ -24,7 +25,6 @@
#include "webrtc/pc/datachannel.h"
#include "webrtc/pc/trackmediainfomap.h"
#include "webrtc/rtc_base/asyncinvoker.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/refcount.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
#include "webrtc/rtc_base/sigslot.h"
diff --git a/pc/srtpfilter.h b/pc/srtpfilter.h
index 619aaa3..2a90360 100644
--- a/pc/srtpfilter.h
+++ b/pc/srtpfilter.h
@@ -17,13 +17,13 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/media/base/cryptoparams.h"
#include "webrtc/p2p/base/sessiondescription.h"
#include "webrtc/rtc_base/basictypes.h"
#include "webrtc/rtc_base/buffer.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/sslstreamadapter.h"
#include "webrtc/rtc_base/thread_checker.h"
diff --git a/pc/webrtcsession.h b/pc/webrtcsession.h
index 0f4d321..4d52a5c 100644
--- a/pc/webrtcsession.h
+++ b/pc/webrtcsession.h
@@ -16,6 +16,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/peerconnectioninterface.h"
#include "webrtc/api/statstypes.h"
#include "webrtc/call/call.h"
@@ -24,7 +25,6 @@
#include "webrtc/pc/datachannel.h"
#include "webrtc/pc/mediasession.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/sigslot.h"
#include "webrtc/rtc_base/sslidentity.h"
#include "webrtc/rtc_base/thread.h"
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 1914b27..6676fdf 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -137,8 +137,6 @@
"mod_ops.h",
"moving_max_counter.h",
"onetimeevent.h",
- "optional.cc",
- "optional.h",
"pathutils.cc",
"pathutils.h",
"platform_file.cc",
@@ -436,6 +434,7 @@
defines = []
deps = [
"..:webrtc_common",
+ "../api:optional",
]
public_deps = [
":rtc_base_approved",
@@ -855,7 +854,6 @@
"mod_ops_unittest.cc",
"moving_max_counter_unittest.cc",
"onetimeevent_unittest.cc",
- "optional_unittest.cc",
"pathutils_unittest.cc",
"platform_thread_unittest.cc",
"random_unittest.cc",
@@ -1047,6 +1045,7 @@
deps = [
":rtc_base_tests_main",
":rtc_base_tests_utils",
+ "../api:optional",
"../test:test_support",
]
public_deps = [
diff --git a/rtc_base/moving_max_counter.h b/rtc_base/moving_max_counter.h
index 907e9cf..190b7b8 100644
--- a/rtc_base/moving_max_counter.h
+++ b/rtc_base/moving_max_counter.h
@@ -17,9 +17,9 @@
#include <limits>
#include <utility>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
namespace rtc {
diff --git a/rtc_base/optional.h b/rtc_base/optional.h
index ca3208e..b707746 100644
--- a/rtc_base/optional.h
+++ b/rtc_base/optional.h
@@ -8,402 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+// This header is for backwards compatibility only, and will be removed soon.
+// Include webrtc/api/optional.h instead.
+
#ifndef WEBRTC_RTC_BASE_OPTIONAL_H_
#define WEBRTC_RTC_BASE_OPTIONAL_H_
-#include <algorithm>
-#include <memory>
-#include <utility>
-
-#ifdef UNIT_TEST
-#include <iomanip>
-#include <ostream>
-#endif // UNIT_TEST
-
-#include "webrtc/api/array_view.h"
-#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/sanitizer.h"
-
-namespace rtc {
-
-namespace optional_internal {
-
-#if RTC_HAS_ASAN
-
-// This is a non-inlined function. The optimizer can't see inside it. It
-// prevents the compiler from generating optimized code that reads value_ even
-// if it is unset. Although safe, this causes memory sanitizers to complain.
-void* FunctionThatDoesNothingImpl(void*);
-
-template <typename T>
-inline T* FunctionThatDoesNothing(T* x) {
- return reinterpret_cast<T*>(
- FunctionThatDoesNothingImpl(reinterpret_cast<void*>(x)));
-}
-
-#else
-
-template <typename T>
-inline T* FunctionThatDoesNothing(T* x) { return x; }
-
-#endif
-
-} // namespace optional_internal
-
-// Simple std::optional-wannabe. It either contains a T or not.
-//
-// A moved-from Optional<T> may only be destroyed, and assigned to if T allows
-// being assigned to after having been moved from. Specifically, you may not
-// assume that it just doesn't contain a value anymore.
-//
-// Examples of good places to use Optional:
-//
-// - As a class or struct member, when the member doesn't always have a value:
-// struct Prisoner {
-// std::string name;
-// Optional<int> cell_number; // Empty if not currently incarcerated.
-// };
-//
-// - As a return value for functions that may fail to return a value on all
-// allowed inputs. For example, a function that searches an array might
-// return an Optional<size_t> (the index where it found the element, or
-// nothing if it didn't find it); and a function that parses numbers might
-// return Optional<double> (the parsed number, or nothing if parsing failed).
-//
-// Examples of bad places to use Optional:
-//
-// - As a return value for functions that may fail because of disallowed
-// inputs. For example, a string length function should not return
-// Optional<size_t> so that it can return nothing in case the caller passed
-// it a null pointer; the function should probably use RTC_[D]CHECK instead,
-// and return plain size_t.
-//
-// - As a return value for functions that may fail to return a value on all
-// allowed inputs, but need to tell the caller what went wrong. Returning
-// Optional<double> when parsing a single number as in the example above
-// might make sense, but any larger parse job is probably going to need to
-// tell the caller what the problem was, not just that there was one.
-//
-// - As a non-mutable function argument. When you want to pass a value of a
-// type T that can fail to be there, const T* is almost always both fastest
-// and cleanest. (If you're *sure* that the the caller will always already
-// have an Optional<T>, const Optional<T>& is slightly faster than const T*,
-// but this is a micro-optimization. In general, stick to const T*.)
-//
-// TODO(kwiberg): Get rid of this class when the standard library has
-// std::optional (and we're allowed to use it).
-template <typename T>
-class Optional final {
- public:
- // Construct an empty Optional.
- Optional() : has_value_(false), empty_('\0') {
- PoisonValue();
- }
-
- // Construct an Optional that contains a value.
- explicit Optional(const T& value) : has_value_(true) {
- new (&value_) T(value);
- }
- explicit Optional(T&& value) : has_value_(true) {
- new (&value_) T(std::move(value));
- }
-
- // Copy constructor: copies the value from m if it has one.
- Optional(const Optional& m) : has_value_(m.has_value_) {
- if (has_value_)
- new (&value_) T(m.value_);
- else
- PoisonValue();
- }
-
- // Move constructor: if m has a value, moves the value from m, leaving m
- // still in a state where it has a value, but a moved-from one (the
- // properties of which depends on T; the only general guarantee is that we
- // can destroy m).
- Optional(Optional&& m) : has_value_(m.has_value_) {
- if (has_value_)
- new (&value_) T(std::move(m.value_));
- else
- PoisonValue();
- }
-
- ~Optional() {
- if (has_value_)
- value_.~T();
- else
- UnpoisonValue();
- }
-
- // Copy assignment. Uses T's copy assignment if both sides have a value, T's
- // copy constructor if only the right-hand side has a value.
- Optional& operator=(const Optional& m) {
- if (m.has_value_) {
- if (has_value_) {
- value_ = m.value_; // T's copy assignment.
- } else {
- UnpoisonValue();
- new (&value_) T(m.value_); // T's copy constructor.
- has_value_ = true;
- }
- } else {
- reset();
- }
- return *this;
- }
-
- // Move assignment. Uses T's move assignment if both sides have a value, T's
- // move constructor if only the right-hand side has a value. The state of m
- // after it's been moved from is as for the move constructor.
- Optional& operator=(Optional&& m) {
- if (m.has_value_) {
- if (has_value_) {
- value_ = std::move(m.value_); // T's move assignment.
- } else {
- UnpoisonValue();
- new (&value_) T(std::move(m.value_)); // T's move constructor.
- has_value_ = true;
- }
- } else {
- reset();
- }
- return *this;
- }
-
- // Swap the values if both m1 and m2 have values; move the value if only one
- // of them has one.
- friend void swap(Optional& m1, Optional& m2) {
- if (m1.has_value_) {
- if (m2.has_value_) {
- // Both have values: swap.
- using std::swap;
- swap(m1.value_, m2.value_);
- } else {
- // Only m1 has a value: move it to m2.
- m2.UnpoisonValue();
- new (&m2.value_) T(std::move(m1.value_));
- m1.value_.~T(); // Destroy the moved-from value.
- m1.has_value_ = false;
- m2.has_value_ = true;
- m1.PoisonValue();
- }
- } else if (m2.has_value_) {
- // Only m2 has a value: move it to m1.
- m1.UnpoisonValue();
- new (&m1.value_) T(std::move(m2.value_));
- m2.value_.~T(); // Destroy the moved-from value.
- m1.has_value_ = true;
- m2.has_value_ = false;
- m2.PoisonValue();
- }
- }
-
- // Destroy any contained value. Has no effect if we have no value.
- void reset() {
- if (!has_value_)
- return;
- value_.~T();
- has_value_ = false;
- PoisonValue();
- }
-
- template <class... Args>
- void emplace(Args&&... args) {
- if (has_value_)
- value_.~T();
- else
- UnpoisonValue();
- new (&value_) T(std::forward<Args>(args)...);
- has_value_ = true;
- }
-
- // Conversion to bool to test if we have a value.
- explicit operator bool() const { return has_value_; }
- bool has_value() const { return has_value_; }
-
- // Dereferencing. Only allowed if we have a value.
- const T* operator->() const {
- RTC_DCHECK(has_value_);
- return &value_;
- }
- T* operator->() {
- RTC_DCHECK(has_value_);
- return &value_;
- }
- const T& operator*() const {
- RTC_DCHECK(has_value_);
- return value_;
- }
- T& operator*() {
- RTC_DCHECK(has_value_);
- return value_;
- }
- const T& value() const {
- RTC_DCHECK(has_value_);
- return value_;
- }
- T& value() {
- RTC_DCHECK(has_value_);
- return value_;
- }
-
- // Dereference with a default value in case we don't have a value.
- const T& value_or(const T& default_val) const {
- // The no-op call prevents the compiler from generating optimized code that
- // reads value_ even if !has_value_, but only if FunctionThatDoesNothing is
- // not completely inlined; see its declaration.).
- return has_value_ ? *optional_internal::FunctionThatDoesNothing(&value_)
- : default_val;
- }
-
- // Dereference and move value.
- T MoveValue() {
- RTC_DCHECK(has_value_);
- return std::move(value_);
- }
-
- // Equality tests. Two Optionals are equal if they contain equivalent values,
- // or if they're both empty.
- friend bool operator==(const Optional& m1, const Optional& m2) {
- return m1.has_value_ && m2.has_value_ ? m1.value_ == m2.value_
- : m1.has_value_ == m2.has_value_;
- }
- friend bool operator==(const Optional& opt, const T& value) {
- return opt.has_value_ && opt.value_ == value;
- }
- friend bool operator==(const T& value, const Optional& opt) {
- return opt.has_value_ && value == opt.value_;
- }
-
- friend bool operator!=(const Optional& m1, const Optional& m2) {
- return m1.has_value_ && m2.has_value_ ? m1.value_ != m2.value_
- : m1.has_value_ != m2.has_value_;
- }
- friend bool operator!=(const Optional& opt, const T& value) {
- return !opt.has_value_ || opt.value_ != value;
- }
- friend bool operator!=(const T& value, const Optional& opt) {
- return !opt.has_value_ || value != opt.value_;
- }
-
- private:
- // Tell sanitizers that value_ shouldn't be touched.
- void PoisonValue() {
- rtc::AsanPoison(rtc::MakeArrayView(&value_, 1));
- rtc::MsanMarkUninitialized(rtc::MakeArrayView(&value_, 1));
- }
-
- // Tell sanitizers that value_ is OK to touch again.
- void UnpoisonValue() {
- rtc::AsanUnpoison(rtc::MakeArrayView(&value_, 1));
- }
-
- bool has_value_; // True iff value_ contains a live value.
- union {
- // empty_ exists only to make it possible to initialize the union, even when
- // it doesn't contain any data. If the union goes uninitialized, it may
- // trigger compiler warnings.
- char empty_;
- // By placing value_ in a union, we get to manage its construction and
- // destruction manually: the Optional constructors won't automatically
- // construct it, and the Optional destructor won't automatically destroy
- // it. Basically, this just allocates a properly sized and aligned block of
- // memory in which we can manually put a T with placement new.
- T value_;
- };
-};
-
-#ifdef UNIT_TEST
-namespace optional_internal {
-
-// Checks if there's a valid PrintTo(const T&, std::ostream*) call for T.
-template <typename T>
-struct HasPrintTo {
- private:
- struct No {};
-
- template <typename T2>
- static auto Test(const T2& obj)
- -> decltype(PrintTo(obj, std::declval<std::ostream*>()));
-
- template <typename>
- static No Test(...);
-
- public:
- static constexpr bool value =
- !std::is_same<decltype(Test<T>(std::declval<const T&>())), No>::value;
-};
-
-// Checks if there's a valid operator<<(std::ostream&, const T&) call for T.
-template <typename T>
-struct HasOstreamOperator {
- private:
- struct No {};
-
- template <typename T2>
- static auto Test(const T2& obj)
- -> decltype(std::declval<std::ostream&>() << obj);
-
- template <typename>
- static No Test(...);
-
- public:
- static constexpr bool value =
- !std::is_same<decltype(Test<T>(std::declval<const T&>())), No>::value;
-};
-
-// Prefer using PrintTo to print the object.
-template <typename T>
-typename std::enable_if<HasPrintTo<T>::value, void>::type OptionalPrintToHelper(
- const T& value,
- std::ostream* os) {
- PrintTo(value, os);
-}
-
-// Fall back to operator<<(std::ostream&, ...) if it exists.
-template <typename T>
-typename std::enable_if<HasOstreamOperator<T>::value && !HasPrintTo<T>::value,
- void>::type
-OptionalPrintToHelper(const T& value, std::ostream* os) {
- *os << value;
-}
-
-inline void OptionalPrintObjectBytes(const unsigned char* bytes,
- size_t size,
- std::ostream* os) {
- *os << "<optional with " << size << "-byte object [";
- for (size_t i = 0; i != size; ++i) {
- *os << (i == 0 ? "" : ((i & 1) ? "-" : " "));
- *os << std::hex << std::setw(2) << std::setfill('0')
- << static_cast<int>(bytes[i]);
- }
- *os << "]>";
-}
-
-// As a final back-up, just print the contents of the objcets byte-wise.
-template <typename T>
-typename std::enable_if<!HasOstreamOperator<T>::value && !HasPrintTo<T>::value,
- void>::type
-OptionalPrintToHelper(const T& value, std::ostream* os) {
- OptionalPrintObjectBytes(reinterpret_cast<const unsigned char*>(&value),
- sizeof(value), os);
-}
-
-} // namespace optional_internal
-
-// PrintTo is used by gtest to print out the results of tests. We want to ensure
-// the object contained in an Optional can be printed out if it's set, while
-// avoiding touching the object's storage if it is undefined.
-template <typename T>
-void PrintTo(const rtc::Optional<T>& opt, std::ostream* os) {
- if (opt) {
- optional_internal::OptionalPrintToHelper(*opt, os);
- } else {
- *os << "<empty optional>";
- }
-}
-
-#endif // UNIT_TEST
-
-} // namespace rtc
+#include "webrtc/api/optional.h"
#endif // WEBRTC_RTC_BASE_OPTIONAL_H_
diff --git a/rtc_base/rate_statistics.h b/rtc_base/rate_statistics.h
index 7c4daea..87f6c35 100644
--- a/rtc_base/rate_statistics.h
+++ b/rtc_base/rate_statistics.h
@@ -13,7 +13,7 @@
#include <memory>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/rtc_base/rtccertificategenerator.h b/rtc_base/rtccertificategenerator.h
index 272a5d6..4e0437c 100644
--- a/rtc_base/rtccertificategenerator.h
+++ b/rtc_base/rtccertificategenerator.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_RTC_BASE_RTCCERTIFICATEGENERATOR_H_
#define WEBRTC_RTC_BASE_RTCCERTIFICATEGENERATOR_H_
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/refcount.h"
#include "webrtc/rtc_base/rtccertificate.h"
#include "webrtc/rtc_base/scoped_ref_ptr.h"
diff --git a/rtc_base/rtccertificategenerator_unittest.cc b/rtc_base/rtccertificategenerator_unittest.cc
index df820d9..829a6ee 100644
--- a/rtc_base/rtccertificategenerator_unittest.cc
+++ b/rtc_base/rtccertificategenerator_unittest.cc
@@ -12,10 +12,10 @@
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/gunit.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread.h"
namespace rtc {
diff --git a/rtc_base/string_to_number.h b/rtc_base/string_to_number.h
index c61d1ed..93bd850 100644
--- a/rtc_base/string_to_number.h
+++ b/rtc_base/string_to_number.h
@@ -14,7 +14,7 @@
#include <string>
#include <limits>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace rtc {
diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn
index 02bbc31..cff453d 100644
--- a/rtc_tools/network_tester/BUILD.gn
+++ b/rtc_tools/network_tester/BUILD.gn
@@ -41,6 +41,7 @@
deps = [
":network_tester_config_proto",
":network_tester_packet_proto",
+ "../../api:optional",
"../../p2p",
"../../rtc_base:protobuf_utils",
"../../rtc_base:rtc_base_approved",
diff --git a/rtc_tools/network_tester/config_reader.h b/rtc_tools/network_tester/config_reader.h
index 83fbdeb..ae4348f 100644
--- a/rtc_tools/network_tester/config_reader.h
+++ b/rtc_tools/network_tester/config_reader.h
@@ -14,8 +14,8 @@
#include <fstream>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/constructormagic.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/ignore_wundef.h"
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index ff97082..086ce49 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -183,6 +183,7 @@
":common_objc",
":videotracksource_objc",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../common_video",
"../media:rtc_media_base",
"../rtc_base:rtc_base",
diff --git a/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm b/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm
index 900f284..14301ba 100644
--- a/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm
+++ b/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm
@@ -20,7 +20,7 @@
#import "RTCShader.h"
#import "WebRTC/RTCLogging.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
static const int kYTextureUnit = 0;
static const int kUTextureUnit = 1;
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 0858468..9ec0290 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -60,6 +60,7 @@
deps = [
"..:webrtc_common",
+ "../api:optional",
"../api/video_codecs:video_codecs_api",
"../call:video_stream_api",
"../common_video",
@@ -375,6 +376,7 @@
]
deps = [
"..:webrtc_common",
+ "../api:optional",
"../rtc_base:rtc_base_approved",
]
if (is_ios) {
@@ -437,6 +439,7 @@
deps = [
":fileutils",
":test_support",
+ "../api:optional",
"../rtc_base:rtc_base_approved",
"//testing/gmock",
"//testing/gtest",
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index e9d771c..6035cd9 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -207,6 +207,7 @@
]
deps = [
"../..:webrtc_common",
+ "../../api:optional",
"../../api/audio_codecs:audio_codecs_api",
"../../modules/rtp_rtcp",
"../../rtc_base:rtc_base_approved",
@@ -369,6 +370,7 @@
"audio_processing_fuzzer_configs.cc",
]
deps = [
+ "../../api:optional",
"../../modules:module_api",
"../../modules/audio_processing",
"../../rtc_base:rtc_base_approved",
diff --git a/test/fuzzers/audio_decoder_fuzzer.cc b/test/fuzzers/audio_decoder_fuzzer.cc
index ff4478d..441b12b 100644
--- a/test/fuzzers/audio_decoder_fuzzer.cc
+++ b/test/fuzzers/audio_decoder_fuzzer.cc
@@ -13,9 +13,9 @@
#include <limits>
#include "webrtc/api/audio_codecs/audio_decoder.h"
+#include "webrtc/api/optional.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {
namespace {
diff --git a/test/fuzzers/audio_processing_fuzzer_configs.cc b/test/fuzzers/audio_processing_fuzzer_configs.cc
index f9814ec..21810ad 100644
--- a/test/fuzzers/audio_processing_fuzzer_configs.cc
+++ b/test/fuzzers/audio_processing_fuzzer_configs.cc
@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/test/fuzzers/audio_processing_fuzzer.h"
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/test/testsupport/fileutils.h b/test/testsupport/fileutils.h
index 570d7b4..5ea7d31 100644
--- a/test/testsupport/fileutils.h
+++ b/test/testsupport/fileutils.h
@@ -16,7 +16,7 @@
#include <string>
#include <vector>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
namespace test {
diff --git a/test/testsupport/fileutils_unittest.cc b/test/testsupport/fileutils_unittest.cc
index bdabb84..fb780be 100644
--- a/test/testsupport/fileutils_unittest.cc
+++ b/test/testsupport/fileutils_unittest.cc
@@ -17,8 +17,8 @@
#include <list>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/pathutils.h"
#include "webrtc/test/gtest.h"
diff --git a/test/video_capturer.h b/test/video_capturer.h
index 2535370..deeb5c8 100644
--- a/test/video_capturer.h
+++ b/test/video_capturer.h
@@ -14,12 +14,12 @@
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/api/video/video_frame.h"
#include "webrtc/media/base/videoadapter.h"
#include "webrtc/media/base/videosourceinterface.h"
#include "webrtc/rtc_base/criticalsection.h"
-#include "webrtc/rtc_base/optional.h"
namespace cricket {
class VideoAdapter;
diff --git a/video/BUILD.gn b/video/BUILD.gn
index c93ef8c..7756ff4 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -55,6 +55,7 @@
deps = [
"..:webrtc_common",
+ "../api:optional",
"../api:transport_api",
"../api/video_codecs:video_codecs_api",
"../call:call_interfaces",
@@ -93,6 +94,7 @@
"video_quality_test.h",
]
deps = [
+ "../api:optional",
"../call:call_interfaces",
"../common_video",
"../logging:rtc_event_log_api",
@@ -265,6 +267,7 @@
]
deps = [
":video",
+ "../api:optional",
"../api:video_frame_api",
"../api/video_codecs:video_codecs_api",
"../call:call_interfaces",
diff --git a/video/end_to_end_tests.cc b/video/end_to_end_tests.cc
index a30b08a..644319c 100644
--- a/video/end_to_end_tests.cc
+++ b/video/end_to_end_tests.cc
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/api/video_codecs/video_encoder.h"
#include "webrtc/call/call.h"
#include "webrtc/common_video/include/frame_callback.h"
@@ -38,7 +39,6 @@
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/event.h"
#include "webrtc/rtc_base/file.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/ptr_util.h"
#include "webrtc/rtc_base/random.h"
#include "webrtc/rtc_base/rate_limiter.h"
diff --git a/video/overuse_frame_detector.h b/video/overuse_frame_detector.h
index 8bf1a78..a5eef51 100644
--- a/video/overuse_frame_detector.h
+++ b/video/overuse_frame_detector.h
@@ -14,10 +14,10 @@
#include <list>
#include <memory>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
#include "webrtc/rtc_base/constructormagic.h"
#include "webrtc/rtc_base/numerics/exp_filter.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/sequenced_task_checker.h"
#include "webrtc/rtc_base/task_queue.h"
#include "webrtc/rtc_base/thread_annotations.h"
diff --git a/video/quality_threshold.h b/video/quality_threshold.h
index ee13f8b..a142d4e 100644
--- a/video/quality_threshold.h
+++ b/video/quality_threshold.h
@@ -13,7 +13,7 @@
#include <memory>
-#include "webrtc/rtc_base/optional.h"
+#include "webrtc/api/optional.h"
namespace webrtc {
diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h
index 140cdbd..45424d9 100644
--- a/video/receive_statistics_proxy.h
+++ b/video/receive_statistics_proxy.h
@@ -14,13 +14,13 @@
#include <map>
#include <string>
+#include "webrtc/api/optional.h"
#include "webrtc/call/video_receive_stream.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/include/frame_callback.h"
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/moving_max_counter.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/rate_statistics.h"
#include "webrtc/rtc_base/ratetracker.h"
#include "webrtc/rtc_base/thread_annotations.h"
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index 2aa6295..8224377 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -18,6 +18,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/optional.h"
#include "webrtc/call/call.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
@@ -37,7 +38,6 @@
#include "webrtc/rtc_base/format_macros.h"
#include "webrtc/rtc_base/logging.h"
#include "webrtc/rtc_base/memory_usage.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/pathutils.h"
#include "webrtc/rtc_base/platform_file.h"
#include "webrtc/rtc_base/ptr_util.h"
diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc
index 6750c9e..74c9013 100644
--- a/video/video_receive_stream.cc
+++ b/video/video_receive_stream.cc
@@ -16,6 +16,7 @@
#include <string>
#include <utility>
+#include "webrtc/api/optional.h"
#include "webrtc/call/rtp_stream_receiver_controller_interface.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/h264/profile_level_id.h"
@@ -31,7 +32,6 @@
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/location.h"
#include "webrtc/rtc_base/logging.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/trace_event.h"
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/field_trial.h"
diff --git a/voice_engine/BUILD.gn b/voice_engine/BUILD.gn
index 9862579..809333b 100644
--- a/voice_engine/BUILD.gn
+++ b/voice_engine/BUILD.gn
@@ -139,6 +139,7 @@
"../api:audio_mixer_api",
"../api:call_api",
"../api:libjingle_peerconnection_api",
+ "../api:optional",
"../api:transport_api",
"../api/audio_codecs:audio_codecs_api",
"../api/audio_codecs:builtin_audio_decoder_factory",
diff --git a/voice_engine/channel.h b/voice_engine/channel.h
index 884845e..0d71a41 100644
--- a/voice_engine/channel.h
+++ b/voice_engine/channel.h
@@ -16,6 +16,7 @@
#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/api/audio_codecs/audio_encoder.h"
#include "webrtc/api/call/audio_sink.h"
+#include "webrtc/api/optional.h"
#include "webrtc/common_audio/resampler/include/push_resampler.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/acm2/codec_manager.h"
@@ -29,7 +30,6 @@
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/event.h"
-#include "webrtc/rtc_base/optional.h"
#include "webrtc/rtc_base/thread_checker.h"
#include "webrtc/voice_engine/audio_level.h"
#include "webrtc/voice_engine/file_player.h"
diff --git a/voice_engine/transport_feedback_packet_loss_tracker.h b/voice_engine/transport_feedback_packet_loss_tracker.h
index 987ba25..8168216 100644
--- a/voice_engine/transport_feedback_packet_loss_tracker.h
+++ b/voice_engine/transport_feedback_packet_loss_tracker.h
@@ -13,8 +13,8 @@
#include <map>
+#include "webrtc/api/optional.h"
#include "webrtc/modules/include/module_common_types.h"
-#include "webrtc/rtc_base/optional.h"
namespace webrtc {