#include "modules/audio_processing/aec3/echo_canceller3.h"
#include <algorithm>
#include <utility>
#include "absl/strings/string_view.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/high_pass_filter.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
enum class EchoCanceller3ApiCall { … };
bool DetectSaturation(rtc::ArrayView<const float> y) { … }
void RetrieveFieldTrialValue(absl::string_view trial_name,
float min,
float max,
float* value_to_update) { … }
void RetrieveFieldTrialValue(absl::string_view trial_name,
int min,
int max,
int* value_to_update) { … }
void FillSubFrameView(
AudioBuffer* frame,
size_t sub_frame_index,
std::vector<std::vector<rtc::ArrayView<float>>>* sub_frame_view) { … }
void FillSubFrameView(
bool proper_downmix_needed,
std::vector<std::vector<std::vector<float>>>* frame,
size_t sub_frame_index,
std::vector<std::vector<rtc::ArrayView<float>>>* sub_frame_view) { … }
void ProcessCaptureFrameContent(
AudioBuffer* linear_output,
AudioBuffer* capture,
bool level_change,
bool aec_reference_is_downmixed_stereo,
bool saturated_microphone_signal,
size_t sub_frame_index,
FrameBlocker* capture_blocker,
BlockFramer* linear_output_framer,
BlockFramer* output_framer,
BlockProcessor* block_processor,
Block* linear_output_block,
std::vector<std::vector<rtc::ArrayView<float>>>*
linear_output_sub_frame_view,
Block* capture_block,
std::vector<std::vector<rtc::ArrayView<float>>>* capture_sub_frame_view) { … }
void ProcessRemainingCaptureFrameContent(bool level_change,
bool aec_reference_is_downmixed_stereo,
bool saturated_microphone_signal,
FrameBlocker* capture_blocker,
BlockFramer* linear_output_framer,
BlockFramer* output_framer,
BlockProcessor* block_processor,
Block* linear_output_block,
Block* block) { … }
void BufferRenderFrameContent(
bool proper_downmix_needed,
std::vector<std::vector<std::vector<float>>>* render_frame,
size_t sub_frame_index,
FrameBlocker* render_blocker,
BlockProcessor* block_processor,
Block* block,
std::vector<std::vector<rtc::ArrayView<float>>>* sub_frame_view) { … }
void BufferRemainingRenderFrameContent(FrameBlocker* render_blocker,
BlockProcessor* block_processor,
Block* block) { … }
void CopyBufferIntoFrame(const AudioBuffer& buffer,
size_t num_bands,
size_t num_channels,
std::vector<std::vector<std::vector<float>>>* frame) { … }
}
EchoCanceller3Config AdjustConfig(const EchoCanceller3Config& config) { … }
class EchoCanceller3::RenderWriter { … };
EchoCanceller3::RenderWriter::RenderWriter(
ApmDataDumper* data_dumper,
const EchoCanceller3Config& config,
SwapQueue<std::vector<std::vector<std::vector<float>>>,
Aec3RenderQueueItemVerifier>* render_transfer_queue,
size_t num_bands,
size_t num_channels)
: … { … }
EchoCanceller3::RenderWriter::~RenderWriter() = default;
void EchoCanceller3::RenderWriter::Insert(const AudioBuffer& input) { … }
std::atomic<int> EchoCanceller3::instance_count_(0);
EchoCanceller3::EchoCanceller3(
const EchoCanceller3Config& config,
const absl::optional<EchoCanceller3Config>& multichannel_config,
int sample_rate_hz,
size_t num_render_channels,
size_t num_capture_channels)
: … { … }
EchoCanceller3::~EchoCanceller3() = default;
void EchoCanceller3::Initialize() { … }
void EchoCanceller3::AnalyzeRender(const AudioBuffer& render) { … }
void EchoCanceller3::AnalyzeCapture(const AudioBuffer& capture) { … }
void EchoCanceller3::ProcessCapture(AudioBuffer* capture, bool level_change) { … }
void EchoCanceller3::ProcessCapture(AudioBuffer* capture,
AudioBuffer* linear_output,
bool level_change) { … }
EchoControl::Metrics EchoCanceller3::GetMetrics() const { … }
void EchoCanceller3::SetAudioBufferDelay(int delay_ms) { … }
void EchoCanceller3::SetCaptureOutputUsage(bool capture_output_used) { … }
bool EchoCanceller3::ActiveProcessing() const { … }
EchoCanceller3Config EchoCanceller3::CreateDefaultMultichannelConfig() { … }
void EchoCanceller3::SetBlockProcessorForTesting(
std::unique_ptr<BlockProcessor> block_processor) { … }
void EchoCanceller3::EmptyRenderQueue() { … }
}