Migrate CreateVoipEngine to take audio_processing_factory instead of audio_processing
This would allow users of the voip engine to migrate away from the AudioProcessingBuilder Bug: webrtc:369904700 Change-Id: Ie4f6f4579e185ff6366333a3f37e6aaa23b892b9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365920 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43255}
This commit is contained in:
parent
b280cb95c6
commit
ecb3ed7a76
@ -43,6 +43,7 @@ rtc_library("voip_engine_factory") {
|
|||||||
"../audio:audio_device",
|
"../audio:audio_device",
|
||||||
"../audio:audio_processing",
|
"../audio:audio_processing",
|
||||||
"../audio_codecs:audio_codecs_api",
|
"../audio_codecs:audio_codecs_api",
|
||||||
|
"../environment",
|
||||||
"../environment:environment_factory",
|
"../environment:environment_factory",
|
||||||
"../task_queue",
|
"../task_queue",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "api/voip/voip_engine_factory.h"
|
#include "api/voip/voip_engine_factory.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "api/make_ref_counted.h"
|
#include "api/make_ref_counted.h"
|
||||||
@ -24,14 +25,16 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using ::testing::NiceMock;
|
||||||
|
|
||||||
// Create voip engine with mock modules as normal use case.
|
// Create voip engine with mock modules as normal use case.
|
||||||
TEST(VoipEngineFactoryTest, CreateEngineWithMockModules) {
|
TEST(VoipEngineFactoryTest, CreateEngineWithMockModules) {
|
||||||
VoipEngineConfig config;
|
VoipEngineConfig config;
|
||||||
config.encoder_factory = rtc::make_ref_counted<MockAudioEncoderFactory>();
|
config.encoder_factory = rtc::make_ref_counted<MockAudioEncoderFactory>();
|
||||||
config.decoder_factory = rtc::make_ref_counted<MockAudioDecoderFactory>();
|
config.decoder_factory = rtc::make_ref_counted<MockAudioDecoderFactory>();
|
||||||
config.task_queue_factory = CreateDefaultTaskQueueFactory();
|
config.task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||||
config.audio_processing =
|
config.audio_processing_factory =
|
||||||
rtc::make_ref_counted<testing::NiceMock<test::MockAudioProcessing>>();
|
std::make_unique<NiceMock<test::MockAudioProcessingFactory>>();
|
||||||
config.audio_device_module = test::MockAudioDeviceModule::CreateNice();
|
config.audio_device_module = test::MockAudioDeviceModule::CreateNice();
|
||||||
|
|
||||||
auto voip_engine = CreateVoipEngine(std::move(config));
|
auto voip_engine = CreateVoipEngine(std::move(config));
|
||||||
|
|||||||
@ -13,7 +13,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "api/audio/audio_processing.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/voip/voip_engine.h"
|
#include "api/voip/voip_engine.h"
|
||||||
#include "audio/voip/voip_core.h"
|
#include "audio/voip/voip_core.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
@ -27,15 +30,26 @@ std::unique_ptr<VoipEngine> CreateVoipEngine(VoipEngineConfig config) {
|
|||||||
RTC_CHECK(config.task_queue_factory);
|
RTC_CHECK(config.task_queue_factory);
|
||||||
RTC_CHECK(config.audio_device_module);
|
RTC_CHECK(config.audio_device_module);
|
||||||
|
|
||||||
if (!config.audio_processing) {
|
Environment env = CreateEnvironment(std::move(config.task_queue_factory));
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
RTC_CHECK(config.audio_processing == nullptr ||
|
||||||
|
config.audio_processing_factory == nullptr);
|
||||||
|
scoped_refptr<AudioProcessing> audio_processing =
|
||||||
|
std::move(config.audio_processing);
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
if (config.audio_processing_factory != nullptr) {
|
||||||
|
audio_processing = config.audio_processing_factory->Create(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audio_processing == nullptr) {
|
||||||
RTC_DLOG(LS_INFO) << "No audio processing functionality provided.";
|
RTC_DLOG(LS_INFO) << "No audio processing functionality provided.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_unique<VoipCore>(
|
return std::make_unique<VoipCore>(
|
||||||
CreateEnvironment(std::move(config.task_queue_factory)),
|
env, std::move(config.encoder_factory), std::move(config.decoder_factory),
|
||||||
std::move(config.encoder_factory), std::move(config.decoder_factory),
|
std::move(config.audio_device_module), std::move(audio_processing));
|
||||||
std::move(config.audio_device_module),
|
|
||||||
std::move(config.audio_processing));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -28,17 +28,27 @@ namespace webrtc {
|
|||||||
// marked with comments as either mandatory or optional and default
|
// marked with comments as either mandatory or optional and default
|
||||||
// implementations that applications can use.
|
// implementations that applications can use.
|
||||||
struct VoipEngineConfig {
|
struct VoipEngineConfig {
|
||||||
|
// TODO: bugs.webrtc.org/369904700 - Remove explicit default constructors
|
||||||
|
// when deprecated `audio_processing` is removed and thus implicit
|
||||||
|
// constructors won't be considered deprecated.
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
VoipEngineConfig() = default;
|
||||||
|
VoipEngineConfig(VoipEngineConfig&&) = default;
|
||||||
|
VoipEngineConfig& operator=(VoipEngineConfig&&) = default;
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
// Mandatory (e.g. api/audio_codec/builtin_audio_encoder_factory).
|
// Mandatory (e.g. api/audio_codec/builtin_audio_encoder_factory).
|
||||||
// AudioEncoderFactory provides a set of audio codecs for VoipEngine to encode
|
// AudioEncoderFactory provides a set of audio codecs for VoipEngine to encode
|
||||||
// the audio input sample. Application can choose to limit the set to reduce
|
// the audio input sample. Application can choose to limit the set to reduce
|
||||||
// application footprint.
|
// application footprint.
|
||||||
rtc::scoped_refptr<AudioEncoderFactory> encoder_factory;
|
scoped_refptr<AudioEncoderFactory> encoder_factory;
|
||||||
|
|
||||||
// Mandatory (e.g. api/audio_codec/builtin_audio_decoder_factory).
|
// Mandatory (e.g. api/audio_codec/builtin_audio_decoder_factory).
|
||||||
// AudioDecoderFactory provides a set of audio codecs for VoipEngine to decode
|
// AudioDecoderFactory provides a set of audio codecs for VoipEngine to decode
|
||||||
// the received RTP packets from remote media endpoint. Application can choose
|
// the received RTP packets from remote media endpoint. Application can choose
|
||||||
// to limit the set to reduce application footprint.
|
// to limit the set to reduce application footprint.
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
|
scoped_refptr<AudioDecoderFactory> decoder_factory;
|
||||||
|
|
||||||
// Mandatory (e.g. api/task_queue/default_task_queue_factory).
|
// Mandatory (e.g. api/task_queue/default_task_queue_factory).
|
||||||
// TaskQeueuFactory provided for VoipEngine to work asynchronously on its
|
// TaskQeueuFactory provided for VoipEngine to work asynchronously on its
|
||||||
@ -49,15 +59,19 @@ struct VoipEngineConfig {
|
|||||||
// AudioDeviceModule that periocally provides audio input samples from
|
// AudioDeviceModule that periocally provides audio input samples from
|
||||||
// recording device (e.g. microphone) and requests audio output samples to
|
// recording device (e.g. microphone) and requests audio output samples to
|
||||||
// play through its output device (e.g. speaker).
|
// play through its output device (e.g. speaker).
|
||||||
rtc::scoped_refptr<AudioDeviceModule> audio_device_module;
|
scoped_refptr<AudioDeviceModule> audio_device_module;
|
||||||
|
|
||||||
// Optional (e.g. modules/audio_processing/include).
|
// Optional (e.g. api/audio/builtin_audio_processing_factory).
|
||||||
// AudioProcessing provides audio procesing functionalities (e.g. acoustic
|
// AudioProcessing provides audio procesing functionalities (e.g. acoustic
|
||||||
// echo cancellation, noise suppression, gain control, etc) on audio input
|
// echo cancellation, noise suppression, gain control, etc) on audio input
|
||||||
// samples for VoipEngine. When optionally not set, VoipEngine will not have
|
// samples for VoipEngine. When optionally not set, VoipEngine will not have
|
||||||
// such functionalities to perform on audio input samples received from
|
// such functionalities to perform on audio input samples received from
|
||||||
// AudioDeviceModule.
|
// AudioDeviceModule.
|
||||||
rtc::scoped_refptr<AudioProcessing> audio_processing;
|
std::unique_ptr<AudioProcessingFactory> audio_processing_factory;
|
||||||
|
|
||||||
|
// TODO: bugs.webrtc.org/369904700 - Remove when users are migrated to set
|
||||||
|
// `audio_processing_factory` instead.
|
||||||
|
[[deprecated]] scoped_refptr<AudioProcessing> audio_processing;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates a VoipEngine instance with provided VoipEngineConfig.
|
// Creates a VoipEngine instance with provided VoipEngineConfig.
|
||||||
|
|||||||
@ -56,6 +56,7 @@ if (is_android) {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":generated_jni",
|
":generated_jni",
|
||||||
|
"../../api/audio:builtin_audio_processing_factory",
|
||||||
"../../rtc_base:async_packet_socket",
|
"../../rtc_base:async_packet_socket",
|
||||||
"../../rtc_base:async_udp_socket",
|
"../../rtc_base:async_udp_socket",
|
||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "api/audio/builtin_audio_processing_factory.h"
|
||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||||
#include "api/task_queue/default_task_queue_factory.h"
|
#include "api/task_queue/default_task_queue_factory.h"
|
||||||
@ -130,7 +131,8 @@ void AndroidVoipClient::Init(
|
|||||||
config.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
|
config.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
|
||||||
config.audio_device_module =
|
config.audio_device_module =
|
||||||
webrtc::CreateJavaAudioDeviceModule(env, application_context.obj());
|
webrtc::CreateJavaAudioDeviceModule(env, application_context.obj());
|
||||||
config.audio_processing = webrtc::AudioProcessingBuilder().Create();
|
config.audio_processing_factory =
|
||||||
|
std::make_unique<webrtc::BuiltinAudioProcessingFactory>();
|
||||||
|
|
||||||
voip_thread_->Start();
|
voip_thread_->Start();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user