2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-06 19:03:39 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-12-15 09:41:24 +00:00
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
|
|
|
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#include <list>
|
2016-02-19 07:04:49 -08:00
|
|
|
#include <memory>
|
2017-03-31 03:08:07 -07:00
|
|
|
#include <string>
|
2015-07-23 11:41:39 -07:00
|
|
|
#include <vector>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2016-11-22 07:24:52 -08:00
|
|
|
#include "webrtc/base/function_view.h"
|
2016-10-07 14:54:10 -07:00
|
|
|
#include "webrtc/base/gtest_prod_util.h"
|
2016-09-28 17:42:01 -07:00
|
|
|
#include "webrtc/base/ignore_wundef.h"
|
2016-10-22 05:04:30 -07:00
|
|
|
#include "webrtc/base/swap_queue.h"
|
2014-12-15 09:41:24 +00:00
|
|
|
#include "webrtc/base/thread_annotations.h"
|
2015-11-28 12:35:15 -08:00
|
|
|
#include "webrtc/modules/audio_processing/audio_buffer.h"
|
2015-03-25 16:37:27 -07:00
|
|
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
2016-10-22 05:04:30 -07:00
|
|
|
#include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
|
2016-11-29 08:09:09 -08:00
|
|
|
#include "webrtc/modules/audio_processing/rms_level.h"
|
2015-11-28 12:35:15 -08:00
|
|
|
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
|
|
|
|
|
|
|
|
|
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
2017-03-31 03:08:07 -07:00
|
|
|
// Files generated at build-time by the protobuf compiler.
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_PUSH_IGNORING_WUNDEF()
|
2015-11-28 12:35:15 -08:00
|
|
|
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
|
|
|
|
|
#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
|
|
|
|
|
#else
|
2016-02-09 08:13:06 -08:00
|
|
|
#include "webrtc/modules/audio_processing/debug.pb.h"
|
2015-11-28 12:35:15 -08:00
|
|
|
#endif
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_POP_IGNORING_WUNDEF()
|
2015-11-28 12:35:15 -08:00
|
|
|
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2014-04-22 21:00:04 +00:00
|
|
|
|
2014-12-15 09:41:24 +00:00
|
|
|
class AgcManagerDirect;
|
2015-08-14 10:35:55 -07:00
|
|
|
class AudioConverter;
|
2015-03-25 16:37:27 -07:00
|
|
|
|
2016-07-01 17:19:09 -07:00
|
|
|
class NonlinearBeamformer;
|
2015-03-25 16:37:27 -07:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
class AudioProcessingImpl : public AudioProcessing {
|
|
|
|
|
public:
|
2015-11-28 12:35:15 -08:00
|
|
|
// Methods forcing APM to run in a single-threaded manner.
|
|
|
|
|
// Acquires both the render and capture locks.
|
2016-09-12 16:47:25 -07:00
|
|
|
explicit AudioProcessingImpl(const webrtc::Config& config);
|
2015-03-25 16:37:27 -07:00
|
|
|
// AudioProcessingImpl takes ownership of beamformer.
|
2016-09-12 16:47:25 -07:00
|
|
|
AudioProcessingImpl(const webrtc::Config& config,
|
|
|
|
|
NonlinearBeamformer* beamformer);
|
2016-08-29 14:46:07 -07:00
|
|
|
~AudioProcessingImpl() override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int Initialize() override;
|
2016-09-16 15:02:15 -07:00
|
|
|
int Initialize(int capture_input_sample_rate_hz,
|
|
|
|
|
int capture_output_sample_rate_hz,
|
|
|
|
|
int render_sample_rate_hz,
|
|
|
|
|
ChannelLayout capture_input_layout,
|
|
|
|
|
ChannelLayout capture_output_layout,
|
|
|
|
|
ChannelLayout render_input_layout) override;
|
2015-07-23 11:41:39 -07:00
|
|
|
int Initialize(const ProcessingConfig& processing_config) override;
|
2016-09-12 16:47:25 -07:00
|
|
|
void ApplyConfig(const AudioProcessing::Config& config) override;
|
|
|
|
|
void SetExtraOptions(const webrtc::Config& config) override;
|
2015-11-28 12:35:15 -08:00
|
|
|
void UpdateHistogramsOnCallEnd() override;
|
2016-01-15 03:06:36 -08:00
|
|
|
int StartDebugRecording(const char filename[kMaxFilenameSize],
|
|
|
|
|
int64_t max_log_size_bytes) override;
|
|
|
|
|
int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override;
|
2016-10-12 03:01:49 -07:00
|
|
|
int StartDebugRecording(FILE* handle) override;
|
2015-11-28 12:35:15 -08:00
|
|
|
int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
|
|
|
|
|
int StopDebugRecording() override;
|
|
|
|
|
|
|
|
|
|
// Capture-side exclusive methods possibly running APM in a
|
|
|
|
|
// multi-threaded manner. Acquire the capture lock.
|
2015-03-04 12:58:35 +00:00
|
|
|
int ProcessStream(AudioFrame* frame) override;
|
|
|
|
|
int ProcessStream(const float* const* src,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t samples_per_channel,
|
2015-03-04 12:58:35 +00:00
|
|
|
int input_sample_rate_hz,
|
|
|
|
|
ChannelLayout input_layout,
|
|
|
|
|
int output_sample_rate_hz,
|
|
|
|
|
ChannelLayout output_layout,
|
|
|
|
|
float* const* dest) override;
|
2015-07-23 11:41:39 -07:00
|
|
|
int ProcessStream(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest) override;
|
2015-11-28 12:35:15 -08:00
|
|
|
void set_output_will_be_muted(bool muted) override;
|
|
|
|
|
int set_stream_delay_ms(int delay) override;
|
|
|
|
|
void set_delay_offset_ms(int offset) override;
|
|
|
|
|
int delay_offset_ms() const override;
|
|
|
|
|
void set_stream_key_pressed(bool key_pressed) override;
|
|
|
|
|
|
|
|
|
|
// Render-side exclusive methods possibly running APM in a
|
|
|
|
|
// multi-threaded manner. Acquire the render lock.
|
2015-08-14 10:35:55 -07:00
|
|
|
int ProcessReverseStream(AudioFrame* frame) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int AnalyzeReverseStream(const float* const* data,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t samples_per_channel,
|
2015-03-04 12:58:35 +00:00
|
|
|
int sample_rate_hz,
|
|
|
|
|
ChannelLayout layout) override;
|
2015-08-14 10:35:55 -07:00
|
|
|
int ProcessReverseStream(const float* const* src,
|
2016-09-16 15:02:15 -07:00
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
2015-08-14 10:35:55 -07:00
|
|
|
float* const* dest) override;
|
2015-11-28 12:35:15 -08:00
|
|
|
|
|
|
|
|
// Methods only accessed from APM submodules or
|
|
|
|
|
// from AudioProcessing tests in a single-threaded manner.
|
|
|
|
|
// Hence there is no need for locks in these.
|
|
|
|
|
int proc_sample_rate_hz() const override;
|
|
|
|
|
int proc_split_sample_rate_hz() const override;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_input_channels() const override;
|
|
|
|
|
size_t num_proc_channels() const override;
|
|
|
|
|
size_t num_output_channels() const override;
|
|
|
|
|
size_t num_reverse_channels() const override;
|
2015-03-04 12:58:35 +00:00
|
|
|
int stream_delay_ms() const override;
|
2015-11-28 12:35:15 -08:00
|
|
|
bool was_stream_delay_set() const override
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
|
|
|
|
|
2016-10-28 07:55:33 -07:00
|
|
|
AudioProcessingStatistics GetStatistics() const override;
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Methods returning pointers to APM submodules.
|
|
|
|
|
// No locks are aquired in those, as those locks
|
|
|
|
|
// would offer no protection (the submodules are
|
|
|
|
|
// created only once in a single-treaded manner
|
|
|
|
|
// during APM creation).
|
2015-03-04 12:58:35 +00:00
|
|
|
EchoCancellation* echo_cancellation() const override;
|
|
|
|
|
EchoControlMobile* echo_control_mobile() const override;
|
|
|
|
|
GainControl* gain_control() const override;
|
2016-11-22 07:24:52 -08:00
|
|
|
// TODO(peah): Deprecate this API call.
|
2015-03-04 12:58:35 +00:00
|
|
|
HighPassFilter* high_pass_filter() const override;
|
|
|
|
|
LevelEstimator* level_estimator() const override;
|
|
|
|
|
NoiseSuppression* noise_suppression() const override;
|
|
|
|
|
VoiceDetection* voice_detection() const override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-11-22 07:24:52 -08:00
|
|
|
// TODO(peah): Remove these two methods once the new API allows that.
|
|
|
|
|
void MutateConfig(rtc::FunctionView<void(AudioProcessing::Config*)> mutator);
|
|
|
|
|
AudioProcessing::Config GetConfig() const;
|
|
|
|
|
|
2014-01-07 17:45:09 +00:00
|
|
|
protected:
|
2014-03-10 22:26:12 +00:00
|
|
|
// Overridden in a mock.
|
2015-11-28 12:35:15 -08:00
|
|
|
virtual int InitializeLocked()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2014-01-07 17:45:09 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
2016-10-07 14:54:10 -07:00
|
|
|
// TODO(peah): These friend classes should be removed as soon as the new
|
|
|
|
|
// parameter setting scheme allows.
|
|
|
|
|
FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, DefaultBehavior);
|
|
|
|
|
FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, ValidConfigBehavior);
|
|
|
|
|
FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, InValidConfigBehavior);
|
2015-11-28 12:35:15 -08:00
|
|
|
struct ApmPublicSubmodules;
|
|
|
|
|
struct ApmPrivateSubmodules;
|
|
|
|
|
|
2016-11-22 07:24:52 -08:00
|
|
|
// Submodule interface implementations.
|
|
|
|
|
std::unique_ptr<HighPassFilter> high_pass_filter_impl_;
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
class ApmSubmoduleStates {
|
|
|
|
|
public:
|
|
|
|
|
ApmSubmoduleStates();
|
|
|
|
|
// Updates the submodule state and returns true if it has changed.
|
2016-11-22 07:24:52 -08:00
|
|
|
bool Update(bool low_cut_filter_enabled,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool echo_canceller_enabled,
|
|
|
|
|
bool mobile_echo_controller_enabled,
|
2016-10-28 05:39:16 -07:00
|
|
|
bool residual_echo_detector_enabled,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool noise_suppressor_enabled,
|
|
|
|
|
bool intelligibility_enhancer_enabled,
|
|
|
|
|
bool beamformer_enabled,
|
|
|
|
|
bool adaptive_gain_controller_enabled,
|
|
|
|
|
bool level_controller_enabled,
|
2016-12-14 01:16:23 -08:00
|
|
|
bool echo_canceller3_enabled,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool voice_activity_detector_enabled,
|
|
|
|
|
bool level_estimator_enabled,
|
|
|
|
|
bool transient_suppressor_enabled);
|
|
|
|
|
bool CaptureMultiBandSubModulesActive() const;
|
|
|
|
|
bool CaptureMultiBandProcessingActive() const;
|
|
|
|
|
bool RenderMultiBandSubModulesActive() const;
|
|
|
|
|
bool RenderMultiBandProcessingActive() const;
|
|
|
|
|
|
|
|
|
|
private:
|
2016-11-22 07:24:52 -08:00
|
|
|
bool low_cut_filter_enabled_ = false;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool echo_canceller_enabled_ = false;
|
|
|
|
|
bool mobile_echo_controller_enabled_ = false;
|
2016-10-28 05:39:16 -07:00
|
|
|
bool residual_echo_detector_enabled_ = false;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool noise_suppressor_enabled_ = false;
|
|
|
|
|
bool intelligibility_enhancer_enabled_ = false;
|
|
|
|
|
bool beamformer_enabled_ = false;
|
|
|
|
|
bool adaptive_gain_controller_enabled_ = false;
|
|
|
|
|
bool level_controller_enabled_ = false;
|
2016-12-14 01:16:23 -08:00
|
|
|
bool echo_canceller3_enabled_ = false;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool level_estimator_enabled_ = false;
|
|
|
|
|
bool voice_activity_detector_enabled_ = false;
|
|
|
|
|
bool transient_suppressor_enabled_ = false;
|
|
|
|
|
bool first_update_ = true;
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
|
|
|
|
// State for the debug dump.
|
|
|
|
|
struct ApmDebugDumpThreadState {
|
2016-08-29 14:46:07 -07:00
|
|
|
ApmDebugDumpThreadState();
|
|
|
|
|
~ApmDebugDumpThreadState();
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<audioproc::Event> event_msg; // Protobuf message.
|
2017-03-31 03:08:07 -07:00
|
|
|
std::string event_str; // Memory for protobuf serialization.
|
2015-11-28 12:35:15 -08:00
|
|
|
|
|
|
|
|
// Serialized string of last saved APM configuration.
|
2017-03-31 03:08:07 -07:00
|
|
|
std::string last_serialized_config;
|
2015-11-28 12:35:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ApmDebugDumpState {
|
2016-08-29 14:46:07 -07:00
|
|
|
ApmDebugDumpState();
|
|
|
|
|
~ApmDebugDumpState();
|
2016-01-15 03:06:36 -08:00
|
|
|
// Number of bytes that can still be written to the log before the maximum
|
|
|
|
|
// size is reached. A value of <= 0 indicates that no limit is used.
|
|
|
|
|
int64_t num_bytes_left_for_log_ = -1;
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<FileWrapper> debug_file;
|
2015-11-28 12:35:15 -08:00
|
|
|
ApmDebugDumpThreadState render;
|
|
|
|
|
ApmDebugDumpThreadState capture;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Method for modifying the formats struct that are called from both
|
|
|
|
|
// the render and capture threads. The check for whether modifications
|
|
|
|
|
// are needed is done while holding the render lock only, thereby avoiding
|
|
|
|
|
// that the capture thread blocks the render thread.
|
|
|
|
|
// The struct is modified in a single-threaded manner by holding both the
|
|
|
|
|
// render and capture locks.
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
int MaybeInitialize(const ProcessingConfig& config, bool force_initialization)
|
2015-11-28 12:35:15 -08:00
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
|
|
|
|
|
|
|
|
|
int MaybeInitializeRender(const ProcessingConfig& processing_config)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
int MaybeInitializeCapture(const ProcessingConfig& processing_config,
|
|
|
|
|
bool force_initialization)
|
2015-11-28 12:35:15 -08:00
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
// Method for updating the state keeping track of the active submodules.
|
|
|
|
|
// Returns a bool indicating whether the state has changed.
|
|
|
|
|
bool UpdateActiveSubmoduleStates() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2015-11-28 12:35:15 -08:00
|
|
|
|
|
|
|
|
// Methods requiring APM running in a single-threaded manner.
|
|
|
|
|
// Are called with both the render and capture locks already
|
|
|
|
|
// acquired.
|
|
|
|
|
void InitializeTransient()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
|
|
|
|
void InitializeBeamformer()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
|
|
|
|
void InitializeIntelligibility()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2015-07-23 11:41:39 -07:00
|
|
|
int InitializeLocked(const ProcessingConfig& config)
|
2015-11-28 12:35:15 -08:00
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2016-06-29 15:26:12 -07:00
|
|
|
void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2016-10-28 05:39:16 -07:00
|
|
|
void InitializeResidualEchoDetector()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2016-11-22 07:24:52 -08:00
|
|
|
void InitializeLowCutFilter() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2016-12-14 01:16:23 -08:00
|
|
|
void InitializeEchoCanceller3() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2015-11-28 12:35:15 -08:00
|
|
|
|
2016-10-22 05:04:30 -07:00
|
|
|
void EmptyQueuedRenderAudio();
|
|
|
|
|
void AllocateRenderQueue()
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2016-10-25 05:42:20 -07:00
|
|
|
void QueueRenderAudio(AudioBuffer* audio)
|
2016-10-22 05:04:30 -07:00
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Capture-side exclusive methods possibly running APM in a multi-threaded
|
|
|
|
|
// manner that are called with the render lock already acquired.
|
2016-09-16 15:02:15 -07:00
|
|
|
int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2015-11-28 12:35:15 -08:00
|
|
|
void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
|
|
|
|
|
|
|
|
|
// Render-side exclusive methods possibly running APM in a multi-threaded
|
|
|
|
|
// manner that are called with the render lock already acquired.
|
2015-08-14 10:35:55 -07:00
|
|
|
// TODO(ekm): Remove once all clients updated to new interface.
|
2015-11-28 12:35:15 -08:00
|
|
|
int AnalyzeReverseStreamLocked(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
2016-09-16 15:02:15 -07:00
|
|
|
int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
|
2015-11-28 12:35:15 -08:00
|
|
|
|
|
|
|
|
// Debug dump methods that are internal and called without locks.
|
|
|
|
|
// TODO(peah): Make thread safe.
|
2011-12-03 00:03:31 +00:00
|
|
|
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
|
|
|
|
// TODO(andrew): make this more graceful. Ideally we would split this stuff
|
|
|
|
|
// out into a separate class with an "enabled" and "disabled" implementation.
|
2015-11-28 12:35:15 -08:00
|
|
|
static int WriteMessageToDebugFile(FileWrapper* debug_file,
|
2016-01-15 03:06:36 -08:00
|
|
|
int64_t* filesize_limit_bytes,
|
2015-11-28 12:35:15 -08:00
|
|
|
rtc::CriticalSection* crit_debug,
|
|
|
|
|
ApmDebugDumpThreadState* debug_state);
|
|
|
|
|
int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
2015-10-03 00:39:14 +02:00
|
|
|
|
|
|
|
|
// Writes Config message. If not |forced|, only writes the current config if
|
|
|
|
|
// it is different from the last saved one; if |forced|, writes the config
|
|
|
|
|
// regardless of the last saved.
|
2015-11-28 12:35:15 -08:00
|
|
|
int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
2015-10-03 00:39:14 +02:00
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Critical section.
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection crit_debug_;
|
2015-10-03 00:39:14 +02:00
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Debug dump state.
|
|
|
|
|
ApmDebugDumpState debug_dump_;
|
2011-12-03 00:03:31 +00:00
|
|
|
#endif
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Critical sections.
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_);
|
|
|
|
|
rtc::CriticalSection crit_capture_;
|
2015-11-28 12:35:15 -08:00
|
|
|
|
2016-10-07 14:54:10 -07:00
|
|
|
// Struct containing the Config specifying the behavior of APM.
|
|
|
|
|
AudioProcessing::Config config_;
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
// Class containing information about what submodules are active.
|
|
|
|
|
ApmSubmoduleStates submodule_states_;
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
// Structs containing the pointers to the submodules.
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<ApmPublicSubmodules> public_submodules_;
|
2016-10-28 05:39:16 -07:00
|
|
|
std::unique_ptr<ApmPrivateSubmodules> private_submodules_;
|
2015-11-28 12:35:15 -08:00
|
|
|
|
2015-11-17 02:16:45 -08:00
|
|
|
// State that is written to while holding both the render and capture locks
|
2015-11-28 12:35:15 -08:00
|
|
|
// but can be read without any lock being held.
|
|
|
|
|
// As this is only accessed internally of APM, and all internal methods in APM
|
|
|
|
|
// either are holding the render or capture locks, this construct is safe as
|
|
|
|
|
// it is not possible to read the variables while writing them.
|
|
|
|
|
struct ApmFormatState {
|
|
|
|
|
ApmFormatState()
|
|
|
|
|
: // Format of processing streams at input/output call sites.
|
|
|
|
|
api_format({{{kSampleRate16kHz, 1, false},
|
|
|
|
|
{kSampleRate16kHz, 1, false},
|
|
|
|
|
{kSampleRate16kHz, 1, false},
|
|
|
|
|
{kSampleRate16kHz, 1, false}}}),
|
2016-09-16 15:02:15 -07:00
|
|
|
render_processing_format(kSampleRate16kHz, 1) {}
|
2015-11-28 12:35:15 -08:00
|
|
|
ProcessingConfig api_format;
|
2016-09-16 15:02:15 -07:00
|
|
|
StreamConfig render_processing_format;
|
2015-11-28 12:35:15 -08:00
|
|
|
} formats_;
|
|
|
|
|
|
|
|
|
|
// APM constants.
|
|
|
|
|
const struct ApmConstants {
|
2016-12-05 09:08:42 -08:00
|
|
|
ApmConstants(int agc_startup_min_volume,
|
|
|
|
|
int agc_clipped_level_min,
|
|
|
|
|
bool use_experimental_agc)
|
2015-11-17 02:16:45 -08:00
|
|
|
: // Format of processing streams at input/output call sites.
|
2015-11-28 12:35:15 -08:00
|
|
|
agc_startup_min_volume(agc_startup_min_volume),
|
2016-12-05 09:08:42 -08:00
|
|
|
agc_clipped_level_min(agc_clipped_level_min),
|
2016-05-16 15:32:38 -07:00
|
|
|
use_experimental_agc(use_experimental_agc) {}
|
2015-11-28 12:35:15 -08:00
|
|
|
int agc_startup_min_volume;
|
2016-12-05 09:08:42 -08:00
|
|
|
int agc_clipped_level_min;
|
2016-02-13 16:40:47 -08:00
|
|
|
bool use_experimental_agc;
|
2015-11-28 12:35:15 -08:00
|
|
|
} constants_;
|
|
|
|
|
|
|
|
|
|
struct ApmCaptureState {
|
2016-01-11 18:04:30 -08:00
|
|
|
ApmCaptureState(bool transient_suppressor_enabled,
|
|
|
|
|
const std::vector<Point>& array_geometry,
|
2016-08-29 14:46:07 -07:00
|
|
|
SphericalPointf target_direction);
|
|
|
|
|
~ApmCaptureState();
|
2015-11-28 12:35:15 -08:00
|
|
|
int aec_system_delay_jumps;
|
|
|
|
|
int delay_offset_ms;
|
|
|
|
|
bool was_stream_delay_set;
|
|
|
|
|
int last_stream_delay_ms;
|
|
|
|
|
int last_aec_system_delay_ms;
|
|
|
|
|
int stream_delay_jumps;
|
|
|
|
|
bool output_will_be_muted;
|
|
|
|
|
bool key_pressed;
|
|
|
|
|
bool transient_suppressor_enabled;
|
2016-01-11 18:04:30 -08:00
|
|
|
std::vector<Point> array_geometry;
|
|
|
|
|
SphericalPointf target_direction;
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<AudioBuffer> capture_audio;
|
2016-09-16 15:02:15 -07:00
|
|
|
// Only the rate and samples fields of capture_processing_format_ are used
|
|
|
|
|
// because the capture processing number of channels is mutable and is
|
|
|
|
|
// tracked by the capture_audio_.
|
|
|
|
|
StreamConfig capture_processing_format;
|
2015-11-28 12:35:15 -08:00
|
|
|
int split_rate;
|
|
|
|
|
} capture_ GUARDED_BY(crit_capture_);
|
|
|
|
|
|
|
|
|
|
struct ApmCaptureNonLockedState {
|
2016-05-16 15:32:38 -07:00
|
|
|
ApmCaptureNonLockedState(bool beamformer_enabled,
|
2016-09-12 16:47:25 -07:00
|
|
|
bool intelligibility_enabled)
|
2016-09-16 15:02:15 -07:00
|
|
|
: capture_processing_format(kSampleRate16kHz),
|
2015-11-28 12:35:15 -08:00
|
|
|
split_rate(kSampleRate16kHz),
|
2016-01-11 20:32:29 -08:00
|
|
|
stream_delay_ms(0),
|
2016-05-16 15:32:38 -07:00
|
|
|
beamformer_enabled(beamformer_enabled),
|
2016-09-12 16:47:25 -07:00
|
|
|
intelligibility_enabled(intelligibility_enabled) {}
|
2016-09-16 15:02:15 -07:00
|
|
|
// Only the rate and samples fields of capture_processing_format_ are used
|
|
|
|
|
// because the forward processing number of channels is mutable and is
|
|
|
|
|
// tracked by the capture_audio_.
|
|
|
|
|
StreamConfig capture_processing_format;
|
2015-11-28 12:35:15 -08:00
|
|
|
int split_rate;
|
|
|
|
|
int stream_delay_ms;
|
2016-01-11 20:32:29 -08:00
|
|
|
bool beamformer_enabled;
|
2016-05-16 15:32:38 -07:00
|
|
|
bool intelligibility_enabled;
|
2016-09-12 16:47:25 -07:00
|
|
|
bool level_controller_enabled = false;
|
2016-12-14 01:16:23 -08:00
|
|
|
bool echo_canceller3_enabled = false;
|
2015-11-28 12:35:15 -08:00
|
|
|
} capture_nonlocked_;
|
|
|
|
|
|
|
|
|
|
struct ApmRenderState {
|
2016-08-29 14:46:07 -07:00
|
|
|
ApmRenderState();
|
|
|
|
|
~ApmRenderState();
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<AudioConverter> render_converter;
|
|
|
|
|
std::unique_ptr<AudioBuffer> render_audio;
|
2015-11-28 12:35:15 -08:00
|
|
|
} render_ GUARDED_BY(crit_render_);
|
2016-10-22 05:04:30 -07:00
|
|
|
|
2016-10-25 05:42:20 -07:00
|
|
|
size_t aec_render_queue_element_max_size_ GUARDED_BY(crit_render_)
|
2016-10-22 05:04:30 -07:00
|
|
|
GUARDED_BY(crit_capture_) = 0;
|
2016-10-25 05:42:20 -07:00
|
|
|
std::vector<float> aec_render_queue_buffer_ GUARDED_BY(crit_render_);
|
|
|
|
|
std::vector<float> aec_capture_queue_buffer_ GUARDED_BY(crit_capture_);
|
2016-10-25 04:45:24 -07:00
|
|
|
|
2016-10-25 05:42:20 -07:00
|
|
|
size_t aecm_render_queue_element_max_size_ GUARDED_BY(crit_render_)
|
2016-10-25 04:45:24 -07:00
|
|
|
GUARDED_BY(crit_capture_) = 0;
|
2016-10-25 05:42:20 -07:00
|
|
|
std::vector<int16_t> aecm_render_queue_buffer_ GUARDED_BY(crit_render_);
|
|
|
|
|
std::vector<int16_t> aecm_capture_queue_buffer_ GUARDED_BY(crit_capture_);
|
|
|
|
|
|
|
|
|
|
size_t agc_render_queue_element_max_size_ GUARDED_BY(crit_render_)
|
|
|
|
|
GUARDED_BY(crit_capture_) = 0;
|
|
|
|
|
std::vector<int16_t> agc_render_queue_buffer_ GUARDED_BY(crit_render_);
|
|
|
|
|
std::vector<int16_t> agc_capture_queue_buffer_ GUARDED_BY(crit_capture_);
|
2016-10-22 05:04:30 -07:00
|
|
|
|
2016-10-28 05:39:16 -07:00
|
|
|
size_t red_render_queue_element_max_size_ GUARDED_BY(crit_render_)
|
|
|
|
|
GUARDED_BY(crit_capture_) = 0;
|
|
|
|
|
std::vector<float> red_render_queue_buffer_ GUARDED_BY(crit_render_);
|
|
|
|
|
std::vector<float> red_capture_queue_buffer_ GUARDED_BY(crit_capture_);
|
|
|
|
|
|
2016-12-20 13:45:58 -08:00
|
|
|
RmsLevel capture_input_rms_ GUARDED_BY(crit_capture_);
|
|
|
|
|
RmsLevel capture_output_rms_ GUARDED_BY(crit_capture_);
|
|
|
|
|
int capture_rms_interval_counter_ GUARDED_BY(crit_capture_) = 0;
|
2016-11-29 08:09:09 -08:00
|
|
|
|
2016-10-22 05:04:30 -07:00
|
|
|
// Lock protection not needed.
|
|
|
|
|
std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
|
2016-10-25 05:42:20 -07:00
|
|
|
aec_render_signal_queue_;
|
|
|
|
|
std::unique_ptr<
|
|
|
|
|
SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
|
|
|
|
|
aecm_render_signal_queue_;
|
2016-10-25 04:45:24 -07:00
|
|
|
std::unique_ptr<
|
|
|
|
|
SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_signal_queue_;
|
2016-10-28 05:39:16 -07:00
|
|
|
std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
|
|
|
|
|
red_render_signal_queue_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2014-04-22 21:00:04 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2014-12-15 09:41:24 +00:00
|
|
|
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
|