In order to be able to analyze the AGC behavior on

aecdump recordings in an efficient manner, it is
important to be able to use a standardized analysis
script. For this to be feasible, data log points should
be present.

This CL adds those logpoints as well as the framework
needed to for those to work.

BUG=webrtc:6564

Review-Url: https://codereview.webrtc.org/2457783003
Cr-Commit-Position: refs/heads/master@{#14812}
This commit is contained in:
peah 2016-10-28 03:12:11 -07:00 committed by Commit bot
parent 04055e95bf
commit 135259ac8f
5 changed files with 44 additions and 8 deletions

View File

@ -435,9 +435,6 @@ int AudioProcessingImpl::InitializeLocked() {
capture_audiobuffer_num_channels,
formats_.api_format.output_stream().num_frames()));
public_submodules_->gain_control->Initialize(num_proc_channels(),
proc_sample_rate_hz());
public_submodules_->echo_cancellation->Initialize(
proc_sample_rate_hz(), num_reverse_channels(), num_output_channels(),
num_proc_channels());
@ -450,6 +447,9 @@ int AudioProcessingImpl::InitializeLocked() {
public_submodules_->echo_control_mobile->Initialize(
proc_split_sample_rate_hz(), num_reverse_channels(),
num_output_channels());
public_submodules_->gain_control->Initialize(num_proc_channels(),
proc_sample_rate_hz());
if (constants_.use_experimental_agc) {
if (!private_submodules_->agc_manager.get()) {
private_submodules_->agc_manager.reset(new AgcManagerDirect(
@ -460,6 +460,7 @@ int AudioProcessingImpl::InitializeLocked() {
private_submodules_->agc_manager->Initialize();
private_submodules_->agc_manager->SetCaptureMuted(
capture_.output_will_be_muted);
public_submodules_->gain_control_for_experimental_agc->Initialize();
}
InitializeTransient();
InitializeBeamformer();

View File

@ -13,15 +13,23 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
int GainControlForExperimentalAgc::instance_counter_ = 0;
GainControlForExperimentalAgc::GainControlForExperimentalAgc(
GainControl* gain_control,
rtc::CriticalSection* crit_capture)
: real_gain_control_(gain_control),
: data_dumper_(new ApmDataDumper(instance_counter_)),
real_gain_control_(gain_control),
volume_(0),
crit_capture_(crit_capture) {}
crit_capture_(crit_capture) {
instance_counter_++;
}
GainControlForExperimentalAgc::~GainControlForExperimentalAgc() = default;
int GainControlForExperimentalAgc::Enable(bool enable) {
return real_gain_control_->Enable(enable);
@ -33,12 +41,16 @@ bool GainControlForExperimentalAgc::is_enabled() const {
int GainControlForExperimentalAgc::set_stream_analog_level(int level) {
rtc::CritScope cs_capture(crit_capture_);
data_dumper_->DumpRaw("experimental_gain_control_set_stream_analog_level", 1,
&level);
volume_ = level;
return AudioProcessing::kNoError;
}
int GainControlForExperimentalAgc::stream_analog_level() {
rtc::CritScope cs_capture(crit_capture_);
data_dumper_->DumpRaw("experimental_gain_control_stream_analog_level", 1,
&volume_);
return volume_;
}
@ -101,4 +113,8 @@ int GainControlForExperimentalAgc::GetMicVolume() {
return volume_;
}
void GainControlForExperimentalAgc::Initialize() {
data_dumper_->InitiateNewSetOfRecordings();
}
} // namespace webrtc

View File

@ -19,6 +19,8 @@
namespace webrtc {
class ApmDataDumper;
// This class has two main purposes:
//
// 1) It is returned instead of the real GainControl after the new AGC has been
@ -33,8 +35,9 @@ namespace webrtc {
class GainControlForExperimentalAgc : public GainControl,
public VolumeCallbacks {
public:
explicit GainControlForExperimentalAgc(GainControl* gain_control,
rtc::CriticalSection* crit_capture);
GainControlForExperimentalAgc(GainControl* gain_control,
rtc::CriticalSection* crit_capture);
~GainControlForExperimentalAgc() override;
// GainControl implementation.
int Enable(bool enable) override;
@ -58,11 +61,15 @@ class GainControlForExperimentalAgc : public GainControl,
void SetMicVolume(int volume) override;
int GetMicVolume() override;
void Initialize();
private:
std::unique_ptr<ApmDataDumper> data_dumper_;
GainControl* real_gain_control_;
int volume_;
rtc::CriticalSection* crit_capture_;
RTC_DISALLOW_COPY_AND_ASSIGN(GainControlForExperimentalAgc);
static int instance_counter_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlForExperimentalAgc);
};
} // namespace webrtc

View File

@ -14,6 +14,7 @@
#include "webrtc/base/optional.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
@ -84,10 +85,13 @@ class GainControlImpl::GainController {
RTC_DISALLOW_COPY_AND_ASSIGN(GainController);
};
int GainControlImpl::instance_counter_ = 0;
GainControlImpl::GainControlImpl(rtc::CriticalSection* crit_render,
rtc::CriticalSection* crit_capture)
: crit_render_(crit_render),
crit_capture_(crit_capture),
data_dumper_(new ApmDataDumper(instance_counter_)),
mode_(kAdaptiveAnalog),
minimum_capture_level_(0),
maximum_capture_level_(255),
@ -239,6 +243,7 @@ int GainControlImpl::compression_gain_db() const {
// TODO(ajm): ensure this is called under kAdaptiveAnalog.
int GainControlImpl::set_stream_analog_level(int level) {
rtc::CritScope cs(crit_capture_);
data_dumper_->DumpRaw("gain_control_set_stream_analog_level", 1, &level);
was_analog_level_set_ = true;
if (level < minimum_capture_level_ || level > maximum_capture_level_) {
@ -251,6 +256,8 @@ int GainControlImpl::set_stream_analog_level(int level) {
int GainControlImpl::stream_analog_level() {
rtc::CritScope cs(crit_capture_);
data_dumper_->DumpRaw("gain_control_stream_analog_level", 1,
&analog_capture_level_);
// TODO(ajm): enable this assertion?
//RTC_DCHECK_EQ(kAdaptiveAnalog, mode_);
@ -385,6 +392,7 @@ bool GainControlImpl::is_limiter_enabled() const {
void GainControlImpl::Initialize(size_t num_proc_channels, int sample_rate_hz) {
rtc::CritScope cs_render(crit_render_);
rtc::CritScope cs_capture(crit_capture_);
data_dumper_->InitiateNewSetOfRecordings();
num_proc_channels_ = rtc::Optional<size_t>(num_proc_channels);
sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz);

View File

@ -23,6 +23,7 @@
namespace webrtc {
class ApmDataDumper;
class AudioBuffer;
class GainControlImpl : public GainControl {
@ -69,6 +70,8 @@ class GainControlImpl : public GainControl {
rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
rtc::CriticalSection* const crit_capture_;
std::unique_ptr<ApmDataDumper> data_dumper_;
bool enabled_ = false;
Mode mode_ GUARDED_BY(crit_capture_);
@ -86,6 +89,7 @@ class GainControlImpl : public GainControl {
rtc::Optional<size_t> num_proc_channels_ GUARDED_BY(crit_capture_);
rtc::Optional<int> sample_rate_hz_ GUARDED_BY(crit_capture_);
static int instance_counter_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlImpl);
};
} // namespace webrtc