From 0efa941d2ffc8c31a1971f3c7af144bd7549b2c7 Mon Sep 17 00:00:00 2001 From: Gustaf Ullberg Date: Tue, 27 Feb 2018 13:58:45 +0100 Subject: [PATCH] Move EchoCanceller3Factory to api/auido The AEC3 factory is now part of the WebRTC API. Bug: webrtc:8844 Change-Id: If6f419b4ca0354e2d346c0e6474086e456ba747e Reviewed-on: https://webrtc-review.googlesource.com/57141 Commit-Queue: Gustaf Ullberg Reviewed-by: Karl Wiberg Reviewed-by: Alex Loiko Cr-Commit-Position: refs/heads/master@{#22204} --- api/DEPS | 1 + api/audio/BUILD.gn | 2 ++ api/audio/echo_canceller3_factory.cc | 17 ++++++++++++++- api/audio/echo_canceller3_factory.h | 21 ++++++++++++++++++- modules/audio_processing/BUILD.gn | 4 ++-- modules/audio_processing/aec3/BUILD.gn | 12 ++--------- .../audio_processing/aec3/echo_canceller3.cc | 20 ------------------ .../audio_processing/aec3/echo_canceller3.h | 3 --- .../aec3/echo_canceller3_unittest.cc | 5 ----- .../include/audio_processing.h | 10 --------- .../test/audio_processing_simulator.cc | 1 + .../audio_processing/test/debug_dump_test.cc | 1 + test/fuzzers/BUILD.gn | 1 + .../audio_processing_configs_fuzzer.cc | 1 + 14 files changed, 47 insertions(+), 52 deletions(-) diff --git a/api/DEPS b/api/DEPS index 9ba724502c..28914ba6a7 100644 --- a/api/DEPS +++ b/api/DEPS @@ -21,6 +21,7 @@ specific_include_rules = { # since no one #includes them. ".*\.cc": [ "+modules/audio_coding", + "+modules/audio_processing", ], ".*i420_buffer\.h": [ diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn index ab9bae8470..f3bca7cab1 100644 --- a/api/audio/BUILD.gn +++ b/api/audio/BUILD.gn @@ -45,6 +45,7 @@ rtc_source_set("aec3_config") { rtc_source_set("aec3_factory") { visibility = [ "*" ] + configs += [ "../../modules/audio_processing:apm_debug_dump" ] sources = [ "echo_canceller3_factory.cc", "echo_canceller3_factory.h", @@ -54,6 +55,7 @@ rtc_source_set("aec3_factory") { ":aec3_config", ":echo_control", "../../modules/audio_processing/aec3", + "../../rtc_base:rtc_base_approved", ] } diff --git a/api/audio/echo_canceller3_factory.cc b/api/audio/echo_canceller3_factory.cc index bdc76b0dd0..7e2c143c66 100644 --- a/api/audio/echo_canceller3_factory.cc +++ b/api/audio/echo_canceller3_factory.cc @@ -9,4 +9,19 @@ */ #include "api/audio/echo_canceller3_factory.h" -// TODO(bugs.webrtc.org/8844): EchoCanceller3Factory will be moved here. +#include + +#include "modules/audio_processing/aec3/echo_canceller3.h" +#include "rtc_base/ptr_util.h" + +namespace webrtc { + +EchoCanceller3Factory::EchoCanceller3Factory() {} + +EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config& config) + : config_(config) {} + +std::unique_ptr EchoCanceller3Factory::Create(int sample_rate_hz) { + return rtc::MakeUnique(config_, sample_rate_hz, true); +} +} // namespace webrtc diff --git a/api/audio/echo_canceller3_factory.h b/api/audio/echo_canceller3_factory.h index e5a81c8f58..f6db116850 100644 --- a/api/audio/echo_canceller3_factory.h +++ b/api/audio/echo_canceller3_factory.h @@ -11,9 +11,28 @@ #ifndef API_AUDIO_ECHO_CANCELLER3_FACTORY_H_ #define API_AUDIO_ECHO_CANCELLER3_FACTORY_H_ +#include + #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" -// TODO(bugs.webrtc.org/8844): EchoCanceller3Factory will be moved here. +namespace webrtc { + +class EchoCanceller3Factory : public EchoControlFactory { + public: + // Factory producing EchoCanceller3 instances with the default configuration. + EchoCanceller3Factory(); + + // Factory producing EchoCanceller3 instances with the specified + // configuration. + explicit EchoCanceller3Factory(const EchoCanceller3Config& config); + + // Creates an EchoCanceller3 running at the specified sampling rate. + std::unique_ptr Create(int sample_rate_hz) override; + + private: + const EchoCanceller3Config config_; +}; +} // namespace webrtc #endif // API_AUDIO_ECHO_CANCELLER3_FACTORY_H_ diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 6a1a3bb474..68f0971177 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -508,6 +508,7 @@ if (rtc_include_tests) { "../../api:array_view", "../../api:optional", "../../api/audio:aec3_config", + "../../api/audio:aec3_factory", "../../common_audio:common_audio", "../../common_audio:common_audio_c", "../../rtc_base:checks", @@ -519,7 +520,6 @@ if (rtc_include_tests) { "../../system_wrappers:cpu_features_api", "../../test:test_support", "../audio_coding:neteq_input_audio_tools", - "aec3:aec3", "aec_dump:mock_aec_dump_unittests", "agc2:fixed_digital_unittests", "test/conversational_speech:unittest", @@ -651,6 +651,7 @@ if (rtc_include_tests) { ":audioproc_protobuf_utils", ":audioproc_test_utils", "../../api:optional", + "../../api/audio:aec3_factory", "../../common_audio:common_audio", "../../rtc_base:checks", "../../rtc_base:protobuf_utils", @@ -660,7 +661,6 @@ if (rtc_include_tests) { "../../system_wrappers", "../../system_wrappers:system_wrappers_default", "../../test:test_support", - "aec3:aec3", "aec_dump", "aec_dump:aec_dump_impl", "//testing/gtest", diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 0ac47fb201..a1fc0e0743 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -9,17 +9,9 @@ import("//build/config/arm.gni") import("../../../webrtc.gni") -config("apm_debug_dump") { - if (apm_debug_dump) { - defines = [ "WEBRTC_APM_DEBUG_DUMP=1" ] - } else { - defines = [ "WEBRTC_APM_DEBUG_DUMP=0" ] - } -} - rtc_static_library("aec3") { visibility = [ "*" ] - configs += [ ":apm_debug_dump" ] + configs += [ "..:apm_debug_dump" ] sources = [ "adaptive_fir_filter.cc", "adaptive_fir_filter.h", @@ -125,7 +117,7 @@ if (rtc_include_tests) { rtc_source_set("aec3_unittests") { testonly = true - configs += [ ":apm_debug_dump" ] + configs += [ "..:apm_debug_dump" ] sources = [ "mock/mock_block_processor.h", "mock/mock_echo_remover.h", diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc index e3659493a8..f0cbbc85da 100644 --- a/modules/audio_processing/aec3/echo_canceller3.cc +++ b/modules/audio_processing/aec3/echo_canceller3.cc @@ -338,10 +338,6 @@ EchoControl::Metrics EchoCanceller3::GetMetrics() const { return metrics; } -bool EchoCanceller3::Validate(const EchoCanceller3Config& config) { - return true; -} - void EchoCanceller3::EmptyRenderQueue() { RTC_DCHECK_RUNS_SERIALIZED(&capture_race_checker_); bool frame_to_buffer = @@ -363,20 +359,4 @@ void EchoCanceller3::EmptyRenderQueue() { render_transfer_queue_.Remove(&render_queue_output_frame_); } } - -EchoCanceller3Factory::EchoCanceller3Factory() {} - -EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config& config) - : config_(config) { - // Revert to default configuration if needed. - if (!EchoCanceller3::Validate(config_)) { - config_ = EchoCanceller3Config(); - } -} - -std::unique_ptr EchoCanceller3Factory::Create(int sample_rate_hz) { - return std::unique_ptr( - new EchoCanceller3(config_, sample_rate_hz, true)); -} - } // namespace webrtc diff --git a/modules/audio_processing/aec3/echo_canceller3.h b/modules/audio_processing/aec3/echo_canceller3.h index b9dbd69262..8658814e93 100644 --- a/modules/audio_processing/aec3/echo_canceller3.h +++ b/modules/audio_processing/aec3/echo_canceller3.h @@ -92,9 +92,6 @@ class EchoCanceller3 : public EchoControl { block_processor_->UpdateEchoLeakageStatus(leakage_detected); } - // Validates a config. - static bool Validate(const EchoCanceller3Config& config); - private: class RenderWriter; diff --git a/modules/audio_processing/aec3/echo_canceller3_unittest.cc b/modules/audio_processing/aec3/echo_canceller3_unittest.cc index d54295f90a..d4ad4f66f6 100644 --- a/modules/audio_processing/aec3/echo_canceller3_unittest.cc +++ b/modules/audio_processing/aec3/echo_canceller3_unittest.cc @@ -681,11 +681,6 @@ TEST(EchoCanceller3Messaging, EchoLeakage) { } } -TEST(EchoCanceller3, ConfigValidation) { - EchoCanceller3Config config; - EXPECT_TRUE(EchoCanceller3::Validate(config)); -} - #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) TEST(EchoCanceller3InputCheck, WrongCaptureNumBandsCheckVerification) { diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index 06c1f4a3ed..48d84062b1 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -1162,16 +1162,6 @@ class VoiceDetection { protected: virtual ~VoiceDetection() {} }; - -class EchoCanceller3Factory : public EchoControlFactory { - public: - EchoCanceller3Factory(); - EchoCanceller3Factory(const EchoCanceller3Config& config); - std::unique_ptr Create(int sample_rate_hz) override; - - private: - EchoCanceller3Config config_; -}; } // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index a72ac1c9ac..82bffe427f 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -17,6 +17,7 @@ #include #include +#include "api/audio/echo_canceller3_factory.h" #include "common_audio/include/audio_util.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" #include "modules/audio_processing/include/audio_processing.h" diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index 69231b2b66..56f47b00fa 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -14,6 +14,7 @@ #include #include +#include "api/audio/echo_canceller3_factory.h" #include "modules/audio_coding/neteq/tools/resample_input_audio_file.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" #include "modules/audio_processing/test/debug_dump_replayer.h" diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index 2d2d77cc71..fc43ada06f 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -444,6 +444,7 @@ webrtc_fuzzer_test("audio_processing_fuzzer") { deps = [ ":audio_processing_fuzzer_helper", ":fuzz_data_helper", + "../../api/audio:aec3_factory", "../../modules/audio_processing", "../../modules/audio_processing/aec3", "../../rtc_base:rtc_base_approved", diff --git a/test/fuzzers/audio_processing_configs_fuzzer.cc b/test/fuzzers/audio_processing_configs_fuzzer.cc index 18913d8d92..a977ff9215 100644 --- a/test/fuzzers/audio_processing_configs_fuzzer.cc +++ b/test/fuzzers/audio_processing_configs_fuzzer.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "api/audio/echo_canceller3_factory.h" #include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/numerics/safe_minmax.h" #include "test/fuzzers/audio_processing_fuzzer_helper.h"