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 <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35026}
This commit is contained in:
Alessio Bazzica
2021-09-17 10:34:26 +02:00
committed by WebRTC LUCI CQ
parent be1b8989d1
commit 1b200b93d5
6 changed files with 0 additions and 247 deletions

View File

@ -582,8 +582,6 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
return true; return true;
} }
webrtc::Config config;
if (options.experimental_ns) { if (options.experimental_ns) {
experimental_ns_ = options.experimental_ns; experimental_ns_ = options.experimental_ns;
} }

View File

@ -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") { rtc_library("api") {
visibility = [ "*" ] visibility = [ "*" ]
sources = [ sources = [
@ -37,7 +28,6 @@ rtc_library("api") {
deps = [ deps = [
":audio_frame_view", ":audio_frame_view",
":audio_processing_statistics", ":audio_processing_statistics",
":config",
"../../api:array_view", "../../api:array_view",
"../../api:scoped_refptr", "../../api:scoped_refptr",
"../../api/audio:aec3_config", "../../api/audio:aec3_config",
@ -162,7 +152,6 @@ rtc_library("audio_processing") {
":audio_frame_proxies", ":audio_frame_proxies",
":audio_frame_view", ":audio_frame_view",
":audio_processing_statistics", ":audio_processing_statistics",
":config",
":high_pass_filter", ":high_pass_filter",
":optionally_built_submodule_creators", ":optionally_built_submodule_creators",
":rms_level", ":rms_level",
@ -335,7 +324,6 @@ if (rtc_include_tests) {
sources = [ sources = [
"audio_buffer_unittest.cc", "audio_buffer_unittest.cc",
"audio_frame_view_unittest.cc", "audio_frame_view_unittest.cc",
"config_unittest.cc",
"echo_control_mobile_unittest.cc", "echo_control_mobile_unittest.cc",
"gain_controller2_unittest.cc", "gain_controller2_unittest.cc",
"splitting_filter_unittest.cc", "splitting_filter_unittest.cc",
@ -350,7 +338,6 @@ if (rtc_include_tests) {
":audio_frame_view", ":audio_frame_view",
":audio_processing", ":audio_processing",
":audioproc_test_utils", ":audioproc_test_utils",
":config",
":high_pass_filter", ":high_pass_filter",
":mocks", ":mocks",
":voice_detection", ":voice_detection",

View File

@ -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<MyExperiment>();
EXPECT_EQ(MyExperiment::kDefaultFactor, my_exp.factor);
EXPECT_EQ(MyExperiment::kDefaultOffset, my_exp.offset);
}
TEST(Config, ReturnOptionWhenSet) {
Config config;
config.Set<MyExperiment>(new MyExperiment(5, 1));
const MyExperiment& my_exp = config.Get<MyExperiment>();
EXPECT_EQ(5, my_exp.factor);
EXPECT_EQ(1, my_exp.offset);
}
TEST(Config, SetNullSetsTheOptionBackToDefault) {
Config config;
config.Set<MyExperiment>(new MyExperiment(5, 1));
config.Set<MyExperiment>(NULL);
const MyExperiment& my_exp = config.Get<MyExperiment>();
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<Algo1_CostFunction>(new SqrCost());
EXPECT_EQ(25, config.Get<Algo1_CostFunction>().cost(5));
}
} // namespace
} // namespace webrtc

View File

@ -29,7 +29,6 @@
#include "api/audio/echo_control.h" #include "api/audio/echo_control.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "modules/audio_processing/include/audio_processing_statistics.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/arraysize.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
#include "rtc_base/ref_count.h" #include "rtc_base/ref_count.h"

View File

@ -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

View File

@ -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 <map>
#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<Algo1_CostFunction>().cost(value);
//
// * setting an option:
// struct SqrCost : Algo1_CostFunction {
// virtual float cost(int x) const { return x*x; }
// };
// config.Set<Algo1_CostFunction>(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<T>
template <typename T>
const T& Get() const;
// Set the option, deleting any previous instance of the same.
// This instance gets ownership of the newly set value.
template <typename T>
void Set(T* value);
Config();
~Config();
private:
struct BaseOption {
virtual ~BaseOption() {}
};
template <typename T>
struct Option : BaseOption {
explicit Option(T* v) : value(v) {}
~Option() { delete value; }
T* value;
};
template <typename T>
static ConfigOptionID identifier() {
return T::identifier;
}
// Used to instantiate a default constructed object that doesn't needs to be
// owned. This allows Get<T> to be implemented without requiring explicitly
// locks.
template <typename T>
static const T& default_value() {
static const T* const def = new T();
return *def;
}
typedef std::map<ConfigOptionID, BaseOption*> OptionMap;
OptionMap options_;
Config(const Config&);
void operator=(const Config&);
};
template <typename T>
const T& Config::Get() const {
OptionMap::const_iterator it = options_.find(identifier<T>());
if (it != options_.end()) {
const T* t = static_cast<Option<T>*>(it->second)->value;
if (t) {
return *t;
}
}
return default_value<T>();
}
template <typename T>
void Config::Set(T* value) {
BaseOption*& it = options_[identifier<T>()];
delete it;
it = new Option<T>(value);
}
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_