Clean up the NetEqFactory API.
This CL decouples NetEqFactory and AudioDecoderFactory.
AudioDecoderFactory is used in more places than just inside of NetEq, so
decoupling these makes sense.
Bug: webrtc:11005
Change-Id: I78dd856e4248e398e69a65816b062ef30555b055
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161005
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29961}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 1e53f3c..ab54a77 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -601,26 +601,6 @@
]
}
-rtc_source_set("neteq_factory_with_codecs") {
- visibility = [ "*" ]
- testonly = true
- sources = [
- "test/neteq_factory_with_codecs.cc",
- "test/neteq_factory_with_codecs.h",
- ]
-
- deps = [
- ":scoped_refptr",
- "../modules/audio_coding:neteq",
- "../system_wrappers:system_wrappers",
- "audio_codecs:audio_codecs_api",
- "audio_codecs:builtin_audio_decoder_factory",
- "neteq:default_neteq_controller_factory",
- "neteq:neteq_api",
- "neteq:neteq_controller_api",
- ]
-}
-
rtc_source_set("function_view") {
visibility = [ "*" ]
sources = [
diff --git a/api/neteq/custom_neteq_factory.cc b/api/neteq/custom_neteq_factory.cc
index eaa8c8a..b2df5df 100644
--- a/api/neteq/custom_neteq_factory.cc
+++ b/api/neteq/custom_neteq_factory.cc
@@ -20,23 +20,10 @@
std::unique_ptr<NetEqControllerFactory> controller_factory)
: controller_factory_(std::move(controller_factory)) {}
-CustomNetEqFactory::CustomNetEqFactory(
- rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
- std::unique_ptr<NetEqControllerFactory> controller_factory)
- : decoder_factory_(decoder_factory),
- controller_factory_(std::move(controller_factory)) {}
CustomNetEqFactory::~CustomNetEqFactory() = default;
std::unique_ptr<NetEq> CustomNetEqFactory::CreateNetEq(
const NetEq::Config& config,
- Clock* clock) const {
- return std::make_unique<NetEqImpl>(
- config, NetEqImpl::Dependencies(config, clock, decoder_factory_,
- *controller_factory_));
-}
-
-std::unique_ptr<NetEq> CustomNetEqFactory::CreateNetEq(
- const NetEq::Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
Clock* clock) const {
return std::make_unique<NetEqImpl>(
diff --git a/api/neteq/custom_neteq_factory.h b/api/neteq/custom_neteq_factory.h
index 7a0ee21..d080f68 100644
--- a/api/neteq/custom_neteq_factory.h
+++ b/api/neteq/custom_neteq_factory.h
@@ -22,30 +22,21 @@
namespace webrtc {
// This factory can be used to generate NetEq instances that make use of a
-// custom AudioDecoderFactory and/or NetEqControllerFactory. Using a custom
-// AudioDecoderFactory is deprecated and the functionality will be removed soon.
+// custom NetEqControllerFactory.
class CustomNetEqFactory : public NetEqFactory {
public:
explicit CustomNetEqFactory(
std::unique_ptr<NetEqControllerFactory> controller_factory);
- // This constructor is deprecated and will be removed soon.
- CustomNetEqFactory(
- rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
- std::unique_ptr<NetEqControllerFactory> controller_factory);
~CustomNetEqFactory() override;
CustomNetEqFactory(const CustomNetEqFactory&) = delete;
CustomNetEqFactory& operator=(const CustomNetEqFactory&) = delete;
- std::unique_ptr<NetEq> CreateNetEq(const NetEq::Config& config,
- Clock* clock) const override;
-
std::unique_ptr<NetEq> CreateNetEq(
const NetEq::Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
Clock* clock) const override;
private:
- rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
std::unique_ptr<NetEqControllerFactory> controller_factory_;
};
diff --git a/api/neteq/neteq_factory.h b/api/neteq/neteq_factory.h
index c2d40ef..65cf9eb 100644
--- a/api/neteq/neteq_factory.h
+++ b/api/neteq/neteq_factory.h
@@ -31,9 +31,6 @@
const NetEq::Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
Clock* clock) const = 0;
- // This method is deprecated and will be removed.
- virtual std::unique_ptr<NetEq> CreateNetEq(const NetEq::Config& config,
- Clock* clock) const = 0;
};
} // namespace webrtc
diff --git a/api/test/neteq_factory_with_codecs.cc b/api/test/neteq_factory_with_codecs.cc
deleted file mode 100644
index 3bead93..0000000
--- a/api/test/neteq_factory_with_codecs.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2019 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 "api/test/neteq_factory_with_codecs.h"
-
-#include "api/audio_codecs/audio_decoder_factory.h"
-#include "api/audio_codecs/builtin_audio_decoder_factory.h"
-#include "api/neteq/default_neteq_controller_factory.h"
-#include "api/neteq/neteq_controller_factory.h"
-#include "api/neteq/neteq_factory.h"
-#include "modules/audio_coding/neteq/decision_logic.h"
-#include "modules/audio_coding/neteq/neteq_impl.h"
-#include "system_wrappers/include/clock.h"
-
-namespace webrtc {
-namespace {
-
-class NetEqFactoryWithCodecs final : public NetEqFactory {
- public:
- std::unique_ptr<NetEq> CreateNetEq(const NetEq::Config& config,
- Clock* clock) const override {
- return std::make_unique<NetEqImpl>(
- config, NetEqImpl::Dependencies(config, clock, decoder_factory_,
- *controller_factory_));
- }
- std::unique_ptr<NetEq> CreateNetEq(
- const NetEq::Config& config,
- const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
- Clock* clock) const override {
- return std::make_unique<NetEqImpl>(
- config, NetEqImpl::Dependencies(config, clock, decoder_factory,
- *controller_factory_));
- }
-
- private:
- const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_ =
- CreateBuiltinAudioDecoderFactory();
- const std::unique_ptr<NetEqControllerFactory> controller_factory_ =
- std::make_unique<DefaultNetEqControllerFactory>();
-};
-
-} // namespace
-
-std::unique_ptr<NetEqFactory> CreateNetEqFactoryWithCodecs() {
- return std::make_unique<NetEqFactoryWithCodecs>();
-}
-
-} // namespace webrtc
diff --git a/api/test/neteq_factory_with_codecs.h b/api/test/neteq_factory_with_codecs.h
deleted file mode 100644
index 7260eb0..0000000
--- a/api/test/neteq_factory_with_codecs.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2019 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 API_TEST_NETEQ_FACTORY_WITH_CODECS_H_
-#define API_TEST_NETEQ_FACTORY_WITH_CODECS_H_
-
-#include <memory>
-
-#include "api/neteq/neteq_factory.h"
-
-namespace webrtc {
-
-// This NetEq factory will use WebRTC's built-in AudioDecoders as well as the
-// built-in NetEqController logic.
-std::unique_ptr<NetEqFactory> CreateNetEqFactoryWithCodecs();
-
-} // namespace webrtc
-#endif // API_TEST_NETEQ_FACTORY_WITH_CODECS_H_
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 4b9d20b..14a1bdc 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -1065,6 +1065,7 @@
]
deps = [
+ ":default_neteq_factory",
":neteq",
"../../api:neteq_simulator_api",
"../../api:rtp_headers",
@@ -1239,11 +1240,11 @@
deps = [
":audio_coding",
":audio_coding_module_typedefs",
+ ":default_neteq_factory",
":neteq_test_tools",
":neteq_tools_minimal",
":webrtc_opus_wrapper",
"..:module_api",
- "../../api:neteq_factory_with_codecs",
"../../api:rtp_headers",
"../../api/audio:audio_frame_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
@@ -1630,10 +1631,10 @@
]
deps = [
+ ":default_neteq_factory",
":neteq",
":neteq_test_tools",
":pcm16b",
- "../../api:neteq_factory_with_codecs",
"../../api/audio:audio_frame_api",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
@@ -1655,11 +1656,10 @@
]
deps = [
+ ":default_neteq_factory",
":neteq",
":neteq_test_tools",
"../../api/audio_codecs:builtin_audio_decoder_factory",
- "../../api/neteq:custom_neteq_factory",
- "../../api/neteq:default_neteq_controller_factory",
"../../api/neteq:neteq_api",
"../../rtc_base:checks",
"../../system_wrappers",
@@ -2072,6 +2072,7 @@
":audio_coding_opus_common",
":audio_encoder_cng",
":audio_network_adaptor",
+ ":default_neteq_factory",
":g711",
":ilbc",
":isac",
@@ -2088,7 +2089,6 @@
":webrtc_opus",
"..:module_api",
"..:module_api_public",
- "../../api:neteq_factory_with_codecs",
"../../api/audio:audio_frame_api",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
@@ -2097,7 +2097,6 @@
"../../api/audio_codecs/opus:audio_decoder_opus",
"../../api/audio_codecs/opus:audio_encoder_multiopus",
"../../api/audio_codecs/opus:audio_encoder_opus",
- "../../api/neteq:custom_neteq_factory",
"../../api/neteq:default_neteq_controller_factory",
"../../api/neteq:neteq_api",
"../../api/neteq:neteq_controller_api",
diff --git a/modules/audio_coding/neteq/default_neteq_factory.cc b/modules/audio_coding/neteq/default_neteq_factory.cc
index ca19b08..487450f 100644
--- a/modules/audio_coding/neteq/default_neteq_factory.cc
+++ b/modules/audio_coding/neteq/default_neteq_factory.cc
@@ -28,12 +28,4 @@
controller_factory_));
}
-std::unique_ptr<NetEq> DefaultNetEqFactory::CreateNetEq(
- const NetEq::Config& /*config*/,
- Clock* /*clock*/) const {
- RTC_NOTREACHED() << "Calling CreateNetEq without an AudioDecoderFactory on "
- "DefaultNetEqFactory is not supported.";
- return nullptr;
-}
-
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/default_neteq_factory.h b/modules/audio_coding/neteq/default_neteq_factory.h
index 4c5ee9b..24d2bae 100644
--- a/modules/audio_coding/neteq/default_neteq_factory.h
+++ b/modules/audio_coding/neteq/default_neteq_factory.h
@@ -32,8 +32,6 @@
const NetEq::Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
Clock* clock) const override;
- std::unique_ptr<NetEq> CreateNetEq(const NetEq::Config& config,
- Clock* clock) const override;
private:
const DefaultNetEqControllerFactory controller_factory_;
diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc
index 1731282..33e3d8d 100644
--- a/modules/audio_coding/neteq/neteq_impl_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc
@@ -18,9 +18,9 @@
#include "api/neteq/default_neteq_controller_factory.h"
#include "api/neteq/neteq.h"
#include "api/neteq/neteq_controller.h"
-#include "api/test/neteq_factory_with_codecs.h"
#include "modules/audio_coding/neteq/accelerate.h"
#include "modules/audio_coding/neteq/decision_logic.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/expand.h"
#include "modules/audio_coding/neteq/histogram.h"
#include "modules/audio_coding/neteq/mock/mock_decoder_database.h"
@@ -252,8 +252,9 @@
TEST(NetEq, CreateAndDestroy) {
NetEq::Config config;
SimulatedClock clock(0);
- std::unique_ptr<NetEqFactory> neteq_factory = CreateNetEqFactoryWithCodecs();
- std::unique_ptr<NetEq> neteq = neteq_factory->CreateNetEq(config, &clock);
+ auto decoder_factory = CreateBuiltinAudioDecoderFactory();
+ std::unique_ptr<NetEq> neteq =
+ DefaultNetEqFactory().CreateNetEq(config, decoder_factory, &clock);
}
TEST_F(NetEqImplTest, RegisterPayloadType) {
diff --git a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
index 0e24f68..d35c44c 100644
--- a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
@@ -13,9 +13,9 @@
#include "absl/memory/memory.h"
#include "api/audio/audio_frame.h"
#include "api/audio_codecs/audio_decoder.h"
-#include "api/neteq/custom_neteq_factory.h"
-#include "api/neteq/default_neteq_controller_factory.h"
+#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/neteq/neteq.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/tools/rtp_generator.h"
#include "rtc_base/ref_counted_object.h"
#include "system_wrappers/include/clock.h"
@@ -31,9 +31,7 @@
const NetEq::Config& config,
Clock* clock,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
- CustomNetEqFactory neteq_factory(
- decoder_factory, std::make_unique<DefaultNetEqControllerFactory>());
- return neteq_factory.CreateNetEq(config, clock);
+ return DefaultNetEqFactory().CreateNetEq(config, decoder_factory, clock);
}
} // namespace
diff --git a/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/modules/audio_coding/neteq/neteq_stereo_unittest.cc
index 14979ae..515fd9b 100644
--- a/modules/audio_coding/neteq/neteq_stereo_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_stereo_unittest.cc
@@ -18,8 +18,8 @@
#include "api/audio/audio_frame.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/neteq/neteq.h"
-#include "api/test/neteq_factory_with_codecs.h"
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "modules/audio_coding/neteq/tools/rtp_generator.h"
#include "rtc_base/strings/string_builder.h"
@@ -68,10 +68,10 @@
last_arrival_time_(0) {
NetEq::Config config;
config.sample_rate_hz = sample_rate_hz_;
- std::unique_ptr<NetEqFactory> neteq_factory =
- CreateNetEqFactoryWithCodecs();
- neteq_mono_ = neteq_factory->CreateNetEq(config, &clock_);
- neteq_ = neteq_factory->CreateNetEq(config, &clock_);
+ DefaultNetEqFactory neteq_factory;
+ auto decoder_factory = CreateBuiltinAudioDecoderFactory();
+ neteq_mono_ = neteq_factory.CreateNetEq(config, decoder_factory, &clock_);
+ neteq_ = neteq_factory.CreateNetEq(config, decoder_factory, &clock_);
input_ = new int16_t[frame_size_samples_];
encoded_ = new uint8_t[2 * frame_size_samples_];
input_multi_channel_ = new int16_t[frame_size_samples_ * num_channels_];
diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc
index a96812c3..098bcc2 100644
--- a/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_unittest.cc
@@ -23,7 +23,6 @@
#include "absl/flags/flag.h"
#include "api/audio/audio_frame.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
-#include "api/test/neteq_factory_with_codecs.h"
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
#include "modules/audio_coding/neteq/test/neteq_decoding_test.h"
#include "modules/audio_coding/neteq/tools/audio_loop.h"
diff --git a/modules/audio_coding/neteq/test/neteq_decoding_test.cc b/modules/audio_coding/neteq/test/neteq_decoding_test.cc
index 24f10cd..11b1b1a 100644
--- a/modules/audio_coding/neteq/test/neteq_decoding_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_decoding_test.cc
@@ -10,8 +10,9 @@
#include "modules/audio_coding/neteq/test/neteq_decoding_test.h"
+#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/rtp_headers.h"
-#include "api/test/neteq_factory_with_codecs.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/test/result_sink.h"
#include "rtc_base/strings/string_builder.h"
#include "test/testsupport/file_utils.h"
@@ -81,8 +82,8 @@
}
void NetEqDecodingTest::SetUp() {
- std::unique_ptr<NetEqFactory> neteq_factory = CreateNetEqFactoryWithCodecs();
- neteq_ = neteq_factory->CreateNetEq(config_, &clock_);
+ auto decoder_factory = CreateBuiltinAudioDecoderFactory();
+ neteq_ = DefaultNetEqFactory().CreateNetEq(config_, decoder_factory, &clock_);
NetEqNetworkStatistics stat;
ASSERT_EQ(0, neteq_->NetworkStatistics(&stat));
algorithmic_delay_ms_ = stat.current_buffer_size_ms;
@@ -421,8 +422,9 @@
}
void NetEqDecodingTestTwoInstances::CreateSecondInstance() {
- std::unique_ptr<NetEqFactory> neteq_factory = CreateNetEqFactoryWithCodecs();
- neteq2_ = neteq_factory->CreateNetEq(config2_, &clock_);
+ auto decoder_factory = CreateBuiltinAudioDecoderFactory();
+ neteq2_ =
+ DefaultNetEqFactory().CreateNetEq(config2_, decoder_factory, &clock_);
ASSERT_TRUE(neteq2_);
LoadDecoders(neteq2_.get());
}
diff --git a/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/modules/audio_coding/neteq/tools/neteq_performance_test.cc
index d963903..1fb853c 100644
--- a/modules/audio_coding/neteq/tools/neteq_performance_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_performance_test.cc
@@ -11,9 +11,10 @@
#include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
#include "api/audio/audio_frame.h"
+#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/neteq/neteq.h"
-#include "api/test/neteq_factory_with_codecs.h"
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/tools/audio_loop.h"
#include "modules/audio_coding/neteq/tools/rtp_generator.h"
#include "rtc_base/checks.h"
@@ -40,8 +41,9 @@
NetEq::Config config;
config.sample_rate_hz = kSampRateHz;
webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock();
- std::unique_ptr<NetEqFactory> neteq_factory = CreateNetEqFactoryWithCodecs();
- auto neteq = neteq_factory->CreateNetEq(config, clock);
+ auto audio_decoder_factory = CreateBuiltinAudioDecoderFactory();
+ auto neteq =
+ DefaultNetEqFactory().CreateNetEq(config, audio_decoder_factory, clock);
// Register decoder in |neteq|.
if (!neteq->RegisterPayloadType(kPayloadType,
SdpAudioFormat("l16", kSampRateHz, 1)))
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
index ba53954..80e3be2 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
@@ -15,8 +15,7 @@
#include <cmath>
#include "absl/flags/flag.h"
-#include "api/neteq/custom_neteq_factory.h"
-#include "api/neteq/default_neteq_controller_factory.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "modules/audio_coding/neteq/tools/output_audio_file.h"
#include "modules/audio_coding/neteq/tools/output_wav_file.h"
@@ -95,9 +94,7 @@
const NetEq::Config& config,
Clock* clock,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
- CustomNetEqFactory neteq_factory(
- decoder_factory, std::make_unique<DefaultNetEqControllerFactory>());
- return neteq_factory.CreateNetEq(config, clock);
+ return DefaultNetEqFactory().CreateNetEq(config, decoder_factory, clock);
}
} // namespace
diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc
index 50d8ba1..a775453 100644
--- a/modules/audio_coding/neteq/tools/neteq_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_test.cc
@@ -13,8 +13,7 @@
#include <iomanip>
#include <iostream>
-#include "api/neteq/custom_neteq_factory.h"
-#include "api/neteq/default_neteq_controller_factory.h"
+#include "modules/audio_coding/neteq/default_neteq_factory.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "system_wrappers/include/clock.h"
@@ -43,9 +42,7 @@
const NetEq::Config& config,
Clock* clock,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
- CustomNetEqFactory neteq_factory(
- decoder_factory, std::make_unique<DefaultNetEqControllerFactory>());
- return neteq_factory.CreateNetEq(config, clock);
+ return DefaultNetEqFactory().CreateNetEq(config, decoder_factory, clock);
}
} // namespace