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/logging.h" | |
8 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" | |
9 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " | |
10 | |
11 namespace content { | |
12 | |
13 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, | |
14 const std::string& key) { | |
15 bool value = false; | |
16 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; | |
17 } | |
18 | |
19 // Extract all these methods to a helper class. | |
20 void EnableEchoCancellation(AudioProcessing* audio_processing) { | |
21 #if defined(IOS) || defined(ANDROID) | |
22 // Mobile devices are using AECM. | |
23 if (audio_processing->echo_control_mobile()->Enable(true)) | |
24 NOTREACHED(); | |
25 | |
26 if (audio_processing->echo_control_mobile()->set_routing_mode( | |
27 webrtc::EchoControlMobile::kSpeakerphone)) | |
28 NOTREACHED(); | |
29 #else | |
30 if (audio_processing->echo_cancellation()->Enable(true)) | |
31 NOTREACHED(); | |
32 if (audio_processing->echo_cancellation()->set_suppression_level( | |
33 webrtc::EchoCancellation::kHighSuppression)) | |
34 NOTREACHED(); | |
35 | |
36 // Enable the metrics for AEC. | |
37 if (audio_processing->echo_cancellation()->enable_metrics(true)) | |
38 NOTREACHED(); | |
39 if (audio_processing->echo_cancellation()->enable_delay_logging(true)) | |
40 NOTREACHED(); | |
41 #endif | |
42 } | |
43 | |
44 void EnableNoiseSuppression(AudioProcessing* audio_processing) { | |
45 if (audio_processing->noise_suppression()->set_level( | |
46 webrtc::NoiseSuppression::kHigh)) | |
47 NOTREACHED(); | |
48 | |
49 if (audio_processing->noise_suppression()->Enable(true)) | |
50 NOTREACHED(); | |
51 } | |
52 | |
53 void EnableHighPassFilter(AudioProcessing* audio_processing) { | |
54 if (audio_processing->high_pass_filter()->Enable(true)) | |
55 NOTREACHED(); | |
56 } | |
57 | |
58 // TODO(xians): stereo swapping | |
59 void EnableTypingDetection(AudioProcessing* audio_processing) { | |
60 if (audio_processing->voice_detection()->Enable(true)) | |
61 NOTREACHED(); | |
62 | |
63 if (audio_processing->voice_detection()->set_likelihood( | |
64 webrtc::VoiceDetection::kVeryLowLikelihood)) | |
65 NOTREACHED(); | |
66 } | |
67 | |
68 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { | |
69 webrtc::Config config; | |
70 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | |
71 audio_processing->SetExtraOptions(config); | |
72 } | |
73 | |
74 void StartAecDump(AudioProcessing* audio_processin) { | |
Jói
2013/11/08 13:36:40
audio_processing -> audio_processing
no longer working on chromium
2013/11/08 15:39:30
Done.
| |
75 static const char kAecDumpFilename[] = "/tmp/audio.aecdump"; | |
Jói
2013/11/08 13:36:40
This won't work on Windows. Can you build a path u
no longer working on chromium
2013/11/08 15:39:30
Talked to Henrik G about this, and decided to keep
Jói
2013/11/08 16:44:22
Looks good.
| |
76 if (audio_processin->StartDebugRecording(kAecDumpFilename)) | |
77 DLOG(ERROR) << "Fail to start AEC debug recording"; | |
78 } | |
79 | |
80 void StopAecDump(AudioProcessing* audio_processin) { | |
Jói
2013/11/08 13:36:40
audio_processin -> audio_processing
no longer working on chromium
2013/11/08 15:39:30
Done.
| |
81 if (audio_processin->StopDebugRecording()) | |
82 DLOG(ERROR) << "Fail to stop AEC debug recording"; | |
83 } | |
84 | |
85 } // namespace content | |
OLD | NEW |