From 1b200b93d54d382eaecef0d18babc609f61e3683 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Fri, 17 Sep 2021 10:34:26 +0200 Subject: [PATCH] APM: remove `webrtc::Config` Remove the deprecated way of configuring APM. Bug: webrtc:5298 Change-Id: Idcedf1fe4a121adfcf2881003579cd58ac42a2b9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232302 Reviewed-by: Sam Zackrisson Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#35026} --- media/engine/webrtc_voice_engine.cc | 2 - modules/audio_processing/BUILD.gn | 13 -- modules/audio_processing/config_unittest.cc | 77 ---------- .../include/audio_processing.h | 1 - modules/audio_processing/include/config.cc | 23 --- modules/audio_processing/include/config.h | 131 ------------------ 6 files changed, 247 deletions(-) delete mode 100644 modules/audio_processing/config_unittest.cc delete mode 100644 modules/audio_processing/include/config.cc delete mode 100644 modules/audio_processing/include/config.h diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index f1ebaf39ee..448ad3522a 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -582,8 +582,6 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { return true; } - webrtc::Config config; - if (options.experimental_ns) { experimental_ns_ = options.experimental_ns; } diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 506c8212fd..d6ed3e251b 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -19,15 +19,6 @@ config("apm_debug_dump") { } } -rtc_library("config") { - visibility = [ ":*" ] - sources = [ - "include/config.cc", - "include/config.h", - ] - deps = [ "../../rtc_base/system:rtc_export" ] -} - rtc_library("api") { visibility = [ "*" ] sources = [ @@ -37,7 +28,6 @@ rtc_library("api") { deps = [ ":audio_frame_view", ":audio_processing_statistics", - ":config", "../../api:array_view", "../../api:scoped_refptr", "../../api/audio:aec3_config", @@ -162,7 +152,6 @@ rtc_library("audio_processing") { ":audio_frame_proxies", ":audio_frame_view", ":audio_processing_statistics", - ":config", ":high_pass_filter", ":optionally_built_submodule_creators", ":rms_level", @@ -335,7 +324,6 @@ if (rtc_include_tests) { sources = [ "audio_buffer_unittest.cc", "audio_frame_view_unittest.cc", - "config_unittest.cc", "echo_control_mobile_unittest.cc", "gain_controller2_unittest.cc", "splitting_filter_unittest.cc", @@ -350,7 +338,6 @@ if (rtc_include_tests) { ":audio_frame_view", ":audio_processing", ":audioproc_test_utils", - ":config", ":high_pass_filter", ":mocks", ":voice_detection", diff --git a/modules/audio_processing/config_unittest.cc b/modules/audio_processing/config_unittest.cc deleted file mode 100644 index 19e9ab37d2..0000000000 --- a/modules/audio_processing/config_unittest.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2013 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. - */ -#include "modules/audio_processing/include/config.h" - -#include "test/gtest.h" - -namespace webrtc { -namespace { - -struct MyExperiment { - static const ConfigOptionID identifier = ConfigOptionID::kMyExperimentForTest; - static const int kDefaultFactor; - static const int kDefaultOffset; - - MyExperiment() : factor(kDefaultFactor), offset(kDefaultOffset) {} - - MyExperiment(int factor, int offset) : factor(factor), offset(offset) {} - - int factor; - int offset; -}; - -const int MyExperiment::kDefaultFactor = 1; -const int MyExperiment::kDefaultOffset = 2; - -TEST(Config, ReturnsDefaultInstanceIfNotConfigured) { - Config config; - const MyExperiment& my_exp = config.Get(); - EXPECT_EQ(MyExperiment::kDefaultFactor, my_exp.factor); - EXPECT_EQ(MyExperiment::kDefaultOffset, my_exp.offset); -} - -TEST(Config, ReturnOptionWhenSet) { - Config config; - config.Set(new MyExperiment(5, 1)); - const MyExperiment& my_exp = config.Get(); - EXPECT_EQ(5, my_exp.factor); - EXPECT_EQ(1, my_exp.offset); -} - -TEST(Config, SetNullSetsTheOptionBackToDefault) { - Config config; - config.Set(new MyExperiment(5, 1)); - config.Set(NULL); - const MyExperiment& my_exp = config.Get(); - EXPECT_EQ(MyExperiment::kDefaultFactor, my_exp.factor); - EXPECT_EQ(MyExperiment::kDefaultOffset, my_exp.offset); -} - -struct Algo1_CostFunction { - static const ConfigOptionID identifier = - ConfigOptionID::kAlgo1CostFunctionForTest; - Algo1_CostFunction() {} - - virtual int cost(int x) const { return x; } - - virtual ~Algo1_CostFunction() {} -}; - -struct SqrCost : Algo1_CostFunction { - virtual int cost(int x) const { return x * x; } -}; - -TEST(Config, SupportsPolymorphism) { - Config config; - config.Set(new SqrCost()); - EXPECT_EQ(25, config.Get().cost(5)); -} -} // namespace -} // namespace webrtc diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index 54ca996f67..15dcc39e0e 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -29,7 +29,6 @@ #include "api/audio/echo_control.h" #include "api/scoped_refptr.h" #include "modules/audio_processing/include/audio_processing_statistics.h" -#include "modules/audio_processing/include/config.h" #include "rtc_base/arraysize.h" #include "rtc_base/constructor_magic.h" #include "rtc_base/ref_count.h" diff --git a/modules/audio_processing/include/config.cc b/modules/audio_processing/include/config.cc deleted file mode 100644 index 14240db305..0000000000 --- a/modules/audio_processing/include/config.cc +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016 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. - */ - -#include "modules/audio_processing/include/config.h" - -namespace webrtc { - -Config::Config() {} - -Config::~Config() { - for (OptionMap::iterator it = options_.begin(); it != options_.end(); ++it) { - delete it->second; - } -} - -} // namespace webrtc diff --git a/modules/audio_processing/include/config.h b/modules/audio_processing/include/config.h deleted file mode 100644 index 5fa04901a7..0000000000 --- a/modules/audio_processing/include/config.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2013 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 MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_ -#define MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_ - -#include - -#include "rtc_base/system/rtc_export.h" - -namespace webrtc { - -// Only add new values to the end of the enumeration and never remove (only -// deprecate) to maintain binary compatibility. -enum class ConfigOptionID { - kMyExperimentForTest, - kAlgo1CostFunctionForTest, - kTemporalLayersFactory, // Deprecated - kNetEqCapacityConfig, // Deprecated - kNetEqFastAccelerate, // Deprecated - kVoicePacing, // Deprecated - kExtendedFilter, // Deprecated - kDelayAgnostic, // Deprecated - kExperimentalAgc, // Deprecated - kExperimentalNs, - kBeamforming, // Deprecated - kIntelligibility, // Deprecated - kEchoCanceller3, // Deprecated - kAecRefinedAdaptiveFilter, // Deprecated - kLevelControl // Deprecated -}; - -// Class Config is designed to ease passing a set of options across webrtc code. -// Options are identified by typename in order to avoid incorrect casts. -// -// Usage: -// * declaring an option: -// struct Algo1_CostFunction { -// virtual float cost(int x) const { return x; } -// virtual ~Algo1_CostFunction() {} -// }; -// -// * accessing an option: -// config.Get().cost(value); -// -// * setting an option: -// struct SqrCost : Algo1_CostFunction { -// virtual float cost(int x) const { return x*x; } -// }; -// config.Set(new SqrCost()); -// -// Note: This class is thread-compatible (like STL containers). -class RTC_EXPORT Config { - public: - // Returns the option if set or a default constructed one. - // Callers that access options too often are encouraged to cache the result. - // Returned references are owned by this. - // - // Requires std::is_default_constructible - template - const T& Get() const; - - // Set the option, deleting any previous instance of the same. - // This instance gets ownership of the newly set value. - template - void Set(T* value); - - Config(); - ~Config(); - - private: - struct BaseOption { - virtual ~BaseOption() {} - }; - - template - struct Option : BaseOption { - explicit Option(T* v) : value(v) {} - ~Option() { delete value; } - T* value; - }; - - template - static ConfigOptionID identifier() { - return T::identifier; - } - - // Used to instantiate a default constructed object that doesn't needs to be - // owned. This allows Get to be implemented without requiring explicitly - // locks. - template - static const T& default_value() { - static const T* const def = new T(); - return *def; - } - - typedef std::map OptionMap; - OptionMap options_; - - Config(const Config&); - void operator=(const Config&); -}; - -template -const T& Config::Get() const { - OptionMap::const_iterator it = options_.find(identifier()); - if (it != options_.end()) { - const T* t = static_cast*>(it->second)->value; - if (t) { - return *t; - } - } - return default_value(); -} - -template -void Config::Set(T* value) { - BaseOption*& it = options_[identifier()]; - delete it; - it = new Option(value); -} -} // namespace webrtc - -#endif // MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_