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_util.h" | |
DaleCurtis
2013/11/07 20:44:08
Instead of _util, maybe _options ?
no longer working on chromium
2013/11/08 13:01:15
Done.
| |
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 DCHECK(audio_processing); | |
DaleCurtis
2013/11/07 20:44:08
Remove dcheck here and below.
no longer working on chromium
2013/11/08 13:01:15
Done.
| |
46 if (audio_processing->noise_suppression()->set_level( | |
47 webrtc::NoiseSuppression::kHigh)) | |
48 NOTREACHED(); | |
49 | |
50 if (audio_processing->noise_suppression()->Enable(true)) | |
51 NOTREACHED(); | |
52 } | |
53 | |
54 void EnableHighPassFilter(AudioProcessing* audio_processing) { | |
55 DCHECK(audio_processing); | |
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 DCHECK(audio_processing); | |
63 if (audio_processing->voice_detection()->Enable(true)) | |
64 NOTREACHED(); | |
65 | |
66 if (audio_processing->voice_detection()->set_likelihood( | |
67 webrtc::VoiceDetection::kVeryLowLikelihood)) | |
68 NOTREACHED(); | |
69 } | |
70 | |
71 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { | |
72 DCHECK(audio_processing); | |
73 webrtc::Config config; | |
74 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | |
75 audio_processing->SetExtraOptions(config); | |
76 } | |
77 | |
78 void StartAecDump(AudioProcessing* audio_processin) { | |
79 static const char kAecDumpFilename[] = "/tmp/audio.aecdump"; | |
80 if (audio_processin->StartDebugRecording(kAecDumpFilename)) | |
81 DLOG(ERROR) << "Fail to start AEC debug recording"; | |
82 } | |
83 | |
84 void StopAecDump(AudioProcessing* audio_processin) { | |
85 if (audio_processin->StopDebugRecording()) | |
86 DLOG(ERROR) << "Fail to stop AEC debug recording"; | |
87 } | |
88 | |
89 } // namespace content | |
OLD | NEW |