Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(972)

Unified Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1348903004: Adding APM configuration in AEC dump. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: removing macro and more Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_processing_impl.cc
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 4ef4e6da6a307e6533e8ac9ddf39e888c2c52713..f6811d62de8f08c54fc677e976d3f1ab7aad86ac 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -42,15 +42,6 @@ extern "C" {
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/metrics.h"
-#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
-// Files generated at build-time by the protobuf compiler.
-#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
-#else
-#include "webrtc/audio_processing/debug.pb.h"
-#endif
-#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
-
#define RETURN_ON_ERR(expr) \
do { \
int err = (expr); \
@@ -194,6 +185,7 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
debug_file_(FileWrapper::Create()),
event_msg_(new audioproc::Event()),
+ config_(new audioproc::Config()),
#endif
api_format_({{{kSampleRate16kHz, 1, false},
{kSampleRate16kHz, 1, false},
@@ -250,6 +242,10 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_));
SetExtraOptions(config);
+
+#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ UpdateCurrentConfig();
+#endif
}
AudioProcessingImpl::~AudioProcessingImpl() {
@@ -560,6 +556,10 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
api_format_.input_stream().num_frames());
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ if (debug_file_->Open() && UpdateCurrentConfig()) {
+ RETURN_ON_ERR(WriteConfigMessage());
+ }
+
if (debug_file_->Open()) {
event_msg_->set_type(audioproc::Event::STREAM);
audioproc::Stream* msg = event_msg_->mutable_stream();
@@ -946,7 +946,13 @@ int AudioProcessingImpl::StartDebugRecording(
return kFileError;
}
- int err = WriteInitMessage();
+ UpdateCurrentConfig();
+ int err = WriteConfigMessage();
+ if (err != kNoError) {
+ return err;
+ }
+
+ err = WriteInitMessage();
if (err != kNoError) {
return err;
}
@@ -975,7 +981,13 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
return kFileError;
}
- int err = WriteInitMessage();
+ UpdateCurrentConfig();
+ int err = WriteConfigMessage();
+ if (err != kNoError) {
+ return err;
+ }
+
+ err = WriteInitMessage();
if (err != kNoError) {
return err;
}
@@ -1255,6 +1267,152 @@ int AudioProcessingImpl::WriteInitMessage() {
return kNoError;
}
+
+bool AudioProcessingImpl::UpdateCurrentConfig() {
peah-webrtc 2015/10/02 08:34:27 This function became very long (for good reasons)
minyue-webrtc 2015/10/02 09:01:42 also goes away per Andrew's suggestion
+ bool changed = false;
+
+ // Acoustic echo canceler.
+ {
+ const bool value = echo_cancellation_->is_enabled();
+ if (!config_->has_aec_enabled() || value != config_->aec_enabled()) {
+ config_->set_aec_enabled(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = echo_cancellation_->is_delay_agnostic_enabled();
+ if (!config_->has_aec_delay_agnostic() ||
+ value != config_->aec_delay_agnostic()) {
+ config_->set_aec_delay_agnostic(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = echo_cancellation_->is_drift_compensation_enabled();
+ if (!config_->has_aec_drift_compensation() ||
+ value != config_->aec_drift_compensation()) {
+ config_->set_aec_drift_compensation(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = echo_cancellation_->is_extended_filter_enabled();
+ if (!config_->has_aec_extended_filter() ||
+ value != config_->aec_extended_filter()) {
+ config_->set_aec_extended_filter(value);
+ changed = true;
+ }
+ }
+ {
+ const int value = static_cast<int>(echo_cancellation_->suppression_level());
+ if (!config_->has_aec_suppression_level() ||
+ value != config_->aec_suppression_level()) {
+ config_->set_aec_suppression_level(value);
+ changed = true;
+ }
+ }
+
+ // Mobile AEC.
+ {
+ const bool value = echo_control_mobile_->is_enabled();
+ if (!config_->has_aecm_enabled() || value != config_->aecm_enabled()) {
+ config_->set_aecm_enabled(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = echo_control_mobile_->is_comfort_noise_enabled();
+ if (!config_->has_aecm_comfort_noise() ||
+ value != config_->aecm_comfort_noise()) {
+ config_->set_aecm_comfort_noise(value);
+ changed = true;
+ }
+ }
+ {
+ const int value = static_cast<int>(echo_control_mobile_->routing_mode());
+ if (!config_->has_aecm_routing_mode() ||
+ value != config_->aecm_routing_mode()) {
+ config_->set_aecm_routing_mode(value);
+ changed = true;
+ }
+ }
+
+ // Automatic gain controller.
+ {
+ const bool value = gain_control_->is_enabled();
+ if (!config_->has_agc_enabled() || value != config_->agc_enabled()) {
+ config_->set_agc_enabled(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = use_new_agc_;
+ if (!config_->has_agc_experiment() || value != config_->agc_experiment()) {
+ config_->set_agc_experiment(value);
+ changed = true;
+ }
+ }
+ {
+ const int value = static_cast<int>(gain_control_->mode());
+ if (!config_->has_agc_mode() || value != config_->agc_mode()) {
+ config_->set_agc_mode(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = gain_control_->is_limiter_enabled();
+ if (!config_->has_agc_limiter() || value != config_->agc_limiter()) {
+ config_->set_agc_limiter(value);
+ changed = true;
+ }
+ }
+
+ // High pass filter.
+ {
+ const bool value = high_pass_filter_->is_enabled();
+ if (!config_->has_hpf_enabled() || value != config_->hpf_enabled()) {
+ config_->set_hpf_enabled(value);
+ changed = true;
+ }
+ }
+
+ // Noise suppression.
+ {
+ const bool value = noise_suppression_->is_enabled();
+ if (!config_->has_ns_enabled() || value != config_->ns_enabled()) {
+ config_->set_ns_enabled(value);
+ changed = true;
+ }
+ }
+ {
+ const bool value = transient_suppressor_enabled_;
+ if (!config_->has_ns_experiment() || value != config_->ns_experiment()) {
+ config_->set_ns_experiment(value);
+ changed = true;
+ }
+ }
+ {
+ const int value = static_cast<int>(noise_suppression_->level());
+ if (!config_->has_ns_level() || value != config_->ns_level()) {
+ config_->set_ns_level(value);
+ changed = true;
+ }
+ }
+
+ return changed;
+}
+
+int AudioProcessingImpl::WriteConfigMessage() {
+ event_msg_->set_type(audioproc::Event::CONFIG);
+ event_msg_->mutable_config()->CopyFrom(*config_);
+
+ int err = WriteMessageToDebugFile();
+ if (err != kNoError) {
+ return err;
+ }
+
+ return kNoError;
+}
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698