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

Side by Side 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: rebased with 77803004, and fixed the order of the methods. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/webrtc_audio_processor_options.h"
6
7 #include "base/files/file_path.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
12 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h "
13
14 namespace content {
15
16 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints,
17 const std::string& key) {
18 bool value = false;
19 return webrtc::FindConstraint(constraints, key, &value, NULL) && value;
20 }
21
22 void EnableEchoCancellation(AudioProcessing* audio_processing) {
23 #if defined(OS_IOS)
24 // On iOS, VPIO provides built-in EC and AGC.
25 return;
26 #elif defined(OS_ANDROID)
27 // Mobile devices are using AECM.
28 if (audio_processing->echo_control_mobile()->Enable(true))
29 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.
30
31 if (audio_processing->echo_control_mobile()->set_routing_mode(
32 webrtc::EchoControlMobile::kSpeakerphone))
33 NOTREACHED();
34 #else
35 if (audio_processing->echo_cancellation()->Enable(true))
36 NOTREACHED();
37 if (audio_processing->echo_cancellation()->set_suppression_level(
38 webrtc::EchoCancellation::kHighSuppression))
39 NOTREACHED();
40
41 // Enable the metrics for AEC.
42 if (audio_processing->echo_cancellation()->enable_metrics(true))
43 NOTREACHED();
44 if (audio_processing->echo_cancellation()->enable_delay_logging(true))
45 NOTREACHED();
46 #endif
47 }
48
49 void EnableNoiseSuppression(AudioProcessing* audio_processing) {
50 if (audio_processing->noise_suppression()->set_level(
51 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.
52 NOTREACHED();
53
54 if (audio_processing->noise_suppression()->Enable(true))
55 NOTREACHED();
56 }
57
58 void EnableHighPassFilter(AudioProcessing* audio_processing) {
59 if (audio_processing->high_pass_filter()->Enable(true))
60 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.
61 }
62
63 // TODO(xians): stereo swapping
64 void EnableTypingDetection(AudioProcessing* audio_processing) {
65 if (audio_processing->voice_detection()->Enable(true))
66 NOTREACHED();
67
68 if (audio_processing->voice_detection()->set_likelihood(
69 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.
70 NOTREACHED();
71 }
72
73 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) {
74 webrtc::Config config;
75 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
76 audio_processing->SetExtraOptions(config);
77 }
78
79 void StartAecDump(AudioProcessing* audio_processing) {
80 // 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.
81 base::FilePath path;
82 #if defined(CHROMEOS)
83 PathService::Get(base::DIR_TEMP, &path);
84 #elif defined(ANDROID)
85 path = base::FilePath(FILE_PATH_LITERAL("sdcard"));
86 #else
87 PathService::Get(base::DIR_EXE, &path);
88 #endif
89 base::FilePath file = path.Append(FILE_PATH_LITERAL("audio.aecdump"));
90
91 #if defined(OS_WIN)
92 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.
93 #else
94 const std::string file_name = file.value();
95 #endif
96 if (audio_processing->StartDebugRecording(file_name.c_str()))
97 DLOG(ERROR) << "Fail to start AEC debug recording";
98 }
99
100 void StopAecDump(AudioProcessing* audio_processing) {
101 if (audio_processing->StopDebugRecording())
102 DLOG(ERROR) << "Fail to stop AEC debug recording";
103 }
104
105 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698