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

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: changed to base::TimeDelta and addressed Joi'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_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..e7abe04febf022293840f5e74db7f7f4fa734bf1
--- /dev/null
+++ b/content/renderer/media/webrtc_audio_processor_options.cc
@@ -0,0 +1,96 @@
+// 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/files/file_path.h"
+#include "base/logging.h"
+#include "base/path_service.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_processing) {
+ // TODO(xians): Figure out a more suitable directory for the audio dump data.
+ base::FilePath path;
+#if defined(CHROMEOS)
+ PathService::Get(base::DIR_TEMP, &path);
+#elif defined(ANDROID)
+ path = base::FilePath(FILE_PATH_LITERAL("sdcard"));
+#else
+ PathService::Get(base::DIR_EXE, &path);
+#endif
+ base::FilePath file = path.Append(FILE_PATH_LITERAL("audio.aecdump"));
+ if (audio_processing->StartDebugRecording(file.value().c_str()))
+ DLOG(ERROR) << "Fail to start AEC debug recording";
+}
+
+void StopAecDump(AudioProcessing* audio_processing) {
+ if (audio_processing->StopDebugRecording())
+ DLOG(ERROR) << "Fail to stop AEC debug recording";
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698