Chromium Code Reviews| 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..07355249db7f2f3ea86335d554b0a21f8813c107 |
| --- /dev/null |
| +++ b/content/renderer/media/webrtc_audio_processor_options.cc |
| @@ -0,0 +1,105 @@ |
| +// 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 "base/strings/utf_string_conversions.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; |
| +} |
| + |
| +void EnableEchoCancellation(AudioProcessing* audio_processing) { |
| +#if defined(OS_IOS) |
| + // On iOS, VPIO provides built-in EC and AGC. |
| + return; |
| +#elif defined(OS_ANDROID) |
| + // Mobile devices are using AECM. |
| + if (audio_processing->echo_control_mobile()->Enable(true)) |
| + NOTREACHED(); |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
same questions about NOTREACHED in this file and t
no longer working on chromium
2013/11/22 13:27:53
Done.
|
| + |
| + 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)) |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
{}
no longer working on chromium
2013/11/22 13:27:53
removed.
|
| + NOTREACHED(); |
| + |
| + if (audio_processing->noise_suppression()->Enable(true)) |
| + NOTREACHED(); |
| +} |
| + |
| +void EnableHighPassFilter(AudioProcessing* audio_processing) { |
| + if (audio_processing->high_pass_filter()->Enable(true)) |
| + NOTREACHED(); |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
strange indent (run lint?)
no longer working on chromium
2013/11/22 13:27:53
Done.
|
| +} |
| + |
| +// 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)) |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
{}
no longer working on chromium
2013/11/22 13:27:53
removed.
|
| + 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. |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
check with grunell? (and perhaps even assign the t
Henrik Grunell
2013/11/22 09:03:36
Shijing and I talked about this offline. We agreed
no longer working on chromium
2013/11/22 13:27:53
I don't have time for this, and the purpose of thi
no longer working on chromium
2013/11/22 13:27:53
Done.
Henrik Grunell
2013/11/25 10:52:02
That's fine, I can deal with this.
|
| + 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 defined(OS_WIN) |
| + const std::string file_name = WideToUTF8(file.value()); |
|
tommi (sloooow) - chröme
2013/11/21 19:52:03
strange indent
no longer working on chromium
2013/11/22 13:27:53
Done.
|
| +#else |
| + const std::string file_name = file.value(); |
| +#endif |
| + if (audio_processing->StartDebugRecording(file_name.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 |