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

Unified Diff: content/renderer/media/webrtc_audio_processor_util.cc

Issue 54383003: Added an "enable-audio-processor" flag and WebRtcAudioProcessor class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed the rest of Dale's comments Created 7 years, 1 month 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: content/renderer/media/webrtc_audio_processor_util.cc
diff --git a/content/renderer/media/webrtc_audio_processor_util.cc b/content/renderer/media/webrtc_audio_processor_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c3f3276ce723c26e8fc75b2d876654949e1845af
--- /dev/null
+++ b/content/renderer/media/webrtc_audio_processor_util.cc
@@ -0,0 +1,89 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/webrtc_audio_processor_util.h"
DaleCurtis 2013/11/07 20:44:08 Instead of _util, maybe _options ?
no longer working on chromium 2013/11/08 13:01:15 Done.
+
+#include "base/logging.h"
+#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
+#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
+
+namespace content {
+
+bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints,
+ const std::string& key) {
+ bool value = false;
+ return webrtc::FindConstraint(constraints, key, &value, NULL) && value;
+}
+
+// Extract all these methods to a helper class.
+void EnableEchoCancellation(AudioProcessing* audio_processing) {
+#if defined(IOS) || defined(ANDROID)
+ // Mobile devices are using AECM.
+ if (audio_processing->echo_control_mobile()->Enable(true))
+ NOTREACHED();
+
+ if (audio_processing->echo_control_mobile()->set_routing_mode(
+ webrtc::EchoControlMobile::kSpeakerphone))
+ NOTREACHED();
+#else
+ if (audio_processing->echo_cancellation()->Enable(true))
+ NOTREACHED();
+ if (audio_processing->echo_cancellation()->set_suppression_level(
+ webrtc::EchoCancellation::kHighSuppression))
+ NOTREACHED();
+
+ // Enable the metrics for AEC.
+ if (audio_processing->echo_cancellation()->enable_metrics(true))
+ NOTREACHED();
+ if (audio_processing->echo_cancellation()->enable_delay_logging(true))
+ NOTREACHED();
+#endif
+}
+
+void EnableNoiseSuppression(AudioProcessing* audio_processing) {
+ DCHECK(audio_processing);
DaleCurtis 2013/11/07 20:44:08 Remove dcheck here and below.
no longer working on chromium 2013/11/08 13:01:15 Done.
+ if (audio_processing->noise_suppression()->set_level(
+ webrtc::NoiseSuppression::kHigh))
+ NOTREACHED();
+
+ if (audio_processing->noise_suppression()->Enable(true))
+ NOTREACHED();
+}
+
+void EnableHighPassFilter(AudioProcessing* audio_processing) {
+ DCHECK(audio_processing);
+ if (audio_processing->high_pass_filter()->Enable(true))
+ NOTREACHED();
+}
+
+// TODO(xians): stereo swapping
+void EnableTypingDetection(AudioProcessing* audio_processing) {
+ DCHECK(audio_processing);
+ if (audio_processing->voice_detection()->Enable(true))
+ NOTREACHED();
+
+ if (audio_processing->voice_detection()->set_likelihood(
+ webrtc::VoiceDetection::kVeryLowLikelihood))
+ NOTREACHED();
+}
+
+void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) {
+ DCHECK(audio_processing);
+ webrtc::Config config;
+ config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
+ audio_processing->SetExtraOptions(config);
+}
+
+void StartAecDump(AudioProcessing* audio_processin) {
+ static const char kAecDumpFilename[] = "/tmp/audio.aecdump";
+ if (audio_processin->StartDebugRecording(kAecDumpFilename))
+ DLOG(ERROR) << "Fail to start AEC debug recording";
+}
+
+void StopAecDump(AudioProcessing* audio_processin) {
+ if (audio_processin->StopDebugRecording())
+ DLOG(ERROR) << "Fail to stop AEC debug recording";
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698