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

Unified Diff: content/renderer/media/webrtc_audio_processor_options.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 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_options.cc
diff --git a/content/renderer/media/webrtc_audio_processor_options.cc b/content/renderer/media/webrtc_audio_processor_options.cc
new file mode 100644
index 0000000000000000000000000000000000000000..93766297c6b83d263071fd3b0ab1bb95930b5ce2
--- /dev/null
+++ b/content/renderer/media/webrtc_audio_processor_options.cc
@@ -0,0 +1,85 @@
+// 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_options.h"
+
+#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) {
+ if (audio_processing->noise_suppression()->set_level(
+ webrtc::NoiseSuppression::kHigh))
+ NOTREACHED();
+
+ if (audio_processing->noise_suppression()->Enable(true))
+ NOTREACHED();
+}
+
+void EnableHighPassFilter(AudioProcessing* audio_processing) {
+ if (audio_processing->high_pass_filter()->Enable(true))
+ NOTREACHED();
+}
+
+// TODO(xians): stereo swapping
+void EnableTypingDetection(AudioProcessing* 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) {
+ webrtc::Config config;
+ config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
+ audio_processing->SetExtraOptions(config);
+}
+
+void StartAecDump(AudioProcessing* audio_processin) {
Jói 2013/11/08 13:36:40 audio_processing -> audio_processing
no longer working on chromium 2013/11/08 15:39:30 Done.
+ static const char kAecDumpFilename[] = "/tmp/audio.aecdump";
Jói 2013/11/08 13:36:40 This won't work on Windows. Can you build a path u
no longer working on chromium 2013/11/08 15:39:30 Talked to Henrik G about this, and decided to keep
Jói 2013/11/08 16:44:22 Looks good.
+ if (audio_processin->StartDebugRecording(kAecDumpFilename))
+ DLOG(ERROR) << "Fail to start AEC debug recording";
+}
+
+void StopAecDump(AudioProcessing* audio_processin) {
Jói 2013/11/08 13:36:40 audio_processin -> audio_processing
no longer working on chromium 2013/11/08 15:39:30 Done.
+ if (audio_processin->StopDebugRecording())
+ DLOG(ERROR) << "Fail to stop AEC debug recording";
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698