OLD | NEW |
---|---|
(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 "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" | |
11 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " | |
12 | |
13 namespace content { | |
14 | |
15 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, | |
16 const std::string& key) { | |
17 bool value = false; | |
18 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; | |
19 } | |
20 | |
21 // 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.
| |
22 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.
| |
23 #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
| |
24 // Mobile devices are using AECM. | |
25 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.
| |
26 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
| |
27 | |
28 if (audio_processing->echo_control_mobile()->set_routing_mode( | |
29 webrtc::EchoControlMobile::kSpeakerphone)) | |
30 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
| |
31 #else | |
32 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.
| |
33 NOTREACHED(); | |
34 if (audio_processing->echo_cancellation()->set_suppression_level( | |
35 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
| |
36 NOTREACHED(); | |
37 | |
38 // Enable the metrics for AEC. | |
39 if (audio_processing->echo_cancellation()->enable_metrics(true)) | |
40 NOTREACHED(); | |
41 if (audio_processing->echo_cancellation()->enable_delay_logging(true)) | |
42 NOTREACHED(); | |
43 #endif | |
44 } | |
45 | |
46 void EnableNoiseSuppression(AudioProcessing* audio_processing) { | |
47 if (audio_processing->noise_suppression()->set_level( | |
48 webrtc::NoiseSuppression::kHigh)) | |
49 NOTREACHED(); | |
50 | |
51 if (audio_processing->noise_suppression()->Enable(true)) | |
52 NOTREACHED(); | |
53 } | |
54 | |
55 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
| |
56 if (audio_processing->high_pass_filter()->Enable(true)) | |
57 NOTREACHED(); | |
58 } | |
59 | |
60 // TODO(xians): stereo swapping | |
61 void EnableTypingDetection(AudioProcessing* audio_processing) { | |
62 if (audio_processing->voice_detection()->Enable(true)) | |
63 NOTREACHED(); | |
64 | |
65 if (audio_processing->voice_detection()->set_likelihood( | |
66 webrtc::VoiceDetection::kVeryLowLikelihood)) | |
67 NOTREACHED(); | |
68 } | |
69 | |
70 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { | |
71 webrtc::Config config; | |
72 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | |
73 audio_processing->SetExtraOptions(config); | |
74 } | |
75 | |
76 void StartAecDump(AudioProcessing* audio_processing) { | |
77 // 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
| |
78 base::FilePath path; | |
79 #if defined(CHROMEOS) | |
80 PathService::Get(base::DIR_TEMP, &path); | |
81 #elif defined(ANDROID) | |
82 path = base::FilePath(FILE_PATH_LITERAL("sdcard")); | |
83 #else | |
84 PathService::Get(base::DIR_EXE, &path); | |
85 #endif | |
86 base::FilePath file = path.Append(FILE_PATH_LITERAL("audio.aecdump")); | |
87 if (audio_processing->StartDebugRecording(file.value().c_str())) | |
88 DLOG(ERROR) << "Fail to start AEC debug recording"; | |
89 } | |
90 | |
91 void StopAecDump(AudioProcessing* audio_processing) { | |
92 if (audio_processing->StopDebugRecording()) | |
93 DLOG(ERROR) << "Fail to stop AEC debug recording"; | |
94 } | |
95 | |
96 } // namespace content | |
OLD | NEW |