diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index e6c5933f0d..c36197645e 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -126,7 +126,6 @@ rtc_static_library("audio_processing") { "../..:typedefs", "../..:webrtc_common", "../../api:array_view", - "../../api:optional", "../../api/audio:aec3_config", "../../api/audio:audio_frame_api", "../../api/audio:echo_control", @@ -144,6 +143,7 @@ rtc_static_library("audio_processing") { "agc2:fixed_digital", "agc2:gain_applier", "vad", + "//third_party/abseil-cpp/absl/types:optional", ] if (aec_untrusted_delay_for_testing) { @@ -187,7 +187,7 @@ rtc_source_set("audio_processing_statistics") { "include/audio_processing_statistics.h", ] deps = [ - "../../api:optional", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -510,7 +510,6 @@ if (rtc_include_tests) { "../..:typedefs", "../..:webrtc_common", "../../api:array_view", - "../../api:optional", "../../api/audio:aec3_config", "../../api/audio:aec3_factory", "../../common_audio:common_audio", @@ -536,6 +535,7 @@ if (rtc_include_tests) { "test/conversational_speech:unittest", "vad:vad_unittests", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] defines = [] @@ -650,11 +650,11 @@ if (rtc_include_tests) { ] deps = [ "../../api:array_view", - "../../api:optional", "../../api/audio:audio_frame_api", "../../common_audio:common_audio", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/types:optional", ] } @@ -678,7 +678,6 @@ if (rtc_include_tests) { ":audioproc_debug_proto", ":audioproc_protobuf_utils", ":audioproc_test_utils", - "../../api:optional", "../../api/audio:aec3_factory", "../../common_audio:common_audio", "../../rtc_base:checks", @@ -693,6 +692,7 @@ if (rtc_include_tests) { "aec_dump", "aec_dump:aec_dump_impl", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] } # audioproc_f_impl rtc_executable("audioproc_f") { @@ -727,7 +727,6 @@ if (rtc_include_tests) { deps = [ ":audio_processing", "../../api:array_view", - "../../api:optional", "../../api/audio:audio_frame_api", "../../common_audio", "../../rtc_base:checks", @@ -737,6 +736,7 @@ if (rtc_include_tests) { "../../test:test_support", "../audio_coding:neteq_input_audio_tools", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 15ca70a688..c0f632aac4 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -112,7 +112,6 @@ rtc_static_library("aec3") { "..:audio_processing", "../../..:typedefs", "../../../api:array_view", - "../../../api:optional", "../../../api/audio:aec3_config", "../../../api/audio:echo_control", "../../../common_audio:common_audio_c", @@ -122,6 +121,7 @@ rtc_static_library("aec3") { "../../../system_wrappers:cpu_features_api", "../../../system_wrappers:field_trial_api", "../../../system_wrappers:metrics_api", + "//third_party/abseil-cpp/absl/types:optional", ] configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] @@ -146,13 +146,13 @@ if (rtc_include_tests) { "..:audio_processing_unittests", "../../..:typedefs", "../../../api:array_view", - "../../../api:optional", "../../../api/audio:aec3_config", "../../../rtc_base:checks", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", "../../../system_wrappers:cpu_features_api", "../../../test:test_support", + "//third_party/abseil-cpp/absl/types:optional", ] defines = [] diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index 9561dff7ef..b075ff52fc 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc @@ -325,7 +325,7 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) { std::vector y(kBlockSize, 0.f); AecState aec_state(EchoCanceller3Config{}); RenderSignalAnalyzer render_signal_analyzer(config); - rtc::Optional delay_estimate; + absl::optional delay_estimate; std::vector e(kBlockSize, 0.f); std::array s_scratch; std::array s; diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 5fe8276b3d..b32ae3c3e5 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -115,7 +115,7 @@ void AecState::HandleEchoPathChange( } void AecState::Update( - const rtc::Optional& external_delay, + const absl::optional& external_delay, const std::vector>& adaptive_filter_frequency_response, const std::vector& adaptive_filter_impulse_response, @@ -143,7 +143,7 @@ void AecState::Update( if (filter_analyzer_.Consistent()) { internal_delay_ = filter_analyzer_.DelayBlocks(); } else { - internal_delay_ = rtc::nullopt; + internal_delay_ = absl::nullopt; } external_delay_seen_ = external_delay_seen_ || external_delay; diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index 710aedbe58..ad3d929e37 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -17,9 +17,9 @@ #include #include +#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/echo_audibility.h" @@ -84,7 +84,7 @@ class AecState { int FilterDelayBlocks() const { return filter_delay_blocks_; } // Returns the internal delay estimate based on the linear filter. - rtc::Optional InternalDelay() const { return internal_delay_; } + absl::optional InternalDelay() const { return internal_delay_; } // Returns whether the capture signal is saturated. bool SaturatedCapture() const { return capture_signal_saturation_; } @@ -125,7 +125,7 @@ class AecState { bool InitialState() const { return initial_state_; } // Updates the aec state. - void Update(const rtc::Optional& external_delay, + void Update(const absl::optional& external_delay, const std::vector>& adaptive_filter_frequency_response, const std::vector& adaptive_filter_impulse_response, @@ -188,7 +188,7 @@ class AecState { SuppressionGainUpperLimiter suppression_gain_limiter_; FilterAnalyzer filter_analyzer_; bool use_linear_filter_output_ = false; - rtc::Optional internal_delay_; + absl::optional internal_delay_; size_t diverged_blocks_ = 0; bool filter_should_have_converged_ = false; size_t blocks_since_converged_filter_; @@ -196,7 +196,7 @@ class AecState { bool converged_filter_seen_ = false; bool consistent_filter_seen_ = false; bool external_delay_seen_ = false; - rtc::Optional external_delay_; + absl::optional external_delay_; size_t frames_since_external_delay_change_ = 0; size_t converged_filter_count_ = 0; bool finite_erl_ = false; diff --git a/modules/audio_processing/aec3/aec_state_unittest.cc b/modules/audio_processing/aec3/aec_state_unittest.cc index 83213b5065..00d25d61df 100644 --- a/modules/audio_processing/aec3/aec_state_unittest.cc +++ b/modules/audio_processing/aec3/aec_state_unittest.cc @@ -22,7 +22,7 @@ TEST(AecState, NormalUsage) { ApmDataDumper data_dumper(42); EchoCanceller3Config config; AecState state(config); - rtc::Optional delay_estimate = + absl::optional delay_estimate = DelayEstimate(DelayEstimate::Quality::kRefined, 10); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, 3)); @@ -173,7 +173,7 @@ TEST(AecState, ConvergedFilterDelay) { AecState state(config); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, 3)); - rtc::Optional delay_estimate; + absl::optional delay_estimate; std::array E2_main; std::array Y2; std::array x; diff --git a/modules/audio_processing/aec3/block_processor.cc b/modules/audio_processing/aec3/block_processor.cc index f954be3b63..1bb69584cc 100644 --- a/modules/audio_processing/aec3/block_processor.cc +++ b/modules/audio_processing/aec3/block_processor.cc @@ -9,7 +9,7 @@ */ #include "modules/audio_processing/aec3/block_processor.h" -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block_processor_metrics.h" #include "modules/audio_processing/aec3/echo_path_variability.h" @@ -58,8 +58,8 @@ class BlockProcessorImpl final : public BlockProcessor { BlockProcessorMetrics metrics_; RenderDelayBuffer::BufferingEvent render_event_; size_t capture_call_counter_ = 0; - rtc::Optional estimated_delay_; - rtc::Optional echo_remover_delay_; + absl::optional estimated_delay_; + absl::optional echo_remover_delay_; RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(BlockProcessorImpl); }; @@ -232,7 +232,7 @@ void BlockProcessorImpl::UpdateEchoLeakageStatus(bool leakage_detected) { void BlockProcessorImpl::GetMetrics(EchoControl::Metrics* metrics) const { echo_remover_->GetMetrics(metrics); const int block_size_ms = sample_rate_hz_ == 8000 ? 8 : 4; - rtc::Optional delay = render_buffer_->Delay(); + absl::optional delay = render_buffer_->Delay(); metrics->delay_ms = delay ? static_cast(*delay) * block_size_ms : 0; } diff --git a/modules/audio_processing/aec3/echo_audibility.cc b/modules/audio_processing/aec3/echo_audibility.cc index a504cca4be..567873b181 100644 --- a/modules/audio_processing/aec3/echo_audibility.cc +++ b/modules/audio_processing/aec3/echo_audibility.cc @@ -42,7 +42,7 @@ void EchoAudibility::Update(const RenderBuffer& render_buffer, void EchoAudibility::Reset() { render_stationarity_.Reset(); non_zero_render_seen_ = false; - render_spectrum_write_prev_ = rtc::nullopt; + render_spectrum_write_prev_ = absl::nullopt; } void EchoAudibility::UpdateRenderStationarityFlags( diff --git a/modules/audio_processing/aec3/echo_audibility.h b/modules/audio_processing/aec3/echo_audibility.h index 58a6599a37..141ac620cb 100644 --- a/modules/audio_processing/aec3/echo_audibility.h +++ b/modules/audio_processing/aec3/echo_audibility.h @@ -17,8 +17,8 @@ #include #include +#include "absl/types/optional.h" #include "api/array_view.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/matrix_buffer.h" #include "modules/audio_processing/aec3/render_buffer.h" #include "modules/audio_processing/aec3/stationarity_estimator.h" @@ -70,7 +70,7 @@ class EchoAudibility { // values. bool IsRenderTooLow(const MatrixBuffer& block_buffer); - rtc::Optional render_spectrum_write_prev_; + absl::optional render_spectrum_write_prev_; int render_block_write_prev_; bool non_zero_render_seen_; StationarityEstimator render_stationarity_; diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.cc b/modules/audio_processing/aec3/echo_path_delay_estimator.cc index bc9cde4577..4cae277c8e 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator.cc @@ -61,11 +61,11 @@ void EchoPathDelayEstimator::Reset(bool soft_reset) { matched_filter_lag_aggregator_.Reset(); } matched_filter_.Reset(); - old_aggregated_lag_ = rtc::nullopt; + old_aggregated_lag_ = absl::nullopt; consistent_estimate_counter_ = 0; } -rtc::Optional EchoPathDelayEstimator::EstimateDelay( +absl::optional EchoPathDelayEstimator::EstimateDelay( const DownsampledRenderBuffer& render_buffer, rtc::ArrayView capture) { RTC_DCHECK_EQ(kBlockSize, capture.size()); @@ -81,7 +81,7 @@ rtc::Optional EchoPathDelayEstimator::EstimateDelay( 16000 / down_sampling_factor_, 1); matched_filter_.Update(render_buffer, downsampled_capture); - rtc::Optional aggregated_matched_filter_lag = + absl::optional aggregated_matched_filter_lag = matched_filter_lag_aggregator_.Aggregate( matched_filter_.GetLagEstimates()); diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.h b/modules/audio_processing/aec3/echo_path_delay_estimator.h index 6389098102..cea9abcb51 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator.h +++ b/modules/audio_processing/aec3/echo_path_delay_estimator.h @@ -13,8 +13,8 @@ #include +#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/decimator.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" @@ -38,7 +38,7 @@ class EchoPathDelayEstimator { void Reset(bool soft_reset); // Produce a delay estimate if such is avaliable. - rtc::Optional EstimateDelay( + absl::optional EstimateDelay( const DownsampledRenderBuffer& render_buffer, rtc::ArrayView capture); @@ -55,7 +55,7 @@ class EchoPathDelayEstimator { Decimator capture_decimator_; MatchedFilter matched_filter_; MatchedFilterLagAggregator matched_filter_lag_aggregator_; - rtc::Optional old_aggregated_lag_; + absl::optional old_aggregated_lag_; size_t consistent_estimate_counter_ = 0; RTC_DISALLOW_COPY_AND_ASSIGN(EchoPathDelayEstimator); diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc index 8dd3bc638b..841cdfa764 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc @@ -72,7 +72,7 @@ TEST(EchoPathDelayEstimator, DelayEstimation) { delay_samples + 2 * config.delay.api_call_jitter_blocks * 64); EchoPathDelayEstimator estimator(&data_dumper, config); - rtc::Optional estimated_delay_samples; + absl::optional estimated_delay_samples; for (size_t k = 0; k < (500 + (delay_samples) / kBlockSize); ++k) { RandomizeSampleVector(&random_generator, render[0]); signal_delay_buffer.Delay(render[0], capture); diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc index a2d5e362e7..e264d30844 100644 --- a/modules/audio_processing/aec3/echo_remover.cc +++ b/modules/audio_processing/aec3/echo_remover.cc @@ -68,14 +68,14 @@ class EchoRemoverImpl final : public EchoRemover { // signal. void ProcessCapture(const EchoPathVariability& echo_path_variability, bool capture_signal_saturation, - const rtc::Optional& external_delay, + const absl::optional& external_delay, RenderBuffer* render_buffer, std::vector>* capture) override; // Returns the internal delay estimate in blocks. - rtc::Optional Delay() const override { + absl::optional Delay() const override { // TODO(peah): Remove or reactivate this functionality. - return rtc::nullopt; + return absl::nullopt; } // Updates the status on whether echo leakage is detected in the output of the @@ -143,7 +143,7 @@ void EchoRemoverImpl::GetMetrics(EchoControl::Metrics* metrics) const { void EchoRemoverImpl::ProcessCapture( const EchoPathVariability& echo_path_variability, bool capture_signal_saturation, - const rtc::Optional& external_delay, + const absl::optional& external_delay, RenderBuffer* render_buffer, std::vector>* capture) { const std::vector>& x = render_buffer->Block(0); diff --git a/modules/audio_processing/aec3/echo_remover.h b/modules/audio_processing/aec3/echo_remover.h index 61d29995f0..710afacb3e 100644 --- a/modules/audio_processing/aec3/echo_remover.h +++ b/modules/audio_processing/aec3/echo_remover.h @@ -13,9 +13,9 @@ #include +#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/echo_path_variability.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -38,12 +38,12 @@ class EchoRemover { virtual void ProcessCapture( const EchoPathVariability& echo_path_variability, bool capture_signal_saturation, - const rtc::Optional& external_delay, + const absl::optional& external_delay, RenderBuffer* render_buffer, std::vector>* capture) = 0; // Returns the internal delay estimate in blocks. - virtual rtc::Optional Delay() const = 0; + virtual absl::optional Delay() const = 0; // Updates the status on whether echo leakage is detected in the output of the // echo remover. diff --git a/modules/audio_processing/aec3/echo_remover_unittest.cc b/modules/audio_processing/aec3/echo_remover_unittest.cc index 8e131fe2a7..04a27273d1 100644 --- a/modules/audio_processing/aec3/echo_remover_unittest.cc +++ b/modules/audio_processing/aec3/echo_remover_unittest.cc @@ -43,7 +43,7 @@ std::string ProduceDebugText(int sample_rate_hz, int delay) { // Verifies the basic API call sequence TEST(EchoRemover, BasicApiCalls) { - rtc::Optional delay_estimate; + absl::optional delay_estimate; for (auto rate : {8000, 16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr remover( @@ -84,7 +84,7 @@ TEST(EchoRemover, DISABLED_WrongSampleRate) { // Verifies the check for the capture block size. TEST(EchoRemover, WrongCaptureBlockSize) { - rtc::Optional delay_estimate; + absl::optional delay_estimate; for (auto rate : {8000, 16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr remover( @@ -106,7 +106,7 @@ TEST(EchoRemover, WrongCaptureBlockSize) { // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH // tests on test bots has been fixed.c TEST(EchoRemover, DISABLED_WrongCaptureNumBands) { - rtc::Optional delay_estimate; + absl::optional delay_estimate; for (auto rate : {16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr remover( @@ -127,7 +127,7 @@ TEST(EchoRemover, DISABLED_WrongCaptureNumBands) { // Verifies the check for non-null capture block. TEST(EchoRemover, NullCapture) { - rtc::Optional delay_estimate; + absl::optional delay_estimate; std::unique_ptr remover( EchoRemover::Create(EchoCanceller3Config(), 8000)); std::unique_ptr render_buffer( @@ -147,7 +147,7 @@ TEST(EchoRemover, NullCapture) { TEST(EchoRemover, BasicEchoRemoval) { constexpr int kNumBlocksToProcess = 500; Random random_generator(42U); - rtc::Optional delay_estimate; + absl::optional delay_estimate; for (auto rate : {8000, 16000, 32000, 48000}) { std::vector> x(NumBandsForRate(rate), std::vector(kBlockSize, 0.f)); diff --git a/modules/audio_processing/aec3/filter_analyzer.h b/modules/audio_processing/aec3/filter_analyzer.h index e47606cc93..3d65aecf2d 100644 --- a/modules/audio_processing/aec3/filter_analyzer.h +++ b/modules/audio_processing/aec3/filter_analyzer.h @@ -13,9 +13,9 @@ #include +#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/cascaded_biquad_filter.h" #include "modules/audio_processing/aec3/render_buffer.h" diff --git a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc index 3d0a8c3771..f398b84fb7 100644 --- a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc +++ b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc @@ -68,7 +68,7 @@ void RunFilterUpdateTest(int num_blocks_to_process, RenderDelayBuffer::Create(config, 3)); AecState aec_state(config); RenderSignalAnalyzer render_signal_analyzer(config); - rtc::Optional delay_estimate; + absl::optional delay_estimate; std::array s_scratch; std::array s; FftData S; diff --git a/modules/audio_processing/aec3/matched_filter.h b/modules/audio_processing/aec3/matched_filter.h index 36c9cad74a..8add6fe3d5 100644 --- a/modules/audio_processing/aec3/matched_filter.h +++ b/modules/audio_processing/aec3/matched_filter.h @@ -15,8 +15,8 @@ #include #include +#include "absl/types/optional.h" #include "api/array_view.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "rtc_base/constructormagic.h" diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc index 23cd71a8be..9cd2eb3d7b 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc @@ -30,7 +30,7 @@ void MatchedFilterLagAggregator::Reset() { significant_candidate_found_ = false; } -rtc::Optional MatchedFilterLagAggregator::Aggregate( +absl::optional MatchedFilterLagAggregator::Aggregate( rtc::ArrayView lag_estimates) { // Choose the strongest lag estimate as the best one. float best_accuracy = 0.f; @@ -72,7 +72,7 @@ rtc::Optional MatchedFilterLagAggregator::Aggregate( return DelayEstimate(DelayEstimate::Quality::kRefined, candidate); } } - return rtc::nullopt; + return absl::nullopt; } } // namespace webrtc diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h index 86968bd24f..fddcfbff79 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/matched_filter.h" #include "rtc_base/constructormagic.h" @@ -33,7 +33,7 @@ class MatchedFilterLagAggregator { void Reset(); // Aggregates the provided lag estimates. - rtc::Optional Aggregate( + absl::optional Aggregate( rtc::ArrayView lag_estimates); private: diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc index 18b8829620..97c7f5b857 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc @@ -40,7 +40,7 @@ TEST(MatchedFilterLagAggregator, MostAccurateLagChosen) { aggregator.Aggregate(lag_estimates); } - rtc::Optional aggregated_lag = + absl::optional aggregated_lag = aggregator.Aggregate(lag_estimates); EXPECT_TRUE(aggregated_lag); EXPECT_EQ(kLag1, aggregated_lag->delay); @@ -68,7 +68,7 @@ TEST(MatchedFilterLagAggregator, std::vector lag_estimates(1); MatchedFilterLagAggregator aggregator(&data_dumper, 100); - rtc::Optional aggregated_lag; + absl::optional aggregated_lag; for (size_t k = 0; k < kNumLagsBeforeDetection; ++k) { lag_estimates[0] = MatchedFilter::LagEstimate(1.f, true, 10, true); aggregated_lag = aggregator.Aggregate(lag_estimates); @@ -98,7 +98,7 @@ TEST(MatchedFilterLagAggregator, MatchedFilterLagAggregator aggregator(&data_dumper, kLag); for (size_t k = 0; k < kNumLagsBeforeDetection * 10; ++k) { lag_estimates[0] = MatchedFilter::LagEstimate(1.f, true, kLag, false); - rtc::Optional aggregated_lag = + absl::optional aggregated_lag = aggregator.Aggregate(lag_estimates); EXPECT_FALSE(aggregated_lag); EXPECT_EQ(kLag, aggregated_lag->delay); @@ -114,7 +114,7 @@ TEST(MatchedFilterLagAggregator, DISABLED_PersistentAggregatedLag) { ApmDataDumper data_dumper(0); std::vector lag_estimates(1); MatchedFilterLagAggregator aggregator(&data_dumper, std::max(kLag1, kLag2)); - rtc::Optional aggregated_lag; + absl::optional aggregated_lag; for (size_t k = 0; k < kNumLagsBeforeDetection; ++k) { lag_estimates[0] = MatchedFilter::LagEstimate(1.f, true, kLag1, true); aggregated_lag = aggregator.Aggregate(lag_estimates); diff --git a/modules/audio_processing/aec3/matched_filter_unittest.cc b/modules/audio_processing/aec3/matched_filter_unittest.cc index e30c78caa6..c3c3a0db86 100644 --- a/modules/audio_processing/aec3/matched_filter_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_unittest.cc @@ -183,7 +183,7 @@ TEST(MatchedFilter, LagEstimation) { auto lag_estimates = filter.GetLagEstimates(); // Find which lag estimate should be the most accurate. - rtc::Optional expected_most_accurate_lag_estimate; + absl::optional expected_most_accurate_lag_estimate; size_t alignment_shift_sub_blocks = 0; for (size_t k = 0; k < config.delay.num_filters; ++k) { if ((alignment_shift_sub_blocks + 3 * kWindowSizeSubBlocks / 4) * diff --git a/modules/audio_processing/aec3/mock/mock_echo_remover.h b/modules/audio_processing/aec3/mock/mock_echo_remover.h index 0acf139f99..0eb95081b6 100644 --- a/modules/audio_processing/aec3/mock/mock_echo_remover.h +++ b/modules/audio_processing/aec3/mock/mock_echo_remover.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/audio_processing/aec3/echo_path_variability.h" #include "modules/audio_processing/aec3/echo_remover.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -29,10 +29,10 @@ class MockEchoRemover : public EchoRemover { MOCK_METHOD5(ProcessCapture, void(const EchoPathVariability& echo_path_variability, bool capture_signal_saturation, - const rtc::Optional& delay_estimate, + const absl::optional& delay_estimate, RenderBuffer* render_buffer, std::vector>* capture)); - MOCK_CONST_METHOD0(Delay, rtc::Optional()); + MOCK_CONST_METHOD0(Delay, absl::optional()); MOCK_METHOD1(UpdateEchoLeakageStatus, void(bool leakage_detected)); MOCK_CONST_METHOD1(GetMetrics, void(EchoControl::Metrics* metrics)); }; diff --git a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h index fab2b652a0..776bdaacb8 100644 --- a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h +++ b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_RENDER_DELAY_CONTROLLER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_RENDER_DELAY_CONTROLLER_H_ +#include "absl/types/optional.h" #include "api/array_view.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/aec3/render_delay_controller.h" #include "test/gmock.h" @@ -26,12 +26,12 @@ class MockRenderDelayController : public RenderDelayController { MOCK_METHOD0(Reset, void()); MOCK_METHOD0(LogRenderCall, void()); - MOCK_METHOD4( - GetDelay, - rtc::Optional(const DownsampledRenderBuffer& render_buffer, - size_t render_delay_buffer_delay, - const rtc::Optional& echo_remover_delay, - rtc::ArrayView capture)); + MOCK_METHOD4(GetDelay, + absl::optional( + const DownsampledRenderBuffer& render_buffer, + size_t render_delay_buffer_delay, + const absl::optional& echo_remover_delay, + rtc::ArrayView capture)); }; } // namespace test diff --git a/modules/audio_processing/aec3/render_delay_buffer.cc b/modules/audio_processing/aec3/render_delay_buffer.cc index b01593be0e..37a2378738 100644 --- a/modules/audio_processing/aec3/render_delay_buffer.cc +++ b/modules/audio_processing/aec3/render_delay_buffer.cc @@ -77,8 +77,8 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer { MatrixBuffer blocks_; VectorBuffer spectra_; FftBuffer ffts_; - rtc::Optional delay_; - rtc::Optional internal_delay_; + absl::optional delay_; + absl::optional internal_delay_; RenderBuffer echo_remover_buffer_; DownsampledRenderBuffer low_rate_; Decimator render_decimator_; @@ -93,7 +93,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer { size_t render_call_counter_ = 0; bool render_activity_ = false; size_t render_activity_counter_ = 0; - rtc::Optional external_audio_buffer_delay_; + absl::optional external_audio_buffer_delay_; bool external_delay_verified_after_reset_ = false; int LowRateBufferOffset() const { return DelayEstimatorOffset(config_) >> 1; } @@ -120,7 +120,7 @@ void IncreaseWriteIndices(int sub_block_size, } // Increases the read indices for the render buffers. -void IncreaseReadIndices(const rtc::Optional& delay, +void IncreaseReadIndices(const absl::optional& delay, int sub_block_size, MatrixBuffer* blocks, VectorBuffer* spectra, @@ -147,7 +147,7 @@ bool RenderOverrun(const MatrixBuffer& b, const DownsampledRenderBuffer& l) { // Checks for a render buffer underrun. If the delay is not specified, only the // low rate buffer underrun is counted as the delay offset for the other buffers // is unknown. -bool RenderUnderrun(const rtc::Optional& delay, +bool RenderUnderrun(const absl::optional& delay, const MatrixBuffer& b, const DownsampledRenderBuffer& l) { return l.read == l.write || (delay && b.read == b.write); @@ -243,8 +243,8 @@ void RenderDelayBufferImpl::Reset() { ApplyDelay(config_.delay.default_delay); // Unset the delays which are set by SetDelay. - delay_ = rtc::nullopt; - internal_delay_ = rtc::nullopt; + delay_ = absl::nullopt; + internal_delay_ = absl::nullopt; } } diff --git a/modules/audio_processing/aec3/render_delay_buffer.h b/modules/audio_processing/aec3/render_delay_buffer.h index e361628ebc..a6d6874e3e 100644 --- a/modules/audio_processing/aec3/render_delay_buffer.h +++ b/modules/audio_processing/aec3/render_delay_buffer.h @@ -15,9 +15,9 @@ #include #include +#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/aec3/fft_data.h" diff --git a/modules/audio_processing/aec3/render_delay_controller.cc b/modules/audio_processing/aec3/render_delay_controller.cc index 7a40c46db6..8adf5f5102 100644 --- a/modules/audio_processing/aec3/render_delay_controller.cc +++ b/modules/audio_processing/aec3/render_delay_controller.cc @@ -50,10 +50,10 @@ class RenderDelayControllerImpl final : public RenderDelayController { ~RenderDelayControllerImpl() override; void Reset() override; void LogRenderCall() override; - rtc::Optional GetDelay( + absl::optional GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, - const rtc::Optional& echo_remover_delay, + const absl::optional& echo_remover_delay, rtc::ArrayView capture) override; private: @@ -63,14 +63,14 @@ class RenderDelayControllerImpl final : public RenderDelayController { const int hysteresis_limit_1_blocks_; const int hysteresis_limit_2_blocks_; const int skew_hysteresis_blocks_; - rtc::Optional delay_; + absl::optional delay_; EchoPathDelayEstimator delay_estimator_; std::vector delay_buf_; int delay_buf_index_ = 0; RenderDelayControllerMetrics metrics_; SkewEstimator skew_estimator_; - rtc::Optional delay_samples_; - rtc::Optional skew_; + absl::optional delay_samples_; + absl::optional skew_; int previous_offset_blocks_ = 0; int skew_shift_reporting_counter_ = 0; size_t capture_call_counter_ = 0; @@ -80,7 +80,7 @@ class RenderDelayControllerImpl final : public RenderDelayController { }; DelayEstimate ComputeBufferDelay( - const rtc::Optional& current_delay, + const absl::optional& current_delay, int delay_headroom_blocks, int hysteresis_limit_1_blocks, int hysteresis_limit_2_blocks, @@ -142,9 +142,9 @@ RenderDelayControllerImpl::RenderDelayControllerImpl( RenderDelayControllerImpl::~RenderDelayControllerImpl() = default; void RenderDelayControllerImpl::Reset() { - delay_ = rtc::nullopt; - delay_samples_ = rtc::nullopt; - skew_ = rtc::nullopt; + delay_ = absl::nullopt; + delay_samples_ = absl::nullopt; + skew_ = absl::nullopt; previous_offset_blocks_ = 0; std::fill(delay_buf_.begin(), delay_buf_.end(), 0.f); delay_estimator_.Reset(false); @@ -157,10 +157,10 @@ void RenderDelayControllerImpl::LogRenderCall() { skew_estimator_.LogRenderCall(); } -rtc::Optional RenderDelayControllerImpl::GetDelay( +absl::optional RenderDelayControllerImpl::GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, - const rtc::Optional& echo_remover_delay, + const absl::optional& echo_remover_delay, rtc::ArrayView capture) { RTC_DCHECK_EQ(kBlockSize, capture.size()); ++capture_call_counter_; @@ -185,7 +185,7 @@ rtc::Optional RenderDelayControllerImpl::GetDelay( delay_buf_index_ = (delay_buf_index_ + kBlockSize) % delay_buf_.size(); // Compute the latest skew update. - rtc::Optional skew = skew_estimator_.GetSkewFromCapture(); + absl::optional skew = skew_estimator_.GetSkewFromCapture(); if (delay_samples) { // TODO(peah): Refactor the rest of the code to assume a kRefined estimate @@ -241,11 +241,11 @@ rtc::Optional RenderDelayControllerImpl::GetDelay( // Log any changes in the skew. skew_shift_reporting_counter_ = std::max(0, skew_shift_reporting_counter_ - 1); - rtc::Optional skew_shift = + absl::optional skew_shift = skew_shift_reporting_counter_ == 0 && previous_offset_blocks_ != offset_blocks - ? rtc::Optional(offset_blocks - previous_offset_blocks_) - : rtc::nullopt; + ? absl::optional(offset_blocks - previous_offset_blocks_) + : absl::nullopt; previous_offset_blocks_ = offset_blocks; if (skew_shift) { RTC_LOG(LS_WARNING) << "API call skew shift of " << *skew_shift @@ -261,8 +261,8 @@ rtc::Optional RenderDelayControllerImpl::GetDelay( hysteresis_limit_2_blocks_, offset_blocks, *delay_samples_); } - metrics_.Update(delay_samples_ ? rtc::Optional(delay_samples_->delay) - : rtc::nullopt, + metrics_.Update(delay_samples_ ? absl::optional(delay_samples_->delay) + : absl::nullopt, delay_ ? delay_->delay : 0, skew_shift); data_dumper_->DumpRaw("aec3_render_delay_controller_delay", diff --git a/modules/audio_processing/aec3/render_delay_controller.h b/modules/audio_processing/aec3/render_delay_controller.h index 1e1df0d72d..ddd95482fc 100644 --- a/modules/audio_processing/aec3/render_delay_controller.h +++ b/modules/audio_processing/aec3/render_delay_controller.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ +#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/aec3/render_delay_buffer.h" @@ -36,10 +36,10 @@ class RenderDelayController { virtual void LogRenderCall() = 0; // Aligns the render buffer content with the capture signal. - virtual rtc::Optional GetDelay( + virtual absl::optional GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, - const rtc::Optional& echo_remover_delay, + const absl::optional& echo_remover_delay, rtc::ArrayView capture) = 0; }; } // namespace webrtc diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics.cc b/modules/audio_processing/aec3/render_delay_controller_metrics.cc index 2da2227967..09db339683 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics.cc +++ b/modules/audio_processing/aec3/render_delay_controller_metrics.cc @@ -43,9 +43,9 @@ constexpr int kMaxSkewShiftCount = 20; RenderDelayControllerMetrics::RenderDelayControllerMetrics() = default; void RenderDelayControllerMetrics::Update( - rtc::Optional delay_samples, + absl::optional delay_samples, size_t buffer_delay_blocks, - rtc::Optional skew_shift_blocks) { + absl::optional skew_shift_blocks) { ++call_counter_; if (!initial_update) { diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics.h b/modules/audio_processing/aec3/render_delay_controller_metrics.h index 8c8845e62c..1cfe899b48 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics.h +++ b/modules/audio_processing/aec3/render_delay_controller_metrics.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_ #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_ -#include "api/optional.h" +#include "absl/types/optional.h" #include "rtc_base/constructormagic.h" namespace webrtc { @@ -22,9 +22,9 @@ class RenderDelayControllerMetrics { RenderDelayControllerMetrics(); // Updates the metric with new data. - void Update(rtc::Optional delay_samples, + void Update(absl::optional delay_samples, size_t buffer_delay_blocks, - rtc::Optional skew_shift_blocks); + absl::optional skew_shift_blocks); // Returns true if the metrics have just been reported, otherwise false. bool MetricsReported() { return metrics_reported_; } diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc index 1129f499c9..e867de4df4 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc +++ b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc @@ -9,7 +9,7 @@ */ #include "modules/audio_processing/aec3/render_delay_controller_metrics.h" -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "test/gtest.h" @@ -22,10 +22,10 @@ TEST(RenderDelayControllerMetrics, NormalUsage) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < kMetricsReportingIntervalBlocks - 1; ++k) { - metrics.Update(rtc::nullopt, 0, rtc::nullopt); + metrics.Update(absl::nullopt, 0, absl::nullopt); EXPECT_FALSE(metrics.MetricsReported()); } - metrics.Update(rtc::nullopt, 0, rtc::nullopt); + metrics.Update(absl::nullopt, 0, absl::nullopt); EXPECT_TRUE(metrics.MetricsReported()); } } diff --git a/modules/audio_processing/aec3/render_delay_controller_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_unittest.cc index 2c9bbef3fb..98d5b259dc 100644 --- a/modules/audio_processing/aec3/render_delay_controller_unittest.cc +++ b/modules/audio_processing/aec3/render_delay_controller_unittest.cc @@ -48,7 +48,7 @@ constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; TEST(RenderDelayController, NoRenderSignal) { std::vector block(kBlockSize, 0.f); EchoCanceller3Config config; - rtc::Optional echo_remover_delay_; + absl::optional echo_remover_delay_; for (size_t num_matched_filters = 4; num_matched_filters == 10; num_matched_filters++) { for (auto down_sampling_factor : kDownSamplingFactors) { @@ -75,8 +75,8 @@ TEST(RenderDelayController, NoRenderSignal) { // Verifies the basic API call sequence. TEST(RenderDelayController, BasicApiCalls) { std::vector capture_block(kBlockSize, 0.f); - rtc::Optional delay_blocks; - rtc::Optional echo_remover_delay; + absl::optional delay_blocks; + absl::optional echo_remover_delay; for (size_t num_matched_filters = 4; num_matched_filters == 10; num_matched_filters++) { for (auto down_sampling_factor : kDownSamplingFactors) { @@ -111,7 +111,7 @@ TEST(RenderDelayController, BasicApiCalls) { // simple timeshifts between the signals. TEST(RenderDelayController, Alignment) { Random random_generator(42U); - rtc::Optional echo_remover_delay; + absl::optional echo_remover_delay; std::vector capture_block(kBlockSize, 0.f); for (size_t num_matched_filters = 4; num_matched_filters == 10; num_matched_filters++) { @@ -125,7 +125,7 @@ TEST(RenderDelayController, Alignment) { NumBandsForRate(rate), std::vector(kBlockSize, 0.f)); for (size_t delay_samples : {15, 50, 150, 200, 800, 4000}) { - rtc::Optional delay_blocks; + absl::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, delay_samples)); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, NumBandsForRate(rate))); @@ -162,7 +162,7 @@ TEST(RenderDelayController, Alignment) { // delays. TEST(RenderDelayController, NonCausalAlignment) { Random random_generator(42U); - rtc::Optional echo_remover_delay; + absl::optional echo_remover_delay; for (size_t num_matched_filters = 4; num_matched_filters == 10; num_matched_filters++) { for (auto down_sampling_factor : kDownSamplingFactors) { @@ -176,7 +176,7 @@ TEST(RenderDelayController, NonCausalAlignment) { NumBandsForRate(rate), std::vector(kBlockSize, 0.f)); for (int delay_samples : {-15, -50, -150, -200}) { - rtc::Optional delay_blocks; + absl::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, -delay_samples)); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, NumBandsForRate(rate))); @@ -208,7 +208,7 @@ TEST(RenderDelayController, NonCausalAlignment) { // simple timeshifts between the signals when there is jitter in the API calls. TEST(RenderDelayController, AlignmentWithJitter) { Random random_generator(42U); - rtc::Optional echo_remover_delay; + absl::optional echo_remover_delay; std::vector capture_block(kBlockSize, 0.f); for (size_t num_matched_filters = 4; num_matched_filters == 10; num_matched_filters++) { @@ -220,7 +220,7 @@ TEST(RenderDelayController, AlignmentWithJitter) { std::vector> render_block( NumBandsForRate(rate), std::vector(kBlockSize, 0.f)); for (size_t delay_samples : {15, 50, 300, 800}) { - rtc::Optional delay_blocks; + absl::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, delay_samples)); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, NumBandsForRate(rate))); @@ -296,7 +296,7 @@ TEST(RenderDelayController, InitialHeadroom) { TEST(RenderDelayController, WrongCaptureSize) { std::vector block(kBlockSize - 1, 0.f); EchoCanceller3Config config; - rtc::Optional echo_remover_delay; + absl::optional echo_remover_delay; for (auto rate : {8000, 16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr render_delay_buffer( diff --git a/modules/audio_processing/aec3/render_signal_analyzer.cc b/modules/audio_processing/aec3/render_signal_analyzer.cc index 10b68b0ff2..50c34ce43f 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer.cc @@ -23,7 +23,7 @@ constexpr size_t kCounterThreshold = 5; // Identifies local bands with narrow characteristics. void IdentifySmallNarrowBandRegions( const RenderBuffer& render_buffer, - const rtc::Optional& delay_partitions, + const absl::optional& delay_partitions, std::array* narrow_band_counters) { if (!delay_partitions) { narrow_band_counters->fill(0); @@ -43,7 +43,7 @@ void IdentifySmallNarrowBandRegions( // Identifies whether the signal has a single strong narrow-band component. void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer, int strong_peak_freeze_duration, - rtc::Optional* narrow_peak_band, + absl::optional* narrow_peak_band, size_t* narrow_peak_counter) { const auto X2_latest = render_buffer.Spectrum(0); @@ -83,7 +83,7 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer, if (*narrow_peak_band && ++(*narrow_peak_counter) > static_cast(strong_peak_freeze_duration)) { - *narrow_peak_band = rtc::nullopt; + *narrow_peak_band = absl::nullopt; } } } @@ -98,7 +98,7 @@ RenderSignalAnalyzer::~RenderSignalAnalyzer() = default; void RenderSignalAnalyzer::Update( const RenderBuffer& render_buffer, - const rtc::Optional& delay_partitions) { + const absl::optional& delay_partitions) { // Identify bands of narrow nature. IdentifySmallNarrowBandRegions(render_buffer, delay_partitions, &narrow_band_counters_); diff --git a/modules/audio_processing/aec3/render_signal_analyzer.h b/modules/audio_processing/aec3/render_signal_analyzer.h index 8cd2172120..c603c92144 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer.h +++ b/modules/audio_processing/aec3/render_signal_analyzer.h @@ -14,8 +14,8 @@ #include #include +#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" -#include "api/optional.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/render_buffer.h" #include "rtc_base/constructormagic.h" @@ -30,7 +30,7 @@ class RenderSignalAnalyzer { // Updates the render signal analysis with the most recent render signal. void Update(const RenderBuffer& render_buffer, - const rtc::Optional& delay_partitions); + const absl::optional& delay_partitions); // Returns true if the render signal is poorly exciting. bool PoorSignalExcitation() const { @@ -44,12 +44,12 @@ class RenderSignalAnalyzer { void MaskRegionsAroundNarrowBands( std::array* v) const; - rtc::Optional NarrowPeakBand() const { return narrow_peak_band_; } + absl::optional NarrowPeakBand() const { return narrow_peak_band_; } private: const int strong_peak_freeze_duration_; std::array narrow_band_counters_; - rtc::Optional narrow_peak_band_; + absl::optional narrow_peak_band_; size_t narrow_peak_counter_; RTC_DISALLOW_COPY_AND_ASSIGN(RenderSignalAnalyzer); diff --git a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc index 51918745d5..f9b1955838 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc @@ -73,7 +73,7 @@ TEST(RenderSignalAnalyzer, NoFalseDetectionOfNarrowBands) { render_delay_buffer->PrepareCaptureProcessing(); analyzer.Update(*render_delay_buffer->GetRenderBuffer(), - rtc::Optional(0)); + absl::optional(0)); } mask.fill(1.f); @@ -112,7 +112,7 @@ TEST(RenderSignalAnalyzer, NarrowBandDetection) { render_delay_buffer->PrepareCaptureProcessing(); analyzer.Update(*render_delay_buffer->GetRenderBuffer(), - known_delay ? rtc::Optional(0) : rtc::nullopt); + known_delay ? absl::optional(0) : absl::nullopt); } }; diff --git a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc index 7f9ad8d6bf..30f3ddcf96 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc @@ -63,7 +63,7 @@ TEST(ResidualEchoEstimator, DISABLED_BasicTest) { Random random_generator(42U); std::array s; Aec3Fft fft; - rtc::Optional delay_estimate; + absl::optional delay_estimate; for (auto& H2_k : H2) { H2_k.fill(0.01f); diff --git a/modules/audio_processing/aec3/skew_estimator.cc b/modules/audio_processing/aec3/skew_estimator.cc index 5a453a051f..310e4e9dd1 100644 --- a/modules/audio_processing/aec3/skew_estimator.cc +++ b/modules/audio_processing/aec3/skew_estimator.cc @@ -28,7 +28,7 @@ void SkewEstimator::Reset() { std::fill(skew_history_.begin(), skew_history_.end(), 0); } -rtc::Optional SkewEstimator::GetSkewFromCapture() { +absl::optional SkewEstimator::GetSkewFromCapture() { --skew_; skew_sum_ += skew_ - skew_history_[next_index_]; @@ -40,7 +40,7 @@ rtc::Optional SkewEstimator::GetSkewFromCapture() { const int bias = static_cast(skew_history_.size()) >> 1; const int average = (skew_sum_ + bias) >> skew_history_size_log2_; - return sufficient_skew_stored_ ? rtc::Optional(average) : rtc::nullopt; + return sufficient_skew_stored_ ? absl::optional(average) : absl::nullopt; } } // namespace webrtc diff --git a/modules/audio_processing/aec3/skew_estimator.h b/modules/audio_processing/aec3/skew_estimator.h index 2afcd76694..ff2526025a 100644 --- a/modules/audio_processing/aec3/skew_estimator.h +++ b/modules/audio_processing/aec3/skew_estimator.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "rtc_base/constructormagic.h" namespace webrtc { @@ -32,7 +32,7 @@ class SkewEstimator { // Updates and computes the skew at a capture call. Returns an optional which // is non-null if a reliable skew has been found. - rtc::Optional GetSkewFromCapture(); + absl::optional GetSkewFromCapture(); private: const int skew_history_size_log2_; diff --git a/modules/audio_processing/aec3/skew_estimator_unittest.cc b/modules/audio_processing/aec3/skew_estimator_unittest.cc index 168470a17b..3e8c13e23c 100644 --- a/modules/audio_processing/aec3/skew_estimator_unittest.cc +++ b/modules/audio_processing/aec3/skew_estimator_unittest.cc @@ -30,7 +30,7 @@ TEST(SkewEstimator, SkewChangeAdaptation) { estimator.LogRenderCall(); - rtc::Optional skew; + absl::optional skew; for (int k = 0; k < kNumSkews; ++k) { estimator.LogRenderCall(); skew = estimator.GetSkewFromCapture(); @@ -63,7 +63,7 @@ TEST(SkewEstimator, SkewForSurplusRender) { estimator.LogRenderCall(); - rtc::Optional skew; + absl::optional skew; for (int k = 0; k < kNumSkews; ++k) { estimator.LogRenderCall(); skew = estimator.GetSkewFromCapture(); @@ -85,7 +85,7 @@ TEST(SkewEstimator, SkewForSurplusCapture) { EXPECT_FALSE(skew); } - rtc::Optional skew; + absl::optional skew; skew = estimator.GetSkewFromCapture(); for (int k = 0; k < kNumSkews; ++k) { @@ -128,7 +128,7 @@ TEST(SkewEstimator, SkewRounding) { SkewEstimator estimator(kNumSkewsLog2); - rtc::Optional skew; + absl::optional skew; for (int k = 0; k < kNumSkews; ++k) { if (k == kNumSkews - 1) { // Reverse call order once. diff --git a/modules/audio_processing/aec3/subtractor_unittest.cc b/modules/audio_processing/aec3/subtractor_unittest.cc index 097d7e8243..3c896ee0ca 100644 --- a/modules/audio_processing/aec3/subtractor_unittest.cc +++ b/modules/audio_processing/aec3/subtractor_unittest.cc @@ -33,7 +33,7 @@ float RunSubtractorTest(int num_blocks_to_process, config.filter.main.length_blocks = config.filter.shadow.length_blocks = filter_length_blocks; Subtractor subtractor(config, &data_dumper, DetectOptimization()); - rtc::Optional delay_estimate; + absl::optional delay_estimate; std::vector> x(3, std::vector(kBlockSize, 0.f)); std::vector y(kBlockSize, 0.f); std::array x_old; diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index 1328601c4e..2098fc25f8 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc @@ -54,7 +54,7 @@ void AdjustForExternalFilters(std::array* gain) { // Computes the gain to apply for the bands beyond the first band. float UpperBandsGain( - const rtc::Optional& narrow_peak_band, + const absl::optional& narrow_peak_band, bool saturated_echo, const std::vector>& render, const std::array& low_band_gain) { @@ -415,7 +415,7 @@ void SuppressionGain::GetGain( // Compute gain for the lower band. bool low_noise_render = low_render_detector_.Detect(render); - const rtc::Optional narrow_peak_band = + const absl::optional narrow_peak_band = render_signal_analyzer.NarrowPeakBand(); LowerBandGain(low_noise_render, aec_state, nearend_spectrum, echo_spectrum, comfort_noise_spectrum, low_band_gain); diff --git a/modules/audio_processing/aec3/suppression_gain_unittest.cc b/modules/audio_processing/aec3/suppression_gain_unittest.cc index 128c61eaf3..7e5ee9fdb4 100644 --- a/modules/audio_processing/aec3/suppression_gain_unittest.cc +++ b/modules/audio_processing/aec3/suppression_gain_unittest.cc @@ -78,7 +78,7 @@ TEST(SuppressionGain, BasicGainComputation) { Subtractor subtractor(config, &data_dumper, DetectOptimization()); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, 3)); - rtc::Optional delay_estimate; + absl::optional delay_estimate; // Ensure that a strong noise is detected to mask any echoes. E2.fill(10.f); diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index 71fefe4786..2c36a7cdf2 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -1677,15 +1677,15 @@ AudioProcessingStats AudioProcessingImpl::GetStatistics( Error::kNoError) { if (metrics.divergent_filter_fraction != -1.0f) { stats.divergent_filter_fraction = - rtc::Optional(metrics.divergent_filter_fraction); + absl::optional(metrics.divergent_filter_fraction); } if (metrics.echo_return_loss.instant != -100) { stats.echo_return_loss = - rtc::Optional(metrics.echo_return_loss.instant); + absl::optional(metrics.echo_return_loss.instant); } if (metrics.echo_return_loss_enhancement.instant != -100) { - stats.echo_return_loss_enhancement = - rtc::Optional(metrics.echo_return_loss_enhancement.instant); + stats.echo_return_loss_enhancement = absl::optional( + metrics.echo_return_loss_enhancement.instant); } } if (config_.residual_echo_detector.enabled) { @@ -1702,10 +1702,10 @@ AudioProcessingStats AudioProcessingImpl::GetStatistics( &delay_median, &delay_std, &fraction_poor_delays) == Error::kNoError) { if (delay_median >= 0) { - stats.delay_median_ms = rtc::Optional(delay_median); + stats.delay_median_ms = absl::optional(delay_median); } if (delay_std >= 0) { - stats.delay_standard_deviation_ms = rtc::Optional(delay_std); + stats.delay_standard_deviation_ms = absl::optional(delay_std); } } } diff --git a/modules/audio_processing/beamformer/array_util.cc b/modules/audio_processing/beamformer/array_util.cc index e853559140..0e461e9cc4 100644 --- a/modules/audio_processing/beamformer/array_util.cc +++ b/modules/audio_processing/beamformer/array_util.cc @@ -56,7 +56,7 @@ bool ArePerpendicular(const Point& a, const Point& b) { return std::abs(DotProduct(a, b)) < kMaxDotProduct; } -rtc::Optional GetDirectionIfLinear( +absl::optional GetDirectionIfLinear( const std::vector& array_geometry) { RTC_DCHECK_GT(array_geometry.size(), 1); const Point first_pair_direction = @@ -65,13 +65,13 @@ rtc::Optional GetDirectionIfLinear( const Point pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]); if (!AreParallel(first_pair_direction, pair_direction)) { - return rtc::nullopt; + return absl::nullopt; } } return first_pair_direction; } -rtc::Optional GetNormalIfPlanar( +absl::optional GetNormalIfPlanar( const std::vector& array_geometry) { RTC_DCHECK_GT(array_geometry.size(), 1); const Point first_pair_direction = @@ -86,30 +86,30 @@ rtc::Optional GetNormalIfPlanar( } } if (is_linear) { - return rtc::nullopt; + return absl::nullopt; } const Point normal_direction = CrossProduct(first_pair_direction, pair_direction); for (; i < array_geometry.size(); ++i) { pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]); if (!ArePerpendicular(normal_direction, pair_direction)) { - return rtc::nullopt; + return absl::nullopt; } } return normal_direction; } -rtc::Optional GetArrayNormalIfExists( +absl::optional GetArrayNormalIfExists( const std::vector& array_geometry) { - const rtc::Optional direction = GetDirectionIfLinear(array_geometry); + const absl::optional direction = GetDirectionIfLinear(array_geometry); if (direction) { return Point(direction->y(), -direction->x(), 0.f); } - const rtc::Optional normal = GetNormalIfPlanar(array_geometry); + const absl::optional normal = GetNormalIfPlanar(array_geometry); if (normal && normal->z() < kMaxDotProduct) { return normal; } - return rtc::nullopt; + return absl::nullopt; } Point AzimuthToPoint(float azimuth) { diff --git a/modules/audio_processing/beamformer/array_util.h b/modules/audio_processing/beamformer/array_util.h index f234929693..8e69f81f7e 100644 --- a/modules/audio_processing/beamformer/array_util.h +++ b/modules/audio_processing/beamformer/array_util.h @@ -14,7 +14,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -59,16 +59,16 @@ float GetMinimumSpacing(const std::vector& array_geometry); // If the given array geometry is linear it returns the direction without // normalizing. -rtc::Optional GetDirectionIfLinear( +absl::optional GetDirectionIfLinear( const std::vector& array_geometry); // If the given array geometry is planar it returns the normal without // normalizing. -rtc::Optional GetNormalIfPlanar( +absl::optional GetNormalIfPlanar( const std::vector& array_geometry); // Returns the normal of an array if it has one and it is in the xy-plane. -rtc::Optional GetArrayNormalIfExists( +absl::optional GetArrayNormalIfExists( const std::vector& array_geometry); // The resulting Point will be in the xy-plane. diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer.h b/modules/audio_processing/beamformer/nonlinear_beamformer.h index 5b79dc467e..9ae28edc1f 100644 --- a/modules/audio_processing/beamformer/nonlinear_beamformer.h +++ b/modules/audio_processing/beamformer/nonlinear_beamformer.h @@ -164,7 +164,7 @@ class NonlinearBeamformer : public LappedTransform::Callback { const std::vector array_geometry_; // The normal direction of the array if it has one and it is in the xy-plane. - const rtc::Optional array_normal_; + const absl::optional array_normal_; // Minimum spacing between microphone pairs. const float min_mic_spacing_; diff --git a/modules/audio_processing/echo_detector/circular_buffer.cc b/modules/audio_processing/echo_detector/circular_buffer.cc index 0c6cc8a933..a6d10edfe2 100644 --- a/modules/audio_processing/echo_detector/circular_buffer.cc +++ b/modules/audio_processing/echo_detector/circular_buffer.cc @@ -28,9 +28,9 @@ void CircularBuffer::Push(float value) { RTC_DCHECK_LE(nr_elements_in_buffer_, buffer_.size()); } -rtc::Optional CircularBuffer::Pop() { +absl::optional CircularBuffer::Pop() { if (nr_elements_in_buffer_ == 0) { - return rtc::nullopt; + return absl::nullopt; } const size_t index = (buffer_.size() + next_insertion_index_ - nr_elements_in_buffer_) % diff --git a/modules/audio_processing/echo_detector/circular_buffer.h b/modules/audio_processing/echo_detector/circular_buffer.h index 53d4afb6d5..9f5cdfa953 100644 --- a/modules/audio_processing/echo_detector/circular_buffer.h +++ b/modules/audio_processing/echo_detector/circular_buffer.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -24,7 +24,7 @@ struct CircularBuffer { ~CircularBuffer(); void Push(float value); - rtc::Optional Pop(); + absl::optional Pop(); size_t Size() const { return nr_elements_in_buffer_; } // This function fills the buffer with zeros, but does not change its size. void Clear(); diff --git a/modules/audio_processing/echo_detector/circular_buffer_unittest.cc b/modules/audio_processing/echo_detector/circular_buffer_unittest.cc index 657bd05888..0fa2a2b2f7 100644 --- a/modules/audio_processing/echo_detector/circular_buffer_unittest.cc +++ b/modules/audio_processing/echo_detector/circular_buffer_unittest.cc @@ -46,7 +46,7 @@ TEST(CircularBufferTests, OverflowTest) { TEST(CircularBufferTests, ReadFromEmpty) { CircularBuffer test_buffer(3); - EXPECT_EQ(rtc::nullopt, test_buffer.Pop()); + EXPECT_EQ(absl::nullopt, test_buffer.Pop()); } } // namespace webrtc diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc index e550ebbfad..8be261c071 100644 --- a/modules/audio_processing/gain_control_impl.cc +++ b/modules/audio_processing/gain_control_impl.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/gain_control_impl.h" -#include "api/optional.h" +#include "absl/types/optional.h" #include "modules/audio_processing/agc/legacy/gain_control.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -80,7 +80,7 @@ class GainControlImpl::GainController { Handle* state_; // TODO(peah): Remove the optional once the initialization is moved into the // ctor. - rtc::Optional capture_level_; + absl::optional capture_level_; RTC_DISALLOW_COPY_AND_ASSIGN(GainController); }; diff --git a/modules/audio_processing/gain_control_impl.h b/modules/audio_processing/gain_control_impl.h index 26745065cf..959422fb44 100644 --- a/modules/audio_processing/gain_control_impl.h +++ b/modules/audio_processing/gain_control_impl.h @@ -86,8 +86,8 @@ class GainControlImpl : public GainControl { std::vector> gain_controllers_; - rtc::Optional num_proc_channels_ RTC_GUARDED_BY(crit_capture_); - rtc::Optional sample_rate_hz_ RTC_GUARDED_BY(crit_capture_); + absl::optional num_proc_channels_ RTC_GUARDED_BY(crit_capture_); + absl::optional sample_rate_hz_ RTC_GUARDED_BY(crit_capture_); static int instance_counter_; RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlImpl); diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index e4fb9b22ab..d5bdeeaecc 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -22,9 +22,9 @@ #include #include +#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" -#include "api/optional.h" #include "modules/audio_processing/beamformer/array_util.h" #include "modules/audio_processing/include/audio_generator.h" #include "modules/audio_processing/include/audio_processing_statistics.h" diff --git a/modules/audio_processing/include/audio_processing_statistics.h b/modules/audio_processing/include/audio_processing_statistics.h index 05c59054b3..237d23c5bc 100644 --- a/modules/audio_processing/include/audio_processing_statistics.h +++ b/modules/audio_processing/include/audio_processing_statistics.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_STATISTICS_H_ #define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_STATISTICS_H_ -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { // This version of the stats uses Optionals, it will replace the regular @@ -23,12 +23,12 @@ struct AudioProcessingStats { // AEC Statistics. // ERL = 10log_10(P_far / P_echo) - rtc::Optional echo_return_loss; + absl::optional echo_return_loss; // ERLE = 10log_10(P_echo / P_out) - rtc::Optional echo_return_loss_enhancement; + absl::optional echo_return_loss_enhancement; // Fraction of time that the AEC linear filter is divergent, in a 1-second // non-overlapped aggregation window. - rtc::Optional divergent_filter_fraction; + absl::optional divergent_filter_fraction; // The delay metrics consists of the delay median and standard deviation. It // also consists of the fraction of delay estimates that can make the echo @@ -37,18 +37,18 @@ struct AudioProcessingStats { // second. Note that if there are several clients pulling metrics from // |GetStatistics()| during a session the first call from any of them will // change to one second aggregation window for all. - rtc::Optional delay_median_ms; - rtc::Optional delay_standard_deviation_ms; + absl::optional delay_median_ms; + absl::optional delay_standard_deviation_ms; // Residual echo detector likelihood. - rtc::Optional residual_echo_likelihood; + absl::optional residual_echo_likelihood; // Maximum residual echo likelihood from the last time period. - rtc::Optional residual_echo_likelihood_recent_max; + absl::optional residual_echo_likelihood_recent_max; // The instantaneous delay estimate produced in the AEC. The unit is in // milliseconds and the value is the instantaneous value at the time of the // call to |GetStatistics()|. - rtc::Optional delay_ms; + absl::optional delay_ms; }; } // namespace webrtc diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc index f506579bad..aec545aa41 100644 --- a/modules/audio_processing/residual_echo_detector.cc +++ b/modules/audio_processing/residual_echo_detector.cc @@ -90,7 +90,7 @@ void ResidualEchoDetector::AnalyzeCaptureAudio( } // Get the next render value. - const rtc::Optional buffered_render_power = render_buffer_.Pop(); + const absl::optional buffered_render_power = render_buffer_.Pop(); if (!buffered_render_power) { // This can happen in a few cases: at the start of a call, due to a glitch // or due to clock drift. The excess capture value will be ignored. diff --git a/modules/audio_processing/rms_level.cc b/modules/audio_processing/rms_level.cc index 55db226af2..727ecfc9fe 100644 --- a/modules/audio_processing/rms_level.cc +++ b/modules/audio_processing/rms_level.cc @@ -54,7 +54,7 @@ void RmsLevel::Reset() { sum_square_ = 0.f; sample_count_ = 0; max_sum_square_ = 0.f; - block_size_ = rtc::nullopt; + block_size_ = absl::nullopt; } void RmsLevel::Analyze(rtc::ArrayView data) { @@ -88,7 +88,7 @@ int RmsLevel::Average() { RmsLevel::Levels RmsLevel::AverageAndPeak() { // Note that block_size_ should by design always be non-empty when - // sample_count_ != 0. Also, the * operator of rtc::Optional enforces this + // sample_count_ != 0. Also, the * operator of absl::optional enforces this // with a DCHECK. Levels levels = (sample_count_ == 0) ? Levels{RmsLevel::kMinLevelDb, RmsLevel::kMinLevelDb} diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h index 6fe22fd120..ae124b7299 100644 --- a/modules/audio_processing/rms_level.h +++ b/modules/audio_processing/rms_level.h @@ -11,8 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ #define MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ +#include "absl/types/optional.h" #include "api/array_view.h" -#include "api/optional.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { @@ -66,7 +66,7 @@ class RmsLevel { float sum_square_; size_t sample_count_; float max_sum_square_; - rtc::Optional block_size_; + absl::optional block_size_; }; } // namespace webrtc diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index a98f8fc4ce..522f778939 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h @@ -17,7 +17,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "common_audio/channel_buffer.h" #include "modules/audio_processing/include/audio_processing.h" #include "modules/audio_processing/test/fake_recording_device.h" @@ -34,63 +34,63 @@ struct SimulationSettings { SimulationSettings(); SimulationSettings(const SimulationSettings&); ~SimulationSettings(); - rtc::Optional stream_delay; - rtc::Optional use_stream_delay; - rtc::Optional stream_drift_samples; - rtc::Optional output_sample_rate_hz; - rtc::Optional output_num_channels; - rtc::Optional reverse_output_sample_rate_hz; - rtc::Optional reverse_output_num_channels; - rtc::Optional output_filename; - rtc::Optional reverse_output_filename; - rtc::Optional input_filename; - rtc::Optional reverse_input_filename; - rtc::Optional artificial_nearend_filename; - rtc::Optional use_aec; - rtc::Optional use_aecm; - rtc::Optional use_ed; // Residual Echo Detector. - rtc::Optional ed_graph_output_filename; - rtc::Optional use_agc; - rtc::Optional use_agc2; - rtc::Optional use_pre_amplifier; - rtc::Optional use_hpf; - rtc::Optional use_ns; - rtc::Optional use_ts; - rtc::Optional use_bf; - rtc::Optional use_ie; - rtc::Optional use_vad; - rtc::Optional use_le; - rtc::Optional use_all; - rtc::Optional aec_suppression_level; - rtc::Optional use_delay_agnostic; - rtc::Optional use_extended_filter; - rtc::Optional use_drift_compensation; - rtc::Optional use_aec3; - rtc::Optional use_experimental_agc; - rtc::Optional aecm_routing_mode; - rtc::Optional use_aecm_comfort_noise; - rtc::Optional agc_mode; - rtc::Optional agc_target_level; - rtc::Optional use_agc_limiter; - rtc::Optional agc_compression_gain; + absl::optional stream_delay; + absl::optional use_stream_delay; + absl::optional stream_drift_samples; + absl::optional output_sample_rate_hz; + absl::optional output_num_channels; + absl::optional reverse_output_sample_rate_hz; + absl::optional reverse_output_num_channels; + absl::optional output_filename; + absl::optional reverse_output_filename; + absl::optional input_filename; + absl::optional reverse_input_filename; + absl::optional artificial_nearend_filename; + absl::optional use_aec; + absl::optional use_aecm; + absl::optional use_ed; // Residual Echo Detector. + absl::optional ed_graph_output_filename; + absl::optional use_agc; + absl::optional use_agc2; + absl::optional use_pre_amplifier; + absl::optional use_hpf; + absl::optional use_ns; + absl::optional use_ts; + absl::optional use_bf; + absl::optional use_ie; + absl::optional use_vad; + absl::optional use_le; + absl::optional use_all; + absl::optional aec_suppression_level; + absl::optional use_delay_agnostic; + absl::optional use_extended_filter; + absl::optional use_drift_compensation; + absl::optional use_aec3; + absl::optional use_experimental_agc; + absl::optional aecm_routing_mode; + absl::optional use_aecm_comfort_noise; + absl::optional agc_mode; + absl::optional agc_target_level; + absl::optional use_agc_limiter; + absl::optional agc_compression_gain; float agc2_fixed_gain_db; float pre_amplifier_gain_factor; - rtc::Optional vad_likelihood; - rtc::Optional ns_level; - rtc::Optional use_refined_adaptive_filter; + absl::optional vad_likelihood; + absl::optional ns_level; + absl::optional use_refined_adaptive_filter; int initial_mic_level; bool simulate_mic_gain = false; - rtc::Optional simulated_mic_kind; + absl::optional simulated_mic_kind; bool report_performance = false; bool report_bitexactness = false; bool use_verbose_logging = false; bool discard_all_settings_in_aecdump = true; - rtc::Optional aec_dump_input_filename; - rtc::Optional aec_dump_output_filename; + absl::optional aec_dump_input_filename; + absl::optional aec_dump_output_filename; bool fixed_interface = false; bool store_intermediate_output = false; - rtc::Optional custom_call_order_filename; - rtc::Optional aec3_settings_filename; + absl::optional custom_call_order_filename; + absl::optional aec3_settings_filename; }; // Holds a few statistics about a series of TickIntervals. diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index bfaa13620a..6a3f31632f 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -184,19 +184,19 @@ DEFINE_string(aec3_settings, DEFINE_bool(help, false, "Print this message"); void SetSettingIfSpecified(const std::string& value, - rtc::Optional* parameter) { + absl::optional* parameter) { if (value.compare("") != 0) { *parameter = value; } } -void SetSettingIfSpecified(int value, rtc::Optional* parameter) { +void SetSettingIfSpecified(int value, absl::optional* parameter) { if (value != kParameterNotSpecifiedValue) { *parameter = value; } } -void SetSettingIfFlagSet(int32_t flag, rtc::Optional* parameter) { +void SetSettingIfFlagSet(int32_t flag, absl::optional* parameter) { if (flag == 0) { *parameter = false; } else if (flag == 1) { diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn index b1cb079b24..d292604b6d 100644 --- a/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -69,11 +69,11 @@ rtc_source_set("unittest") { "../../../..:webrtc_common", "../../../../:typedefs", "../../../../api:array_view", - "../../../../api:optional", "../../../../common_audio", "../../../../rtc_base:rtc_base_approved", "../../../../test:fileutils", "../../../../test:test_support", "//testing/gtest", + "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/modules/audio_processing/test/conversational_speech/generator_unittest.cc index 3a05762887..5ef11db5db 100644 --- a/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -42,7 +42,7 @@ #include #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/conversational_speech/config.h" #include "modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h" @@ -149,7 +149,7 @@ void CheckAudioTrackParams(const WavReaderFactory& wav_reader_factory, void DeleteFolderAndContents(const std::string& dir) { if (!DirExists(dir)) { return; } - rtc::Optional> dir_content = ReadDirectory(dir); + absl::optional> dir_content = ReadDirectory(dir); EXPECT_TRUE(dir_content); for (const auto& path : *dir_content) { if (DirExists(path)) { diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc index 262f347de3..bc95cfd749 100644 --- a/modules/audio_processing/test/debug_dump_replayer.cc +++ b/modules/audio_processing/test/debug_dump_replayer.cc @@ -49,9 +49,9 @@ bool DebugDumpReplayer::SetDumpFile(const std::string& filename) { } // Get next event that has not run. -rtc::Optional DebugDumpReplayer::GetNextEvent() const { +absl::optional DebugDumpReplayer::GetNextEvent() const { if (!has_next_event_) - return rtc::nullopt; + return absl::nullopt; else return next_event_; } diff --git a/modules/audio_processing/test/debug_dump_replayer.h b/modules/audio_processing/test/debug_dump_replayer.h index 4cd961dd7f..aa5d72735a 100644 --- a/modules/audio_processing/test/debug_dump_replayer.h +++ b/modules/audio_processing/test/debug_dump_replayer.h @@ -34,7 +34,7 @@ class DebugDumpReplayer { bool SetDumpFile(const std::string& filename); // Return next event. - rtc::Optional GetNextEvent() const; + absl::optional GetNextEvent() const; // Run the next event. Returns true if succeeded. bool RunNextEvent(); diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index 4d3be48684..d90d14fa8f 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -275,8 +275,8 @@ class DebugDumpTest : public ::testing::Test { void DebugDumpTest::VerifyDebugDump(const std::string& in_filename) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(in_filename)); - while (const rtc::Optional event = - debug_dump_replayer_.GetNextEvent()) { + while (const absl::optional event = + debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::STREAM) { const audioproc::Stream* msg = &event->stream(); @@ -388,7 +388,7 @@ TEST_F(DebugDumpTest, VerifyRefinedAdaptiveFilterExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -416,7 +416,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -444,7 +444,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -472,7 +472,7 @@ TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -497,7 +497,7 @@ TEST_F(DebugDumpTest, VerifyAgcClippingLevelExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -520,7 +520,7 @@ TEST_F(DebugDumpTest, VerifyEmptyExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const rtc::Optional event = + while (const absl::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { diff --git a/modules/audio_processing/test/fake_recording_device.cc b/modules/audio_processing/test/fake_recording_device.cc index 3260ec1e61..9c6ea51086 100644 --- a/modules/audio_processing/test/fake_recording_device.cc +++ b/modules/audio_processing/test/fake_recording_device.cc @@ -12,7 +12,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "rtc_base/logging.h" #include "rtc_base/ptr_util.h" @@ -44,7 +44,7 @@ class FakeRecordingDeviceWorker { // Mic level to simulate. int mic_level_; // Optional mic level to undo. - rtc::Optional undo_mic_level_; + absl::optional undo_mic_level_; }; namespace { diff --git a/modules/audio_processing/test/performance_timer.h b/modules/audio_processing/test/performance_timer.h index 1c862dc78e..b6e0da70d8 100644 --- a/modules/audio_processing/test/performance_timer.h +++ b/modules/audio_processing/test/performance_timer.h @@ -13,7 +13,7 @@ #include -#include "api/optional.h" +#include "absl/types/optional.h" #include "system_wrappers/include/clock.h" namespace webrtc { @@ -37,7 +37,7 @@ class PerformanceTimer { private: webrtc::Clock* clock_; - rtc::Optional start_timestamp_us_; + absl::optional start_timestamp_us_; std::vector timestamps_us_; };