mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-20 00:57:49 +01:00
Change the way that AecDumps are created in APM
This CL changes the way that AecDumps are created in APM. Instead of being injected, they are now created via the API. This removes the AecDumpFactory from the API surface of APM and makes the API more explicit. The CL will be followed by one more CL that deprecates the usage of the AttachAecDump API also within the audio_processing and the fuzzer folders. The CL also moves the aec_dump.* files from the include folder to the aec_dump folder and changes the build files. The reasons for this are that 1) The content of aec_dump.h is not really part of the API surface of APM. 2) Those files anyway needed to be moved to a separate build- target to avoid a circular build-file dependency caused by the other changes in this CL Bug: webrtc:5298 Change-Id: I7dd6b49de76eb44158472874e1d4ae17dca9be54 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174750 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31207}
This commit is contained in:
parent
6b9c60b06d
commit
09e9a83d91
8 changed files with 100 additions and 18 deletions
|
@ -587,14 +587,8 @@ bool WebRtcVoiceEngine::StartAecDump(webrtc::FileWrapper file,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto aec_dump = webrtc::AecDumpFactory::Create(
|
return ap->CreateAndAttachAecDump(file.Release(), max_size_bytes,
|
||||||
std::move(file), max_size_bytes, low_priority_worker_queue_.get());
|
low_priority_worker_queue_.get());
|
||||||
if (!aec_dump) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ap->AttachAecDump(std::move(aec_dump));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcVoiceEngine::StopAecDump() {
|
void WebRtcVoiceEngine::StopAecDump() {
|
||||||
|
|
|
@ -50,6 +50,7 @@ rtc_library("api") {
|
||||||
"../../rtc_base:macromagic",
|
"../../rtc_base:macromagic",
|
||||||
"../../rtc_base:rtc_base_approved",
|
"../../rtc_base:rtc_base_approved",
|
||||||
"../../rtc_base/system:arch",
|
"../../rtc_base/system:arch",
|
||||||
|
"../../rtc_base/system:file_wrapper",
|
||||||
"../../rtc_base/system:rtc_export",
|
"../../rtc_base/system:rtc_export",
|
||||||
"agc:gain_control_interface",
|
"agc:gain_control_interface",
|
||||||
"//third_party/abseil-cpp/absl/types:optional",
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
|
@ -112,6 +113,20 @@ rtc_library("high_pass_filter") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_source_set("aec_dump_interface") {
|
||||||
|
visibility = [ "*" ]
|
||||||
|
sources = [
|
||||||
|
"include/aec_dump.cc",
|
||||||
|
"include/aec_dump.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":api",
|
||||||
|
":audio_frame_view",
|
||||||
|
"../../rtc_base:deprecation",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
rtc_library("audio_processing") {
|
rtc_library("audio_processing") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
configs += [ ":apm_debug_dump" ]
|
configs += [ ":apm_debug_dump" ]
|
||||||
|
@ -134,8 +149,6 @@ rtc_library("audio_processing") {
|
||||||
"gain_control_impl.h",
|
"gain_control_impl.h",
|
||||||
"gain_controller2.cc",
|
"gain_controller2.cc",
|
||||||
"gain_controller2.h",
|
"gain_controller2.h",
|
||||||
"include/aec_dump.cc",
|
|
||||||
"include/aec_dump.h",
|
|
||||||
"level_estimator.cc",
|
"level_estimator.cc",
|
||||||
"level_estimator.h",
|
"level_estimator.h",
|
||||||
"render_queue_item_verifier.h",
|
"render_queue_item_verifier.h",
|
||||||
|
@ -147,6 +160,7 @@ rtc_library("audio_processing") {
|
||||||
|
|
||||||
defines = []
|
defines = []
|
||||||
deps = [
|
deps = [
|
||||||
|
":aec_dump_interface",
|
||||||
":api",
|
":api",
|
||||||
":apm_logging",
|
":apm_logging",
|
||||||
":audio_buffer",
|
":audio_buffer",
|
||||||
|
@ -178,6 +192,7 @@ rtc_library("audio_processing") {
|
||||||
"../../system_wrappers:field_trial",
|
"../../system_wrappers:field_trial",
|
||||||
"../../system_wrappers:metrics",
|
"../../system_wrappers:metrics",
|
||||||
"aec3",
|
"aec3",
|
||||||
|
"aec_dump:aec_dump",
|
||||||
"aecm:aecm_core",
|
"aecm:aecm_core",
|
||||||
"agc",
|
"agc",
|
||||||
"agc:gain_control_interface",
|
"agc:gain_control_interface",
|
||||||
|
@ -198,6 +213,12 @@ rtc_library("audio_processing") {
|
||||||
"../../rtc_base:rtc_base_approved",
|
"../../rtc_base:rtc_base_approved",
|
||||||
"../../system_wrappers",
|
"../../system_wrappers",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (rtc_enable_protobuf) {
|
||||||
|
deps += [ "aec_dump:aec_dump_impl" ]
|
||||||
|
} else {
|
||||||
|
deps += [ "aec_dump:null_aec_dump_factory" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("voice_detection") {
|
rtc_library("voice_detection") {
|
||||||
|
@ -283,6 +304,7 @@ if (rtc_include_tests) {
|
||||||
testonly = true
|
testonly = true
|
||||||
sources = [ "include/mock_audio_processing.h" ]
|
sources = [ "include/mock_audio_processing.h" ]
|
||||||
deps = [
|
deps = [
|
||||||
|
":aec_dump_interface",
|
||||||
":api",
|
":api",
|
||||||
":audio_buffer",
|
":audio_buffer",
|
||||||
":audio_processing",
|
":audio_processing",
|
||||||
|
|
|
@ -13,7 +13,7 @@ rtc_source_set("aec_dump") {
|
||||||
sources = [ "aec_dump_factory.h" ]
|
sources = [ "aec_dump_factory.h" ]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"../",
|
"..:aec_dump_interface",
|
||||||
"../../../rtc_base:rtc_base_approved",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
"../../../rtc_base/system:file_wrapper",
|
"../../../rtc_base/system:file_wrapper",
|
||||||
"../../../rtc_base/system:rtc_export",
|
"../../../rtc_base/system:rtc_export",
|
||||||
|
@ -29,6 +29,7 @@ if (rtc_include_tests) {
|
||||||
]
|
]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
|
"..:aec_dump_interface",
|
||||||
"..:audioproc_test_utils",
|
"..:audioproc_test_utils",
|
||||||
"../",
|
"../",
|
||||||
"../../../test:test_support",
|
"../../../test:test_support",
|
||||||
|
@ -64,7 +65,7 @@ if (rtc_enable_protobuf) {
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":aec_dump",
|
":aec_dump",
|
||||||
"../",
|
"..:aec_dump_interface",
|
||||||
"../../../api/audio:audio_frame_api",
|
"../../../api/audio:audio_frame_api",
|
||||||
"../../../api/task_queue",
|
"../../../api/task_queue",
|
||||||
"../../../rtc_base:checks",
|
"../../../rtc_base:checks",
|
||||||
|
@ -104,6 +105,6 @@ rtc_library("null_aec_dump_factory") {
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":aec_dump",
|
":aec_dump",
|
||||||
"../",
|
"..:aec_dump_interface",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "api/audio/audio_frame.h"
|
#include "api/audio/audio_frame.h"
|
||||||
#include "common_audio/audio_converter.h"
|
#include "common_audio/audio_converter.h"
|
||||||
#include "common_audio/include/audio_util.h"
|
#include "common_audio/include/audio_util.h"
|
||||||
|
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||||
#include "modules/audio_processing/agc2/gain_applier.h"
|
#include "modules/audio_processing/agc2/gain_applier.h"
|
||||||
#include "modules/audio_processing/audio_buffer.h"
|
#include "modules/audio_processing/audio_buffer.h"
|
||||||
#include "modules/audio_processing/common.h"
|
#include "modules/audio_processing/common.h"
|
||||||
|
@ -1532,6 +1533,32 @@ int AudioProcessingImpl::recommended_stream_analog_level() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioProcessingImpl::CreateAndAttachAecDump(const std::string& file_name,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) {
|
||||||
|
std::unique_ptr<AecDump> aec_dump =
|
||||||
|
AecDumpFactory::Create(file_name, max_log_size_bytes, worker_queue);
|
||||||
|
if (!aec_dump) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AttachAecDump(std::move(aec_dump));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioProcessingImpl::CreateAndAttachAecDump(FILE* handle,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) {
|
||||||
|
std::unique_ptr<AecDump> aec_dump =
|
||||||
|
AecDumpFactory::Create(handle, max_log_size_bytes, worker_queue);
|
||||||
|
if (!aec_dump) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AttachAecDump(std::move(aec_dump));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void AudioProcessingImpl::AttachAecDump(std::unique_ptr<AecDump> aec_dump) {
|
void AudioProcessingImpl::AttachAecDump(std::unique_ptr<AecDump> aec_dump) {
|
||||||
RTC_DCHECK(aec_dump);
|
RTC_DCHECK(aec_dump);
|
||||||
rtc::CritScope cs_render(&crit_render_);
|
rtc::CritScope cs_render(&crit_render_);
|
||||||
|
|
|
@ -11,8 +11,11 @@
|
||||||
#ifndef MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
#ifndef MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
||||||
#define MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
#define MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "api/function_view.h"
|
#include "api/function_view.h"
|
||||||
|
@ -70,6 +73,13 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||||
int Initialize(const ProcessingConfig& processing_config) override;
|
int Initialize(const ProcessingConfig& processing_config) override;
|
||||||
void ApplyConfig(const AudioProcessing::Config& config) override;
|
void ApplyConfig(const AudioProcessing::Config& config) override;
|
||||||
void SetExtraOptions(const webrtc::Config& config) override;
|
void SetExtraOptions(const webrtc::Config& config) override;
|
||||||
|
bool CreateAndAttachAecDump(const std::string& file_name,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) override;
|
||||||
|
bool CreateAndAttachAecDump(FILE* handle,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) override;
|
||||||
|
// TODO(webrtc:5298) Deprecated variant.
|
||||||
void AttachAecDump(std::unique_ptr<AecDump> aec_dump) override;
|
void AttachAecDump(std::unique_ptr<AecDump> aec_dump) override;
|
||||||
void DetachAecDump() override;
|
void DetachAecDump() override;
|
||||||
void SetRuntimeSetting(RuntimeSetting setting) override;
|
void SetRuntimeSetting(RuntimeSetting setting) override;
|
||||||
|
|
|
@ -33,8 +33,13 @@
|
||||||
#include "rtc_base/arraysize.h"
|
#include "rtc_base/arraysize.h"
|
||||||
#include "rtc_base/deprecation.h"
|
#include "rtc_base/deprecation.h"
|
||||||
#include "rtc_base/ref_count.h"
|
#include "rtc_base/ref_count.h"
|
||||||
|
#include "rtc_base/system/file_wrapper.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
|
|
||||||
|
namespace rtc {
|
||||||
|
class TaskQueue;
|
||||||
|
} // namespace rtc
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class AecDump;
|
class AecDump;
|
||||||
|
@ -600,6 +605,23 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||||
// with this chunk of audio.
|
// with this chunk of audio.
|
||||||
virtual void set_stream_key_pressed(bool key_pressed) = 0;
|
virtual void set_stream_key_pressed(bool key_pressed) = 0;
|
||||||
|
|
||||||
|
// Creates and attaches an webrtc::AecDump for recording debugging
|
||||||
|
// information.
|
||||||
|
// The |worker_queue| may not be null and must outlive the created
|
||||||
|
// AecDump instance. |max_log_size_bytes == -1| means the log size
|
||||||
|
// will be unlimited. |handle| may not be null. The AecDump takes
|
||||||
|
// responsibility for |handle| and closes it in the destructor. A
|
||||||
|
// return value of true indicates that the file has been
|
||||||
|
// sucessfully opened, while a value of false indicates that
|
||||||
|
// opening the file failed.
|
||||||
|
virtual bool CreateAndAttachAecDump(const std::string& file_name,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) = 0;
|
||||||
|
virtual bool CreateAndAttachAecDump(FILE* handle,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) = 0;
|
||||||
|
|
||||||
|
// TODO(webrtc:5298) Deprecated variant.
|
||||||
// Attaches provided webrtc::AecDump for recording debugging
|
// Attaches provided webrtc::AecDump for recording debugging
|
||||||
// information. Log file and maximum file size logic is supposed to
|
// information. Log file and maximum file size logic is supposed to
|
||||||
// be handled by implementing instance of AecDump. Calling this
|
// be handled by implementing instance of AecDump. Calling this
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "modules/audio_processing/audio_buffer.h"
|
|
||||||
#include "modules/audio_processing/include/aec_dump.h"
|
#include "modules/audio_processing/include/aec_dump.h"
|
||||||
#include "modules/audio_processing/include/audio_processing.h"
|
#include "modules/audio_processing/include/audio_processing.h"
|
||||||
#include "modules/audio_processing/include/audio_processing_statistics.h"
|
#include "modules/audio_processing/include/audio_processing_statistics.h"
|
||||||
|
@ -128,8 +127,15 @@ class MockAudioProcessing : public ::testing::NiceMock<AudioProcessing> {
|
||||||
MOCK_CONST_METHOD0(delay_offset_ms, int());
|
MOCK_CONST_METHOD0(delay_offset_ms, int());
|
||||||
MOCK_METHOD1(set_stream_analog_level, void(int));
|
MOCK_METHOD1(set_stream_analog_level, void(int));
|
||||||
MOCK_CONST_METHOD0(recommended_stream_analog_level, int());
|
MOCK_CONST_METHOD0(recommended_stream_analog_level, int());
|
||||||
|
MOCK_METHOD3(CreateAndAttachAecDump,
|
||||||
virtual void AttachAecDump(std::unique_ptr<AecDump> aec_dump) {}
|
bool(const std::string& file_name,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue));
|
||||||
|
MOCK_METHOD3(CreateAndAttachAecDump,
|
||||||
|
bool(FILE* handle,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue));
|
||||||
|
MOCK_METHOD1(AttachAecDump, void(std::unique_ptr<AecDump>));
|
||||||
MOCK_METHOD0(DetachAecDump, void());
|
MOCK_METHOD0(DetachAecDump, void());
|
||||||
|
|
||||||
MOCK_METHOD0(GetStatistics, AudioProcessingStats());
|
MOCK_METHOD0(GetStatistics, AudioProcessingStats());
|
||||||
|
|
|
@ -292,8 +292,8 @@ std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer(
|
||||||
rtc::scoped_refptr<AudioProcessing> audio_processing =
|
rtc::scoped_refptr<AudioProcessing> audio_processing =
|
||||||
webrtc::AudioProcessingBuilder().Create();
|
webrtc::AudioProcessingBuilder().Create();
|
||||||
if (params->aec_dump_path && audio_processing) {
|
if (params->aec_dump_path && audio_processing) {
|
||||||
audio_processing->AttachAecDump(
|
audio_processing->CreateAndAttachAecDump(*params->aec_dump_path, -1,
|
||||||
AecDumpFactory::Create(*params->aec_dump_path, -1, task_queue));
|
task_queue);
|
||||||
}
|
}
|
||||||
rtc::scoped_refptr<AudioDeviceModule> audio_device_module =
|
rtc::scoped_refptr<AudioDeviceModule> audio_device_module =
|
||||||
CreateAudioDeviceModule(
|
CreateAudioDeviceModule(
|
||||||
|
|
Loading…
Reference in a new issue