diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn index 2e3d77a03a..86a63e4dee 100644 --- a/webrtc/api/BUILD.gn +++ b/webrtc/api/BUILD.gn @@ -207,6 +207,17 @@ rtc_source_set("array_view") { ] } +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 @@ if (rtc_include_tests) { } sources = [ "array_view_unittest.cc", + "optional_unittest.cc", "ortc/mediadescription_unittest.cc", "ortc/sessiondescription_unittest.cc", "rtcerror_unittest.cc", @@ -280,6 +292,7 @@ if (rtc_include_tests) { deps = [ ":array_view", ":libjingle_peerconnection_api", + ":optional", ":ortc_api", "../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_tests_utils", diff --git a/webrtc/api/audio_codecs/BUILD.gn b/webrtc/api/audio_codecs/BUILD.gn index 29238e65fe..04a5238f84 100644 --- a/webrtc/api/audio_codecs/BUILD.gn +++ b/webrtc/api/audio_codecs/BUILD.gn @@ -27,6 +27,7 @@ rtc_source_set("audio_codecs_api") { ] deps = [ "..:array_view", + "..:optional", "../..:webrtc_common", "../../rtc_base:rtc_base_approved", ] diff --git a/webrtc/api/audio_codecs/L16/BUILD.gn b/webrtc/api/audio_codecs/L16/BUILD.gn index db61713c5d..8f06a8f332 100644 --- a/webrtc/api/audio_codecs/L16/BUILD.gn +++ b/webrtc/api/audio_codecs/L16/BUILD.gn @@ -19,6 +19,7 @@ rtc_static_library("audio_encoder_L16") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", @@ -32,6 +33,7 @@ rtc_static_library("audio_decoder_L16") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/L16/audio_decoder_L16.h b/webrtc/api/audio_codecs/L16/audio_decoder_L16.h index 478da16abe..39b389a0ec 100644 --- a/webrtc/api/audio_codecs/L16/audio_decoder_L16.h +++ b/webrtc/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/webrtc/api/audio_codecs/L16/audio_encoder_L16.h b/webrtc/api/audio_codecs/L16/audio_encoder_L16.h index e2e4019f21..3ac0423af9 100644 --- a/webrtc/api/audio_codecs/L16/audio_encoder_L16.h +++ b/webrtc/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/webrtc/api/audio_codecs/audio_decoder.h b/webrtc/api/audio_codecs/audio_decoder.h index 0d15e6d29f..2d850fd461 100644 --- a/webrtc/api/audio_codecs/audio_decoder.h +++ b/webrtc/api/audio_codecs/audio_decoder.h @@ -15,9 +15,9 @@ #include #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/webrtc/api/audio_codecs/audio_encoder.h b/webrtc/api/audio_codecs/audio_encoder.h index 37a03d0317..7406d7d653 100644 --- a/webrtc/api/audio_codecs/audio_encoder.h +++ b/webrtc/api/audio_codecs/audio_encoder.h @@ -17,9 +17,9 @@ #include #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/webrtc/api/audio_codecs/audio_format.h b/webrtc/api/audio_codecs/audio_format.h index c442972788..ab825bb960 100644 --- a/webrtc/api/audio_codecs/audio_format.h +++ b/webrtc/api/audio_codecs/audio_format.h @@ -16,7 +16,7 @@ #include #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/api/audio_codecs/g711/BUILD.gn b/webrtc/api/audio_codecs/g711/BUILD.gn index fbf9248683..aa86490a73 100644 --- a/webrtc/api/audio_codecs/g711/BUILD.gn +++ b/webrtc/api/audio_codecs/g711/BUILD.gn @@ -19,6 +19,7 @@ rtc_static_library("audio_encoder_g711") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", @@ -32,6 +33,7 @@ rtc_static_library("audio_decoder_g711") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/g711/audio_decoder_g711.h b/webrtc/api/audio_codecs/g711/audio_decoder_g711.h index b9650c95a6..2824c32fd1 100644 --- a/webrtc/api/audio_codecs/g711/audio_decoder_g711.h +++ b/webrtc/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/webrtc/api/audio_codecs/g711/audio_encoder_g711.h b/webrtc/api/audio_codecs/g711/audio_encoder_g711.h index a22650dd44..57501002c1 100644 --- a/webrtc/api/audio_codecs/g711/audio_encoder_g711.h +++ b/webrtc/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/webrtc/api/audio_codecs/g722/BUILD.gn b/webrtc/api/audio_codecs/g722/BUILD.gn index f3108e7b21..5af7e5c223 100644 --- a/webrtc/api/audio_codecs/g722/BUILD.gn +++ b/webrtc/api/audio_codecs/g722/BUILD.gn @@ -26,6 +26,7 @@ rtc_static_library("audio_encoder_g722") { deps = [ ":audio_encoder_g722_config", "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", @@ -39,6 +40,7 @@ rtc_static_library("audio_decoder_g722") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/g722/audio_decoder_g722.h b/webrtc/api/audio_codecs/g722/audio_decoder_g722.h index 9b063c2bf0..cf0dfa9602 100644 --- a/webrtc/api/audio_codecs/g722/audio_decoder_g722.h +++ b/webrtc/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/webrtc/api/audio_codecs/g722/audio_encoder_g722.h b/webrtc/api/audio_codecs/g722/audio_encoder_g722.h index 458a6c5a79..37cb968ee3 100644 --- a/webrtc/api/audio_codecs/g722/audio_encoder_g722.h +++ b/webrtc/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/webrtc/api/audio_codecs/ilbc/BUILD.gn b/webrtc/api/audio_codecs/ilbc/BUILD.gn index ab9681a3e5..0f5f80dfe2 100644 --- a/webrtc/api/audio_codecs/ilbc/BUILD.gn +++ b/webrtc/api/audio_codecs/ilbc/BUILD.gn @@ -26,6 +26,7 @@ rtc_static_library("audio_encoder_ilbc") { deps = [ ":audio_encoder_ilbc_config", "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", @@ -39,6 +40,7 @@ rtc_static_library("audio_decoder_ilbc") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h index 65a67e2311..343308df9a 100644 --- a/webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h +++ b/webrtc/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/webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h index 6f7a9f6c62..a30d1092e8 100644 --- a/webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h +++ b/webrtc/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/webrtc/api/audio_codecs/isac/BUILD.gn b/webrtc/api/audio_codecs/isac/BUILD.gn index 3340e28a06..b22eb95525 100644 --- a/webrtc/api/audio_codecs/isac/BUILD.gn +++ b/webrtc/api/audio_codecs/isac/BUILD.gn @@ -19,6 +19,7 @@ rtc_static_library("audio_encoder_isac_fix") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", @@ -32,6 +33,7 @@ rtc_static_library("audio_decoder_isac_fix") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", @@ -45,6 +47,7 @@ rtc_static_library("audio_encoder_isac_float") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", @@ -58,6 +61,7 @@ rtc_static_library("audio_decoder_isac_float") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/isac/audio_decoder_isac_fix.h b/webrtc/api/audio_codecs/isac/audio_decoder_isac_fix.h index 71e7cc41f2..7662002a84 100644 --- a/webrtc/api/audio_codecs/isac/audio_decoder_isac_fix.h +++ b/webrtc/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/webrtc/api/audio_codecs/isac/audio_decoder_isac_float.h b/webrtc/api/audio_codecs/isac/audio_decoder_isac_float.h index c0dc880dae..f0232e9209 100644 --- a/webrtc/api/audio_codecs/isac/audio_decoder_isac_float.h +++ b/webrtc/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/webrtc/api/audio_codecs/isac/audio_encoder_isac_fix.h b/webrtc/api/audio_codecs/isac/audio_encoder_isac_fix.h index 5f0e8fe4b5..ce4a1d01b3 100644 --- a/webrtc/api/audio_codecs/isac/audio_encoder_isac_fix.h +++ b/webrtc/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/webrtc/api/audio_codecs/isac/audio_encoder_isac_float.h b/webrtc/api/audio_codecs/isac/audio_encoder_isac_float.h index 35bc94b464..244e59b11d 100644 --- a/webrtc/api/audio_codecs/isac/audio_encoder_isac_float.h +++ b/webrtc/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/webrtc/api/audio_codecs/opus/BUILD.gn b/webrtc/api/audio_codecs/opus/BUILD.gn index 658d151a1d..faa5956dc5 100644 --- a/webrtc/api/audio_codecs/opus/BUILD.gn +++ b/webrtc/api/audio_codecs/opus/BUILD.gn @@ -18,6 +18,7 @@ rtc_static_library("audio_encoder_opus_config") { "audio_encoder_opus_config.h", ] deps = [ + "../..:optional", "../../../rtc_base:rtc_base_approved", ] defines = [] @@ -51,6 +52,7 @@ rtc_static_library("audio_decoder_opus") { ] deps = [ "..:audio_codecs_api", + "../..:optional", "../../..:webrtc_common", "../../../modules/audio_coding:webrtc_opus", "../../../rtc_base:rtc_base_approved", diff --git a/webrtc/api/audio_codecs/opus/audio_decoder_opus.h b/webrtc/api/audio_codecs/opus/audio_decoder_opus.h index 6a9d6da57a..272503da94 100644 --- a/webrtc/api/audio_codecs/opus/audio_decoder_opus.h +++ b/webrtc/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/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.h b/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.h index c3fe17b39c..d07f7848e7 100644 --- a/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.h +++ b/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.h @@ -15,7 +15,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/api/mediaconstraintsinterface.h b/webrtc/api/mediaconstraintsinterface.h index 72fdd97866..eb89b3ee52 100644 --- a/webrtc/api/mediaconstraintsinterface.h +++ b/webrtc/api/mediaconstraintsinterface.h @@ -23,8 +23,8 @@ #include #include +#include "webrtc/api/optional.h" #include "webrtc/api/peerconnectioninterface.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc { diff --git a/webrtc/api/mediastreaminterface.h b/webrtc/api/mediastreaminterface.h index aaf5b62aa4..5d6544716d 100644 --- a/webrtc/api/mediastreaminterface.h +++ b/webrtc/api/mediastreaminterface.h @@ -22,8 +22,8 @@ #include #include +#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/webrtc/rtc_base/optional.cc b/webrtc/api/optional.cc similarity index 85% rename from webrtc/rtc_base/optional.cc rename to webrtc/api/optional.cc index 4b41a2d7fb..ec8696661f 100644 --- a/webrtc/rtc_base/optional.cc +++ b/webrtc/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/webrtc/api/optional.h b/webrtc/api/optional.h new file mode 100644 index 0000000000..de1ec764bf --- /dev/null +++ b/webrtc/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 +#include +#include + +#ifdef UNIT_TEST +#include +#include +#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 +inline T* FunctionThatDoesNothing(T* x) { + return reinterpret_cast( + FunctionThatDoesNothingImpl(reinterpret_cast(x))); +} + +#else + +template +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 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 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 (the index where it found the element, or +// nothing if it didn't find it); and a function that parses numbers might +// return Optional (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 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 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, const Optional& 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 +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 + void emplace(Args&&... args) { + if (has_value_) + value_.~T(); + else + UnpoisonValue(); + new (&value_) T(std::forward(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 +struct HasPrintTo { + private: + struct No {}; + + template + static auto Test(const T2& obj) + -> decltype(PrintTo(obj, std::declval())); + + template + static No Test(...); + + public: + static constexpr bool value = + !std::is_same(std::declval())), No>::value; +}; + +// Checks if there's a valid operator<<(std::ostream&, const T&) call for T. +template +struct HasOstreamOperator { + private: + struct No {}; + + template + static auto Test(const T2& obj) + -> decltype(std::declval() << obj); + + template + static No Test(...); + + public: + static constexpr bool value = + !std::is_same(std::declval())), No>::value; +}; + +// Prefer using PrintTo to print the object. +template +typename std::enable_if::value, void>::type OptionalPrintToHelper( + const T& value, + std::ostream* os) { + PrintTo(value, os); +} + +// Fall back to operator<<(std::ostream&, ...) if it exists. +template +typename std::enable_if::value && !HasPrintTo::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 << "(bytes[i]); + } + *os << "]>"; +} + +// As a final back-up, just print the contents of the objcets byte-wise. +template +typename std::enable_if::value && !HasPrintTo::value, + void>::type +OptionalPrintToHelper(const T& value, std::ostream* os) { + OptionalPrintObjectBytes(reinterpret_cast(&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 +void PrintTo(const rtc::Optional& opt, std::ostream* os) { + if (opt) { + optional_internal::OptionalPrintToHelper(*opt, os); + } else { + *os << ""; + } +} + +#endif // UNIT_TEST + +} // namespace rtc + +#endif // WEBRTC_API_OPTIONAL_H_ diff --git a/webrtc/rtc_base/optional_unittest.cc b/webrtc/api/optional_unittest.cc similarity index 98% rename from webrtc/rtc_base/optional_unittest.cc rename to webrtc/api/optional_unittest.cc index 8f2f7fd1f0..f8f9cf300a 100644 --- a/webrtc/rtc_base/optional_unittest.cc +++ b/webrtc/api/optional_unittest.cc @@ -14,8 +14,8 @@ #include #include +#include "webrtc/api/optional.h" #include "webrtc/rtc_base/gunit.h" -#include "webrtc/rtc_base/optional.h" namespace rtc { @@ -37,14 +37,12 @@ void PrintTo(const MyPrintableType& mpt, std::ostream* os) { *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/webrtc/api/ortc/mediadescription.h b/webrtc/api/ortc/mediadescription.h index efee6629a1..d638dfc433 100644 --- a/webrtc/api/ortc/mediadescription.h +++ b/webrtc/api/ortc/mediadescription.h @@ -15,8 +15,8 @@ #include #include +#include "webrtc/api/optional.h" #include "webrtc/media/base/cryptoparams.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc { diff --git a/webrtc/api/ortc/rtptransportinterface.h b/webrtc/api/ortc/rtptransportinterface.h index 165daada6b..1fdc12caab 100644 --- a/webrtc/api/ortc/rtptransportinterface.h +++ b/webrtc/api/ortc/rtptransportinterface.h @@ -13,10 +13,10 @@ #include +#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/webrtc/api/rtpparameters.h b/webrtc/api/rtpparameters.h index 46f71395ce..ce61b15f75 100644 --- a/webrtc/api/rtpparameters.h +++ b/webrtc/api/rtpparameters.h @@ -16,7 +16,7 @@ #include #include "webrtc/api/mediatypes.h" -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/api/video_codecs/BUILD.gn b/webrtc/api/video_codecs/BUILD.gn index 7fad43d8f0..be7194e283 100644 --- a/webrtc/api/video_codecs/BUILD.gn +++ b/webrtc/api/video_codecs/BUILD.gn @@ -20,6 +20,7 @@ rtc_source_set("video_codecs_api") { ] deps = [ + "..:optional", "..:video_frame_api", "../..:webrtc_common", "../../common_video", diff --git a/webrtc/api/video_codecs/video_encoder.h b/webrtc/api/video_codecs/video_encoder.h index 7a319d7216..4ec6e45f00 100644 --- a/webrtc/api/video_codecs/video_encoder.h +++ b/webrtc/api/video_codecs/video_encoder.h @@ -15,11 +15,11 @@ #include #include +#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/webrtc/audio/BUILD.gn b/webrtc/audio/BUILD.gn index 2c62584ece..42b74ffcd6 100644 --- a/webrtc/audio/BUILD.gn +++ b/webrtc/audio/BUILD.gn @@ -37,6 +37,7 @@ rtc_static_library("audio") { "..: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/webrtc/audio/time_interval.h b/webrtc/audio/time_interval.h index 069127d641..448184359f 100644 --- a/webrtc/audio/time_interval.h +++ b/webrtc/audio/time_interval.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/call/BUILD.gn b/webrtc/call/BUILD.gn index 580d606f59..706d502b21 100644 --- a/webrtc/call/BUILD.gn +++ b/webrtc/call/BUILD.gn @@ -26,6 +26,7 @@ rtc_source_set("call_interfaces") { "..: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 @@ rtc_source_set("rtp_receiver") { ":rtp_interfaces", "..:webrtc_common", "../api:array_view", + "../api:optional", "../modules/rtp_rtcp", "../rtc_base:rtc_base_approved", ] @@ -114,6 +116,7 @@ rtc_static_library("call") { ":rtp_sender", ":video_stream_api", "..:webrtc_common", + "../api:optional", "../api:transport_api", "../audio", "../logging:rtc_event_log_api", @@ -144,6 +147,7 @@ rtc_source_set("video_stream_api") { ":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/webrtc/call/audio_receive_stream.h b/webrtc/call/audio_receive_stream.h index 018ad35fb7..6de62dffa6 100644 --- a/webrtc/call/audio_receive_stream.h +++ b/webrtc/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/webrtc/call/audio_send_stream.h b/webrtc/call/audio_send_stream.h index 8720249c4b..4f7f8c0f84 100644 --- a/webrtc/call/audio_send_stream.h +++ b/webrtc/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/webrtc/call/call.cc b/webrtc/call/call.cc index edb9bf3106..343b3ef41f 100644 --- a/webrtc/call/call.cc +++ b/webrtc/call/call.cc @@ -16,6 +16,7 @@ #include #include +#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/webrtc/call/rtp_rtcp_demuxer_helper.h b/webrtc/call/rtp_rtcp_demuxer_helper.h index 02d08aacba..0a4767d84a 100644 --- a/webrtc/call/rtp_rtcp_demuxer_helper.h +++ b/webrtc/call/rtp_rtcp_demuxer_helper.h @@ -16,8 +16,8 @@ #include #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/webrtc/call/syncable.h b/webrtc/call/syncable.h index 734d20ec06..2692a8a09c 100644 --- a/webrtc/call/syncable.h +++ b/webrtc/call/syncable.h @@ -16,7 +16,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/call/video_config.h b/webrtc/call/video_config.h index cdff513263..4a98d01405 100644 --- a/webrtc/call/video_config.h +++ b/webrtc/call/video_config.h @@ -14,9 +14,9 @@ #include #include +#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/webrtc/common_audio/BUILD.gn b/webrtc/common_audio/BUILD.gn index a51a83c3a7..8cfd642d97 100644 --- a/webrtc/common_audio/BUILD.gn +++ b/webrtc/common_audio/BUILD.gn @@ -63,6 +63,7 @@ rtc_static_library("common_audio") { deps = [ ":sinc_resampler", "..:webrtc_common", + "../api:optional", "../rtc_base:gtest_prod", "../rtc_base:rtc_base_approved", "../system_wrappers", diff --git a/webrtc/common_audio/smoothing_filter.h b/webrtc/common_audio/smoothing_filter.h index c59842ec8c..15ea3d1e55 100644 --- a/webrtc/common_audio/smoothing_filter.h +++ b/webrtc/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/webrtc/common_types.h b/webrtc/common_types.h index 229d858c92..49b42ac376 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -18,12 +18,12 @@ #include #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/webrtc/common_video/BUILD.gn b/webrtc/common_video/BUILD.gn index 93906ef51b..f0e262f23b 100644 --- a/webrtc/common_video/BUILD.gn +++ b/webrtc/common_video/BUILD.gn @@ -57,6 +57,7 @@ rtc_static_library("common_video") { deps = [ "..:webrtc_common", + "../api:optional", "../media:rtc_h264_profile_id", "../modules:module_api", "../rtc_base:rtc_base", diff --git a/webrtc/common_video/h264/h264_bitstream_parser.h b/webrtc/common_video/h264/h264_bitstream_parser.h index 136c90317f..145700f509 100644 --- a/webrtc/common_video/h264/h264_bitstream_parser.h +++ b/webrtc/common_video/h264/h264_bitstream_parser.h @@ -13,9 +13,9 @@ #include #include +#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/webrtc/common_video/h264/pps_parser.h b/webrtc/common_video/h264/pps_parser.h index 941b99e71e..b981d22a3b 100644 --- a/webrtc/common_video/h264/pps_parser.h +++ b/webrtc/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/webrtc/common_video/h264/sps_parser.h b/webrtc/common_video/h264/sps_parser.h index ea14f79202..77ad25d83f 100644 --- a/webrtc/common_video/h264/sps_parser.h +++ b/webrtc/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/webrtc/common_video/h264/sps_vui_rewriter.h b/webrtc/common_video/h264/sps_vui_rewriter.h index 6eff1abcea..7875117722 100644 --- a/webrtc/common_video/h264/sps_vui_rewriter.h +++ b/webrtc/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/webrtc/common_video/video_render_frames.h b/webrtc/common_video/video_render_frames.h index 4f043e16ba..fe4d4f0b07 100644 --- a/webrtc/common_video/video_render_frames.h +++ b/webrtc/common_video/video_render_frames.h @@ -15,8 +15,8 @@ #include +#include "webrtc/api/optional.h" #include "webrtc/api/video/video_frame.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc { diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn index 0ed8fc2663..25aa1e07a7 100644 --- a/webrtc/media/BUILD.gn +++ b/webrtc/media/BUILD.gn @@ -45,6 +45,7 @@ rtc_source_set("rtc_h264_profile_id") { deps = [ "..:webrtc_common", + "../api:optional", "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", ] @@ -227,6 +228,7 @@ rtc_static_library("rtc_audio_video") { "..: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/webrtc/media/base/h264_profile_level_id.h b/webrtc/media/base/h264_profile_level_id.h index 7b1d8c5c80..acbb84e194 100644 --- a/webrtc/media/base/h264_profile_level_id.h +++ b/webrtc/media/base/h264_profile_level_id.h @@ -14,8 +14,8 @@ #include #include +#include "webrtc/api/optional.h" #include "webrtc/common_types.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc { namespace H264 { diff --git a/webrtc/media/base/mediachannel.h b/webrtc/media/base/mediachannel.h index 5aae309feb..ef245a133a 100644 --- a/webrtc/media/base/mediachannel.h +++ b/webrtc/media/base/mediachannel.h @@ -15,6 +15,7 @@ #include #include +#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/webrtc/media/base/videoadapter.cc b/webrtc/media/base/videoadapter.cc index 73a5638bb3..45868b67d9 100644 --- a/webrtc/media/base/videoadapter.cc +++ b/webrtc/media/base/videoadapter.cc @@ -15,12 +15,12 @@ #include #include +#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/webrtc/media/base/videoadapter.h b/webrtc/media/base/videoadapter.h index 135f411b0a..61de4b5980 100644 --- a/webrtc/media/base/videoadapter.h +++ b/webrtc/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/webrtc/media/base/videosourceinterface.h b/webrtc/media/base/videosourceinterface.h index 24b3bed5b6..551a6ea12b 100644 --- a/webrtc/media/base/videosourceinterface.h +++ b/webrtc/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/webrtc/media/engine/payload_type_mapper.h b/webrtc/media/engine/payload_type_mapper.h index 1a74f21008..128f557ae7 100644 --- a/webrtc/media/engine/payload_type_mapper.h +++ b/webrtc/media/engine/payload_type_mapper.h @@ -15,8 +15,8 @@ #include #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/webrtc/media/engine/webrtcvideoengine.h b/webrtc/media/engine/webrtcvideoengine.h index 3224d0027f..7710c043d1 100644 --- a/webrtc/media/engine/webrtcvideoengine.h +++ b/webrtc/media/engine/webrtcvideoengine.h @@ -18,6 +18,7 @@ #include #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/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 359bd8c05b..dd8e54b68b 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -36,6 +36,7 @@ rtc_source_set("module_api") { ] deps = [ "..:webrtc_common", + "../api:optional", "../api:video_frame_api", "../rtc_base:rtc_base_approved", ] diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index 8d92c46719..4003db1b35 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -47,6 +47,7 @@ rtc_static_library("audio_format_conversion") { deps = [ "../..:webrtc_common", "../../api:array_view", + "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../../rtc_base:rtc_base_approved", ] @@ -61,6 +62,7 @@ rtc_static_library("rent_a_codec") { ] deps = [ "../../api:array_view", + "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../..:webrtc_common", "../../rtc_base:protobuf_utils", @@ -132,6 +134,7 @@ rtc_static_library("audio_coding") { ":neteq", ":rent_a_codec", "../../rtc_base:rtc_base_approved", + "../../api:optional", "../../logging:rtc_event_log_api", ] defines = audio_coding_defines @@ -814,6 +817,7 @@ rtc_static_library("webrtc_opus") { 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 @@ rtc_static_library("audio_network_adaptor") { deps = [ "../..:webrtc_common", + "../../api:optional", "../../common_audio", "../../logging:rtc_event_log_api", "../../rtc_base:protobuf_utils", @@ -934,6 +939,7 @@ rtc_source_set("neteq_decoder_enum") { "neteq/neteq_decoder_enum.h", ] deps = [ + "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../../rtc_base:rtc_base_approved", ] @@ -1023,6 +1029,7 @@ rtc_static_library("neteq") { ":pcm16b", "..:module_api", "../..:webrtc_common", + "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../../common_audio", "../../rtc_base:gtest_prod", @@ -1082,6 +1089,7 @@ rtc_source_set("neteq_tools_minimal") { ":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 @@ rtc_source_set("neteq_tools") { 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 @@ if (rtc_include_tests) { ":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 @@ if (rtc_include_tests) { ":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 @@ if (rtc_include_tests) { ":audio_format_conversion", "..:module_api", "../../:webrtc_common", + "../../api:optional", "../../rtc_base:rtc_base_approved", "../../system_wrappers", "../../system_wrappers:system_wrappers_default", diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.h b/webrtc/modules/audio_coding/acm2/acm_receiver.h index 5acb013288..ebeecec7f9 100644 --- a/webrtc/modules/audio_coding/acm2/acm_receiver.h +++ b/webrtc/modules/audio_coding/acm2/acm_receiver.h @@ -17,6 +17,7 @@ #include #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/webrtc/modules/audio_coding/acm2/codec_manager.h b/webrtc/modules/audio_coding/acm2/codec_manager.h index 3d45b335bc..b5c8d3e53c 100644 --- a/webrtc/modules/audio_coding/acm2/codec_manager.h +++ b/webrtc/modules/audio_coding/acm2/codec_manager.h @@ -13,12 +13,12 @@ #include +#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/webrtc/modules/audio_coding/acm2/rent_a_codec.h b/webrtc/modules/audio_coding/acm2/rent_a_codec.h index 3dd9dc8209..6dcf793d04 100644 --- a/webrtc/modules/audio_coding/acm2/rent_a_codec.h +++ b/webrtc/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/webrtc/modules/audio_coding/audio_network_adaptor/controller.h b/webrtc/modules/audio_coding/audio_network_adaptor/controller.h index ab9cfb706f..38c2c2122a 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/controller.h +++ b/webrtc/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/webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h b/webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h index 6d03730a17..fa742e69f6 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h +++ b/webrtc/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/webrtc/modules/audio_coding/codecs/audio_format_conversion.cc b/webrtc/modules/audio_coding/codecs/audio_format_conversion.cc index 17f8d9623e..1e53bf35fc 100644 --- a/webrtc/modules/audio_coding/codecs/audio_format_conversion.cc +++ b/webrtc/modules/audio_coding/codecs/audio_format_conversion.cc @@ -13,8 +13,8 @@ #include #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/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h b/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h index 387b34b5da..66f021a87c 100644 --- a/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h +++ b/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h @@ -14,9 +14,9 @@ #include #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/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h index f78cf1e39c..588f268e7f 100644 --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h +++ b/webrtc/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/webrtc/modules/audio_coding/include/audio_coding_module.h b/webrtc/modules/audio_coding/include/audio_coding_module.h index 44eec75666..4ceade25d0 100644 --- a/webrtc/modules/audio_coding/include/audio_coding_module.h +++ b/webrtc/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/webrtc/modules/audio_coding/neteq/include/neteq.h b/webrtc/modules/audio_coding/neteq/include/neteq.h index 56c30e5f2d..9f5af7cea5 100644 --- a/webrtc/modules/audio_coding/neteq/include/neteq.h +++ b/webrtc/modules/audio_coding/neteq/include/neteq.h @@ -16,10 +16,10 @@ #include #include +#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/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h b/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h index a36034ccdf..e108ccfc41 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h +++ b/webrtc/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/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h index f4b014adac..fea1682f74 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.h +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h @@ -14,6 +14,7 @@ #include #include +#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/webrtc/modules/audio_coding/neteq/packet_buffer.h b/webrtc/modules/audio_coding/neteq/packet_buffer.h index afd5f04454..5c2499c6b9 100644 --- a/webrtc/modules/audio_coding/neteq/packet_buffer.h +++ b/webrtc/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/webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h b/webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h index d293ecde21..09c2e789f0 100644 --- a/webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h +++ b/webrtc/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/webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h b/webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h index b652bf2290..e142a3b0c3 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h @@ -16,9 +16,9 @@ #include #include +#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/webrtc/modules/audio_coding/neteq/tools/neteq_input.h b/webrtc/modules/audio_coding/neteq/tools/neteq_input.h index 1e0889336a..08f554bd4e 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_input.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_input.h @@ -15,11 +15,11 @@ #include #include +#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/webrtc/modules/audio_coding/test/PCMFile.h b/webrtc/modules/audio_coding/test/PCMFile.h index fd1c53a10b..3576dc67d8 100644 --- a/webrtc/modules/audio_coding/test/PCMFile.h +++ b/webrtc/modules/audio_coding/test/PCMFile.h @@ -16,8 +16,8 @@ #include +#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/webrtc/modules/audio_device/BUILD.gn b/webrtc/modules/audio_device/BUILD.gn index b9716aea94..2db993b7b3 100644 --- a/webrtc/modules/audio_device/BUILD.gn +++ b/webrtc/modules/audio_device/BUILD.gn @@ -283,6 +283,7 @@ if (rtc_include_tests) { ":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/webrtc/modules/audio_device/audio_device_unittest.cc b/webrtc/modules/audio_device/audio_device_unittest.cc index 67e9f4732f..c65f139192 100644 --- a/webrtc/modules/audio_device/audio_device_unittest.cc +++ b/webrtc/modules/audio_device/audio_device_unittest.cc @@ -13,6 +13,7 @@ #include #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/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index e0719b4315..4887250d88 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -238,6 +238,7 @@ rtc_static_library("audio_processing") { "..: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 @@ if (rtc_include_tests) { "..: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 @@ if (rtc_include_tests) { ":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 @@ if (rtc_include_tests) { ":audio_processing", "..:module_api", "../../api:array_view", + "../../api:optional", "../../common_audio", "../../rtc_base:rtc_base_approved", "../../system_wrappers:system_wrappers", diff --git a/webrtc/modules/audio_processing/aec3/aec_state.h b/webrtc/modules/audio_processing/aec3/aec_state.h index 8dc45304f1..38ed3b047b 100644 --- a/webrtc/modules/audio_processing/aec3/aec_state.h +++ b/webrtc/modules/audio_processing/aec3/aec_state.h @@ -16,6 +16,7 @@ #include #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/webrtc/modules/audio_processing/aec3/block_processor.cc b/webrtc/modules/audio_processing/aec3/block_processor.cc index 536335e8a2..7bb9e15129 100644 --- a/webrtc/modules/audio_processing/aec3/block_processor.cc +++ b/webrtc/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/webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h b/webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h index 4b536b99a9..7ff1cb33a5 100644 --- a/webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h +++ b/webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h @@ -13,13 +13,13 @@ #include +#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/webrtc/modules/audio_processing/aec3/echo_remover.h b/webrtc/modules/audio_processing/aec3/echo_remover.h index ce43fa8a72..8a28729ba6 100644 --- a/webrtc/modules/audio_processing/aec3/echo_remover.h +++ b/webrtc/modules/audio_processing/aec3/echo_remover.h @@ -13,10 +13,10 @@ #include +#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/webrtc/modules/audio_processing/aec3/matched_filter.h b/webrtc/modules/audio_processing/aec3/matched_filter.h index 0702a124e8..a200af1261 100644 --- a/webrtc/modules/audio_processing/aec3/matched_filter.h +++ b/webrtc/modules/audio_processing/aec3/matched_filter.h @@ -15,10 +15,10 @@ #include #include +#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/webrtc/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/webrtc/modules/audio_processing/aec3/matched_filter_lag_aggregator.h index 983ae3b7f3..d490f0d45d 100644 --- a/webrtc/modules/audio_processing/aec3/matched_filter_lag_aggregator.h +++ b/webrtc/modules/audio_processing/aec3/matched_filter_lag_aggregator.h @@ -13,9 +13,9 @@ #include +#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/webrtc/modules/audio_processing/aec3/mock/mock_echo_remover.h b/webrtc/modules/audio_processing/aec3/mock/mock_echo_remover.h index 008fca669f..8d2aca992d 100644 --- a/webrtc/modules/audio_processing/aec3/mock/mock_echo_remover.h +++ b/webrtc/modules/audio_processing/aec3/mock/mock_echo_remover.h @@ -13,10 +13,10 @@ #include +#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/webrtc/modules/audio_processing/aec3/mock/mock_render_delay_controller.h b/webrtc/modules/audio_processing/aec3/mock/mock_render_delay_controller.h index 46a59dc201..64daef5a45 100644 --- a/webrtc/modules/audio_processing/aec3/mock/mock_render_delay_controller.h +++ b/webrtc/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/webrtc/modules/audio_processing/aec3/render_delay_controller.h b/webrtc/modules/audio_processing/aec3/render_delay_controller.h index c1e2229d66..e840178cb6 100644 --- a/webrtc/modules/audio_processing/aec3/render_delay_controller.h +++ b/webrtc/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/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h b/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h index 0cef897c34..625f30f04a 100644 --- a/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h +++ b/webrtc/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/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc b/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc index 5f24fe3d7f..bb39e77471 100644 --- a/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc +++ b/webrtc/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/webrtc/modules/audio_processing/aec3/render_signal_analyzer.h b/webrtc/modules/audio_processing/aec3/render_signal_analyzer.h index b0b56cde9e..48ce81e9fc 100644 --- a/webrtc/modules/audio_processing/aec3/render_signal_analyzer.h +++ b/webrtc/modules/audio_processing/aec3/render_signal_analyzer.h @@ -14,10 +14,10 @@ #include #include +#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/webrtc/modules/audio_processing/beamformer/array_util.h b/webrtc/modules/audio_processing/beamformer/array_util.h index bfb9dfdb65..aa18e71931 100644 --- a/webrtc/modules/audio_processing/beamformer/array_util.h +++ b/webrtc/modules/audio_processing/beamformer/array_util.h @@ -14,7 +14,7 @@ #include #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/modules/audio_processing/echo_detector/circular_buffer.h b/webrtc/modules/audio_processing/echo_detector/circular_buffer.h index 9fadb0d66f..cf58e33840 100644 --- a/webrtc/modules/audio_processing/echo_detector/circular_buffer.h +++ b/webrtc/modules/audio_processing/echo_detector/circular_buffer.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/modules/audio_processing/gain_control_impl.cc b/webrtc/modules/audio_processing/gain_control_impl.cc index e5760183f0..f882d10cd6 100644 --- a/webrtc/modules/audio_processing/gain_control_impl.cc +++ b/webrtc/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/webrtc/modules/audio_processing/level_controller/level_controller.h b/webrtc/modules/audio_processing/level_controller/level_controller.h index e04620f19c..9aa50852df 100644 --- a/webrtc/modules/audio_processing/level_controller/level_controller.h +++ b/webrtc/modules/audio_processing/level_controller/level_controller.h @@ -14,6 +14,7 @@ #include #include +#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/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc b/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc index b7571e92d5..d37b58011b 100644 --- a/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc +++ b/webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc @@ -11,12 +11,12 @@ #include #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/webrtc/modules/audio_processing/rms_level.h b/webrtc/modules/audio_processing/rms_level.h index 4ce28a4957..e0df754f56 100644 --- a/webrtc/modules/audio_processing/rms_level.h +++ b/webrtc/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/webrtc/modules/audio_processing/test/audio_processing_simulator.h b/webrtc/modules/audio_processing/test/audio_processing_simulator.h index 1ae465cbef..8a2295f0cd 100644 --- a/webrtc/modules/audio_processing/test/audio_processing_simulator.h +++ b/webrtc/modules/audio_processing/test/audio_processing_simulator.h @@ -17,11 +17,11 @@ #include #include +#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/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn index 1f24c0982a..1d492bf644 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -65,6 +65,7 @@ rtc_source_set("unittest") { ":lib", "../../../..:webrtc_common", "../../../../api:array_view", + "../../../../api:optional", "../../../../common_audio", "../../../../rtc_base:rtc_base_approved", "../../../../test:test_support", diff --git a/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc index 9a52e5cc1f..e0aa43de23 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -42,6 +42,7 @@ #include #include +#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/webrtc/modules/audio_processing/test/performance_timer.h b/webrtc/modules/audio_processing/test/performance_timer.h index 3e75e3f5f5..9377f4ae77 100644 --- a/webrtc/modules/audio_processing/test/performance_timer.h +++ b/webrtc/modules/audio_processing/test/performance_timer.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" #include "webrtc/system_wrappers/include/clock.h" namespace webrtc { diff --git a/webrtc/modules/congestion_controller/BUILD.gn b/webrtc/modules/congestion_controller/BUILD.gn index 8c3f35be14..be0afd2dfd 100644 --- a/webrtc/modules/congestion_controller/BUILD.gn +++ b/webrtc/modules/congestion_controller/BUILD.gn @@ -49,6 +49,7 @@ rtc_static_library("congestion_controller") { deps = [ "..:module_api", "../..:webrtc_common", + "../../api:optional", "../../logging:rtc_event_log_api", "../../rtc_base:rtc_base", "../../rtc_base:rtc_base_approved", diff --git a/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h b/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h index bab5d93ce5..491acb67c3 100644 --- a/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h +++ b/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h @@ -14,8 +14,8 @@ #include #include +#include "webrtc/api/optional.h" #include "webrtc/modules/congestion_controller/bitrate_estimator.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc { diff --git a/webrtc/modules/congestion_controller/bitrate_estimator.h b/webrtc/modules/congestion_controller/bitrate_estimator.h index f27d0630ef..ad7bef5fc2 100644 --- a/webrtc/modules/congestion_controller/bitrate_estimator.h +++ b/webrtc/modules/congestion_controller/bitrate_estimator.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/modules/congestion_controller/trendline_estimator.cc b/webrtc/modules/congestion_controller/trendline_estimator.cc index 4d25b45bba..e51d4fb137 100644 --- a/webrtc/modules/congestion_controller/trendline_estimator.cc +++ b/webrtc/modules/congestion_controller/trendline_estimator.cc @@ -12,9 +12,9 @@ #include +#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/webrtc/modules/include/module_common_types.h b/webrtc/modules/include/module_common_types.h index 1ee428deed..a3ac2bbc56 100644 --- a/webrtc/modules/include/module_common_types.h +++ b/webrtc/modules/include/module_common_types.h @@ -17,6 +17,7 @@ #include #include +#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/webrtc/modules/pacing/BUILD.gn b/webrtc/modules/pacing/BUILD.gn index 7884c01e55..4882d4f714 100644 --- a/webrtc/modules/pacing/BUILD.gn +++ b/webrtc/modules/pacing/BUILD.gn @@ -31,6 +31,7 @@ rtc_static_library("pacing") { deps = [ "..:module_api", "../../:webrtc_common", + "../../api:optional", "../../logging:rtc_event_log_api", "../../rtc_base:rtc_base_approved", "../../system_wrappers", diff --git a/webrtc/modules/pacing/alr_detector.h b/webrtc/modules/pacing/alr_detector.h index 1e124d99e9..0d43fbb8f2 100644 --- a/webrtc/modules/pacing/alr_detector.h +++ b/webrtc/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/webrtc/modules/pacing/paced_sender.h b/webrtc/modules/pacing/paced_sender.h index 74b87804de..a9c6233b27 100644 --- a/webrtc/modules/pacing/paced_sender.h +++ b/webrtc/modules/pacing/paced_sender.h @@ -15,9 +15,9 @@ #include #include +#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/webrtc/modules/remote_bitrate_estimator/BUILD.gn b/webrtc/modules/remote_bitrate_estimator/BUILD.gn index 8bcbe7b334..72e6f1de12 100644 --- a/webrtc/modules/remote_bitrate_estimator/BUILD.gn +++ b/webrtc/modules/remote_bitrate_estimator/BUILD.gn @@ -140,6 +140,7 @@ if (rtc_include_tests) { ":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/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h b/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h index 21f9e57cad..426dbb1b6c 100644 --- a/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h +++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h index 6f4d831bc2..cf61c5747e 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h @@ -17,9 +17,9 @@ #include #include +#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/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h index 105a748d63..3194d81c2a 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h +++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h index f45437eee5..82451bd242 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h @@ -16,7 +16,7 @@ #include #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { namespace testing { diff --git a/webrtc/modules/rtp_rtcp/BUILD.gn b/webrtc/modules/rtp_rtcp/BUILD.gn index 8d17d1a799..2095aadb28 100644 --- a/webrtc/modules/rtp_rtcp/BUILD.gn +++ b/webrtc/modules/rtp_rtcp/BUILD.gn @@ -169,6 +169,7 @@ rtc_static_library("rtp_rtcp") { "../..: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 @@ rtc_source_set("mock_rtp_rtcp") { deps = [ ":rtp_rtcp", "..:module_api", + "../../api:optional", "../../rtc_base:rtc_base_approved", "../../test:test_support", ] diff --git a/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h index 427229472c..25d904672a 100644 --- a/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h @@ -16,13 +16,13 @@ #include #include +#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/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h index 54d84d595d..1d45463484 100644 --- a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h @@ -15,12 +15,12 @@ #include #include +#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/webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h b/webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h index aed304f74b..33a23de57a 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h @@ -13,12 +13,12 @@ #include +#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/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h index 7b3ad496dd..ae06a17d8e 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h @@ -19,6 +19,7 @@ #include #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/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 7a28be536d..aa9555076a 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -16,6 +16,7 @@ #include #include +#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/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h index 9c4fdc1b3d..f345274b9d 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h +++ b/webrtc/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/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h index e4a24052e5..f91fa69051 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h @@ -14,6 +14,7 @@ #include #include +#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/webrtc/modules/video_coding/BUILD.gn b/webrtc/modules/video_coding/BUILD.gn index 3af09ea232..3bf221be17 100644 --- a/webrtc/modules/video_coding/BUILD.gn +++ b/webrtc/modules/video_coding/BUILD.gn @@ -96,6 +96,7 @@ rtc_static_library("video_coding") { ":webrtc_vp9", "..:module_api", "../..:webrtc_common", + "../../api:optional", "../../call:video_stream_api", "../../common_video", "../../rtc_base:rtc_base", @@ -136,6 +137,7 @@ rtc_static_library("video_coding_utility") { deps = [ "..:module_api", "../..:webrtc_common", + "../../api:optional", "../../api/video_codecs:video_codecs_api", "../../common_video", "../../modules/rtp_rtcp:rtp_rtcp", @@ -232,6 +234,7 @@ rtc_static_library("webrtc_vp8") { ":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 @@ if (rtc_include_tests) { ":webrtc_h264", ":webrtc_vp8", ":webrtc_vp9", + "../../api:optional", "../../api:video_frame_api", "../../common_video:common_video", "../../rtc_base:rtc_base_approved", diff --git a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h index 4762f872a7..985874b620 100644 --- a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h +++ b/webrtc/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/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc index 310fa3c543..3eb04be037 100644 --- a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -12,13 +12,13 @@ #include +#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/webrtc/modules/video_coding/frame_object.h b/webrtc/modules/video_coding/frame_object.h index 90c1c00564..69ab6f03c8 100644 --- a/webrtc/modules/video_coding/frame_object.h +++ b/webrtc/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/webrtc/modules/video_coding/generic_encoder.cc b/webrtc/modules/video_coding/generic_encoder.cc index adc4365497..339e1b516f 100644 --- a/webrtc/modules/video_coding/generic_encoder.cc +++ b/webrtc/modules/video_coding/generic_encoder.cc @@ -12,13 +12,13 @@ #include +#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/webrtc/modules/video_coding/sequence_number_util.h b/webrtc/modules/video_coding/sequence_number_util.h index 05f33676d5..3e7d64a2f5 100644 --- a/webrtc/modules/video_coding/sequence_number_util.h +++ b/webrtc/modules/video_coding/sequence_number_util.h @@ -14,8 +14,8 @@ #include #include +#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/webrtc/modules/video_coding/utility/moving_average.h b/webrtc/modules/video_coding/utility/moving_average.h index bc31cd5213..0f2c4cc3c8 100644 --- a/webrtc/modules/video_coding/utility/moving_average.h +++ b/webrtc/modules/video_coding/utility/moving_average.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { class MovingAverage { diff --git a/webrtc/modules/video_coding/utility/quality_scaler.h b/webrtc/modules/video_coding/utility/quality_scaler.h index 690d1bc059..25d39cc986 100644 --- a/webrtc/modules/video_coding/utility/quality_scaler.h +++ b/webrtc/modules/video_coding/utility/quality_scaler.h @@ -13,10 +13,10 @@ #include +#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/webrtc/ortc/BUILD.gn b/webrtc/ortc/BUILD.gn index 199ee625c0..485771c9a4 100644 --- a/webrtc/ortc/BUILD.gn +++ b/webrtc/ortc/BUILD.gn @@ -33,6 +33,7 @@ rtc_static_library("ortc") { # 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/webrtc/ortc/rtpparametersconversion.h b/webrtc/ortc/rtpparametersconversion.h index fe183da127..072aaf2264 100644 --- a/webrtc/ortc/rtpparametersconversion.h +++ b/webrtc/ortc/rtpparametersconversion.h @@ -14,11 +14,11 @@ #include #include +#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/webrtc/p2p/BUILD.gn b/webrtc/p2p/BUILD.gn index 588f6bd1a3..9223f865b4 100644 --- a/webrtc/p2p/BUILD.gn +++ b/webrtc/p2p/BUILD.gn @@ -86,6 +86,7 @@ rtc_static_library("rtc_p2p") { deps = [ "../api:libjingle_peerconnection_api", + "../api:optional", "../api:ortc_api", "../rtc_base:rtc_base", "../system_wrappers:field_trial_api", diff --git a/webrtc/p2p/base/jseptransport.h b/webrtc/p2p/base/jseptransport.h index aee07180c1..f680646e16 100644 --- a/webrtc/p2p/base/jseptransport.h +++ b/webrtc/p2p/base/jseptransport.h @@ -16,13 +16,13 @@ #include #include +#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/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h index 19391b52ba..76a3deaa49 100644 --- a/webrtc/p2p/base/port.h +++ b/webrtc/p2p/base/port.h @@ -17,6 +17,7 @@ #include #include +#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/webrtc/p2p/base/udptransport.h b/webrtc/p2p/base/udptransport.h index c3c9513bb9..823c88fcab 100644 --- a/webrtc/p2p/base/udptransport.h +++ b/webrtc/p2p/base/udptransport.h @@ -14,10 +14,10 @@ #include #include +#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/webrtc/p2p/quic/quictransportchannel.h b/webrtc/p2p/quic/quictransportchannel.h index 4c34675f20..76560e9f03 100644 --- a/webrtc/p2p/quic/quictransportchannel.h +++ b/webrtc/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/webrtc/pc/BUILD.gn b/webrtc/pc/BUILD.gn index 6473cf68cc..09c58ab221 100644 --- a/webrtc/pc/BUILD.gn +++ b/webrtc/pc/BUILD.gn @@ -62,6 +62,7 @@ rtc_static_library("rtc_pc_base") { "..: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_static_library("peerconnection") { ":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/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc index 4d4744aeb0..2d9fd94b05 100644 --- a/webrtc/pc/mediasession.cc +++ b/webrtc/pc/mediasession.cc @@ -18,6 +18,7 @@ #include #include +#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/webrtc/pc/rtcstatscollector.h b/webrtc/pc/rtcstatscollector.h index 980edd6078..5ba4bfd34f 100644 --- a/webrtc/pc/rtcstatscollector.h +++ b/webrtc/pc/rtcstatscollector.h @@ -16,6 +16,7 @@ #include #include +#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/webrtc/pc/srtpfilter.h b/webrtc/pc/srtpfilter.h index 619aaa37d5..2a90360860 100644 --- a/webrtc/pc/srtpfilter.h +++ b/webrtc/pc/srtpfilter.h @@ -17,13 +17,13 @@ #include #include +#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/webrtc/pc/webrtcsession.h b/webrtc/pc/webrtcsession.h index 0f4d321eea..4d52a5c361 100644 --- a/webrtc/pc/webrtcsession.h +++ b/webrtc/pc/webrtcsession.h @@ -16,6 +16,7 @@ #include #include +#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/webrtc/rtc_base/BUILD.gn b/webrtc/rtc_base/BUILD.gn index 1914b27439..6676fdf2ea 100644 --- a/webrtc/rtc_base/BUILD.gn +++ b/webrtc/rtc_base/BUILD.gn @@ -137,8 +137,6 @@ rtc_static_library("rtc_base_approved") { "mod_ops.h", "moving_max_counter.h", "onetimeevent.h", - "optional.cc", - "optional.h", "pathutils.cc", "pathutils.h", "platform_file.cc", @@ -436,6 +434,7 @@ rtc_static_library("rtc_base") { defines = [] deps = [ "..:webrtc_common", + "../api:optional", ] public_deps = [ ":rtc_base_approved", @@ -855,7 +854,6 @@ if (rtc_include_tests) { "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 @@ if (rtc_include_tests) { deps = [ ":rtc_base_tests_main", ":rtc_base_tests_utils", + "../api:optional", "../test:test_support", ] public_deps = [ diff --git a/webrtc/rtc_base/moving_max_counter.h b/webrtc/rtc_base/moving_max_counter.h index 907e9cf298..190b7b85c2 100644 --- a/webrtc/rtc_base/moving_max_counter.h +++ b/webrtc/rtc_base/moving_max_counter.h @@ -17,9 +17,9 @@ #include #include +#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/webrtc/rtc_base/optional.h b/webrtc/rtc_base/optional.h index ca3208e4d5..b70774684c 100644 --- a/webrtc/rtc_base/optional.h +++ b/webrtc/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 -#include -#include - -#ifdef UNIT_TEST -#include -#include -#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 -inline T* FunctionThatDoesNothing(T* x) { - return reinterpret_cast( - FunctionThatDoesNothingImpl(reinterpret_cast(x))); -} - -#else - -template -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 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 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 (the index where it found the element, or -// nothing if it didn't find it); and a function that parses numbers might -// return Optional (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 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 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, const Optional& 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 -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 - void emplace(Args&&... args) { - if (has_value_) - value_.~T(); - else - UnpoisonValue(); - new (&value_) T(std::forward(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 -struct HasPrintTo { - private: - struct No {}; - - template - static auto Test(const T2& obj) - -> decltype(PrintTo(obj, std::declval())); - - template - static No Test(...); - - public: - static constexpr bool value = - !std::is_same(std::declval())), No>::value; -}; - -// Checks if there's a valid operator<<(std::ostream&, const T&) call for T. -template -struct HasOstreamOperator { - private: - struct No {}; - - template - static auto Test(const T2& obj) - -> decltype(std::declval() << obj); - - template - static No Test(...); - - public: - static constexpr bool value = - !std::is_same(std::declval())), No>::value; -}; - -// Prefer using PrintTo to print the object. -template -typename std::enable_if::value, void>::type OptionalPrintToHelper( - const T& value, - std::ostream* os) { - PrintTo(value, os); -} - -// Fall back to operator<<(std::ostream&, ...) if it exists. -template -typename std::enable_if::value && !HasPrintTo::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 << "(bytes[i]); - } - *os << "]>"; -} - -// As a final back-up, just print the contents of the objcets byte-wise. -template -typename std::enable_if::value && !HasPrintTo::value, - void>::type -OptionalPrintToHelper(const T& value, std::ostream* os) { - OptionalPrintObjectBytes(reinterpret_cast(&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 -void PrintTo(const rtc::Optional& opt, std::ostream* os) { - if (opt) { - optional_internal::OptionalPrintToHelper(*opt, os); - } else { - *os << ""; - } -} - -#endif // UNIT_TEST - -} // namespace rtc +#include "webrtc/api/optional.h" #endif // WEBRTC_RTC_BASE_OPTIONAL_H_ diff --git a/webrtc/rtc_base/rate_statistics.h b/webrtc/rtc_base/rate_statistics.h index 7c4daeaa6e..87f6c35bdf 100644 --- a/webrtc/rtc_base/rate_statistics.h +++ b/webrtc/rtc_base/rate_statistics.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" #include "webrtc/typedefs.h" namespace webrtc { diff --git a/webrtc/rtc_base/rtccertificategenerator.h b/webrtc/rtc_base/rtccertificategenerator.h index 272a5d61f0..4e0437c58a 100644 --- a/webrtc/rtc_base/rtccertificategenerator.h +++ b/webrtc/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/webrtc/rtc_base/rtccertificategenerator_unittest.cc b/webrtc/rtc_base/rtccertificategenerator_unittest.cc index df820d93cc..829a6ee9a3 100644 --- a/webrtc/rtc_base/rtccertificategenerator_unittest.cc +++ b/webrtc/rtc_base/rtccertificategenerator_unittest.cc @@ -12,10 +12,10 @@ #include +#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/webrtc/rtc_base/string_to_number.h b/webrtc/rtc_base/string_to_number.h index c61d1ed73c..93bd850f63 100644 --- a/webrtc/rtc_base/string_to_number.h +++ b/webrtc/rtc_base/string_to_number.h @@ -14,7 +14,7 @@ #include #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace rtc { diff --git a/webrtc/rtc_tools/network_tester/BUILD.gn b/webrtc/rtc_tools/network_tester/BUILD.gn index 02bbc3182b..cff453d808 100644 --- a/webrtc/rtc_tools/network_tester/BUILD.gn +++ b/webrtc/rtc_tools/network_tester/BUILD.gn @@ -41,6 +41,7 @@ if (rtc_enable_protobuf) { deps = [ ":network_tester_config_proto", ":network_tester_packet_proto", + "../../api:optional", "../../p2p", "../../rtc_base:protobuf_utils", "../../rtc_base:rtc_base_approved", diff --git a/webrtc/rtc_tools/network_tester/config_reader.h b/webrtc/rtc_tools/network_tester/config_reader.h index 83fbdebc6a..ae4348f483 100644 --- a/webrtc/rtc_tools/network_tester/config_reader.h +++ b/webrtc/rtc_tools/network_tester/config_reader.h @@ -14,8 +14,8 @@ #include #include +#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/webrtc/sdk/BUILD.gn b/webrtc/sdk/BUILD.gn index ff97082229..086ce49f47 100644 --- a/webrtc/sdk/BUILD.gn +++ b/webrtc/sdk/BUILD.gn @@ -183,6 +183,7 @@ if (is_ios || is_mac) { ":common_objc", ":videotracksource_objc", "../api:libjingle_peerconnection_api", + "../api:optional", "../common_video", "../media:rtc_media_base", "../rtc_base:rtc_base", diff --git a/webrtc/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm b/webrtc/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm index 900f2840ea..14301ba3d5 100644 --- a/webrtc/sdk/objc/Framework/Classes/Video/RTCDefaultShader.mm +++ b/webrtc/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/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn index 0858468e5c..9ec02902d9 100644 --- a/webrtc/test/BUILD.gn +++ b/webrtc/test/BUILD.gn @@ -60,6 +60,7 @@ rtc_source_set("video_test_common") { deps = [ "..:webrtc_common", + "../api:optional", "../api/video_codecs:video_codecs_api", "../call:video_stream_api", "../common_video", @@ -375,6 +376,7 @@ rtc_source_set("fileutils") { ] deps = [ "..:webrtc_common", + "../api:optional", "../rtc_base:rtc_base_approved", ] if (is_ios) { @@ -437,6 +439,7 @@ rtc_source_set("fileutils_unittests") { deps = [ ":fileutils", ":test_support", + "../api:optional", "../rtc_base:rtc_base_approved", "//testing/gmock", "//testing/gtest", diff --git a/webrtc/test/fuzzers/BUILD.gn b/webrtc/test/fuzzers/BUILD.gn index e9d771cc73..6035cd93af 100644 --- a/webrtc/test/fuzzers/BUILD.gn +++ b/webrtc/test/fuzzers/BUILD.gn @@ -207,6 +207,7 @@ rtc_static_library("audio_decoder_fuzzer") { ] deps = [ "../..:webrtc_common", + "../../api:optional", "../../api/audio_codecs:audio_codecs_api", "../../modules/rtp_rtcp", "../../rtc_base:rtc_base_approved", @@ -369,6 +370,7 @@ webrtc_fuzzer_test("audio_processing_fuzzer") { "audio_processing_fuzzer_configs.cc", ] deps = [ + "../../api:optional", "../../modules:module_api", "../../modules/audio_processing", "../../rtc_base:rtc_base_approved", diff --git a/webrtc/test/fuzzers/audio_decoder_fuzzer.cc b/webrtc/test/fuzzers/audio_decoder_fuzzer.cc index ff4478dca9..441b12b5f2 100644 --- a/webrtc/test/fuzzers/audio_decoder_fuzzer.cc +++ b/webrtc/test/fuzzers/audio_decoder_fuzzer.cc @@ -13,9 +13,9 @@ #include #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/webrtc/test/fuzzers/audio_processing_fuzzer_configs.cc b/webrtc/test/fuzzers/audio_processing_fuzzer_configs.cc index f9814ec306..21810ad83a 100644 --- a/webrtc/test/fuzzers/audio_processing_fuzzer_configs.cc +++ b/webrtc/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/webrtc/test/testsupport/fileutils.h b/webrtc/test/testsupport/fileutils.h index 570d7b4d20..5ea7d31705 100644 --- a/webrtc/test/testsupport/fileutils.h +++ b/webrtc/test/testsupport/fileutils.h @@ -16,7 +16,7 @@ #include #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { namespace test { diff --git a/webrtc/test/testsupport/fileutils_unittest.cc b/webrtc/test/testsupport/fileutils_unittest.cc index bdabb8470a..fb780be56e 100644 --- a/webrtc/test/testsupport/fileutils_unittest.cc +++ b/webrtc/test/testsupport/fileutils_unittest.cc @@ -17,8 +17,8 @@ #include #include +#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/webrtc/test/video_capturer.h b/webrtc/test/video_capturer.h index 2535370f8e..deeb5c8c2a 100644 --- a/webrtc/test/video_capturer.h +++ b/webrtc/test/video_capturer.h @@ -14,12 +14,12 @@ #include +#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/webrtc/video/BUILD.gn b/webrtc/video/BUILD.gn index c93ef8cc40..7756ff416d 100644 --- a/webrtc/video/BUILD.gn +++ b/webrtc/video/BUILD.gn @@ -55,6 +55,7 @@ rtc_static_library("video") { deps = [ "..:webrtc_common", + "../api:optional", "../api:transport_api", "../api/video_codecs:video_codecs_api", "../call:call_interfaces", @@ -93,6 +94,7 @@ if (rtc_include_tests) { "video_quality_test.h", ] deps = [ + "../api:optional", "../call:call_interfaces", "../common_video", "../logging:rtc_event_log_api", @@ -265,6 +267,7 @@ if (rtc_include_tests) { ] deps = [ ":video", + "../api:optional", "../api:video_frame_api", "../api/video_codecs:video_codecs_api", "../call:call_interfaces", diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index a30b08a320..644319cf79 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -15,6 +15,7 @@ #include #include +#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/webrtc/video/overuse_frame_detector.h b/webrtc/video/overuse_frame_detector.h index 8bf1a78aed..a5eef51020 100644 --- a/webrtc/video/overuse_frame_detector.h +++ b/webrtc/video/overuse_frame_detector.h @@ -14,10 +14,10 @@ #include #include +#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/webrtc/video/quality_threshold.h b/webrtc/video/quality_threshold.h index ee13f8b810..a142d4e716 100644 --- a/webrtc/video/quality_threshold.h +++ b/webrtc/video/quality_threshold.h @@ -13,7 +13,7 @@ #include -#include "webrtc/rtc_base/optional.h" +#include "webrtc/api/optional.h" namespace webrtc { diff --git a/webrtc/video/receive_statistics_proxy.h b/webrtc/video/receive_statistics_proxy.h index 140cdbd407..45424d980f 100644 --- a/webrtc/video/receive_statistics_proxy.h +++ b/webrtc/video/receive_statistics_proxy.h @@ -14,13 +14,13 @@ #include #include +#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/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc index 2aa6295ccf..8224377627 100644 --- a/webrtc/video/video_quality_test.cc +++ b/webrtc/video/video_quality_test.cc @@ -18,6 +18,7 @@ #include #include +#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/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc index 6750c9e0de..74c90134b9 100644 --- a/webrtc/video/video_receive_stream.cc +++ b/webrtc/video/video_receive_stream.cc @@ -16,6 +16,7 @@ #include #include +#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/webrtc/voice_engine/BUILD.gn b/webrtc/voice_engine/BUILD.gn index 9862579c85..809333b850 100644 --- a/webrtc/voice_engine/BUILD.gn +++ b/webrtc/voice_engine/BUILD.gn @@ -139,6 +139,7 @@ rtc_static_library("voice_engine") { "../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/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 884845ef83..0d71a41d82 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/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/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h index 987ba25832..8168216f69 100644 --- a/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h +++ b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h @@ -13,8 +13,8 @@ #include +#include "webrtc/api/optional.h" #include "webrtc/modules/include/module_common_types.h" -#include "webrtc/rtc_base/optional.h" namespace webrtc {