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

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: used a temp int64 and added a check 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.
Henrik Grunell 2013/11/12 12:46:37 Comment doesn't seem to make sense. Is this a todo
no longer working on chromium 2013/11/12 13:31:56 Done.
+void EnableEchoCancellation(AudioProcessing* audio_processing) {
Henrik Grunell 2013/11/12 12:46:37 Should we have disable calls? Are all components d
no longer working on chromium 2013/11/12 13:31:56 No, all the components are disabled by default.
+#if defined(IOS) || defined(ANDROID)
Henrik Grunell 2013/11/12 12:46:37 Note: In libjingle, for iOS built-in EC and AGC is
no longer working on chromium 2013/11/12 13:31:56 OK, I was not taking this code seriously since chr
+ // Mobile devices are using AECM.
+ if (audio_processing->echo_control_mobile()->Enable(true))
Henrik Grunell 2013/11/12 12:46:37 Does ordinary EC need to be disabled before enabli
no longer working on chromium 2013/11/12 13:31:56 We never enable the ordinary EC for mobile.
+ NOTREACHED();
Henrik Grunell 2013/11/12 12:46:37 Can't enabling fail for this and all below calls?
no longer working on chromium 2013/11/12 13:31:56 After the offline discussion, we agreed that a NOT
+
+ if (audio_processing->echo_control_mobile()->set_routing_mode(
+ webrtc::EchoControlMobile::kSpeakerphone))
+ NOTREACHED();
Henrik Grunell 2013/11/12 12:46:37 Do we need to set CN for mobile EC to false or is
no longer working on chromium 2013/11/12 13:31:56 I think the defaults are all false
+#else
+ if (audio_processing->echo_cancellation()->Enable(true))
Henrik Grunell 2013/11/12 12:46:37 Does mobile EC need to be disabled before enabling
no longer working on chromium 2013/11/12 13:31:56 We never enable Mobile EC for desktops.
+ NOTREACHED();
+ if (audio_processing->echo_cancellation()->set_suppression_level(
+ webrtc::EchoCancellation::kHighSuppression))
Henrik Grunell 2013/11/12 12:46:37 For mobile, the level should be set to moderate. S
no longer working on chromium 2013/11/12 13:31:56 Addressed this offline, no need to change anything
+ 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) {
Henrik Grunell 2013/11/12 12:46:37 Isn't this on by default? Since there's no disable
no longer working on chromium 2013/11/12 13:31:56 I think all the processing components are set to f
+ 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.
Henrik Grunell 2013/11/12 12:46:37 Did you check with ajm@ about the locations?
no longer working on chromium 2013/11/12 13:31:56 Not yet, but will do it. But this should not block
+ 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