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

Side by Side Diff: trunk/src/content/renderer/media/media_stream_audio_processor_options.cc

Issue 148213002: Revert 246905 "Revert 246894 "Wire up AGC to the MediaStreamAudi..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 months 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_audio_processor_options.h" 5 #include "content/renderer/media/media_stream_audio_processor_options.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 21 matching lines...) Expand all
32 webrtc::MediaConstraintsInterface::kValueTrue }, 32 webrtc::MediaConstraintsInterface::kValueTrue },
33 #endif 33 #endif
34 { webrtc::MediaConstraintsInterface::kAutoGainControl, 34 { webrtc::MediaConstraintsInterface::kAutoGainControl,
35 webrtc::MediaConstraintsInterface::kValueTrue }, 35 webrtc::MediaConstraintsInterface::kValueTrue },
36 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, 36 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl,
37 webrtc::MediaConstraintsInterface::kValueTrue }, 37 webrtc::MediaConstraintsInterface::kValueTrue },
38 { webrtc::MediaConstraintsInterface::kNoiseSuppression, 38 { webrtc::MediaConstraintsInterface::kNoiseSuppression,
39 webrtc::MediaConstraintsInterface::kValueTrue }, 39 webrtc::MediaConstraintsInterface::kValueTrue },
40 { webrtc::MediaConstraintsInterface::kHighpassFilter, 40 { webrtc::MediaConstraintsInterface::kHighpassFilter,
41 webrtc::MediaConstraintsInterface::kValueTrue }, 41 webrtc::MediaConstraintsInterface::kValueTrue },
42 // TODO(xians): Verify if it is OK to set typing detection to kValueFalse as
43 // default.
44 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, 42 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection,
45 webrtc::MediaConstraintsInterface::kValueFalse }, 43 webrtc::MediaConstraintsInterface::kValueTrue },
46 }; 44 };
47 45
48 } // namespace 46 } // namespace
49 47
50 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { 48 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) {
51 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { 49 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) {
52 bool already_set_value; 50 bool already_set_value;
53 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, 51 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key,
54 &already_set_value, NULL)) { 52 &already_set_value, NULL)) {
55 constraints->AddMandatory(kDefaultAudioConstraints[i].key, 53 constraints->AddMandatory(kDefaultAudioConstraints[i].key,
(...skipping 27 matching lines...) Expand all
83 return false; 81 return false;
84 } 82 }
85 83
86 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, 84 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints,
87 const std::string& key) { 85 const std::string& key) {
88 bool value = false; 86 bool value = false;
89 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; 87 return webrtc::FindConstraint(constraints, key, &value, NULL) && value;
90 } 88 }
91 89
92 void EnableEchoCancellation(AudioProcessing* audio_processing) { 90 void EnableEchoCancellation(AudioProcessing* audio_processing) {
93 #if defined(OS_IOS) 91 #if defined(OS_ANDROID)
94 // On iOS, VPIO provides built-in EC and AGC.
95 return;
96 #elif defined(OS_ANDROID)
97 // Mobile devices are using AECM. 92 // Mobile devices are using AECM.
98 int err = audio_processing->echo_control_mobile()->Enable(true); 93 int err = audio_processing->echo_control_mobile()->set_routing_mode(
99 err |= audio_processing->echo_control_mobile()->set_routing_mode(
100 webrtc::EchoControlMobile::kSpeakerphone); 94 webrtc::EchoControlMobile::kSpeakerphone);
95 err |= audio_processing->echo_control_mobile()->Enable(true);
101 CHECK_EQ(err, 0); 96 CHECK_EQ(err, 0);
102 #else 97 #else
103 int err = audio_processing->echo_cancellation()->Enable(true); 98 int err = audio_processing->echo_cancellation()->set_suppression_level(
104 err |= audio_processing->echo_cancellation()->set_suppression_level(
105 webrtc::EchoCancellation::kHighSuppression); 99 webrtc::EchoCancellation::kHighSuppression);
106 100
107 // Enable the metrics for AEC. 101 // Enable the metrics for AEC.
108 err |= audio_processing->echo_cancellation()->enable_metrics(true); 102 err |= audio_processing->echo_cancellation()->enable_metrics(true);
109 err |= audio_processing->echo_cancellation()->enable_delay_logging(true); 103 err |= audio_processing->echo_cancellation()->enable_delay_logging(true);
104 err |= audio_processing->echo_cancellation()->Enable(true);
110 CHECK_EQ(err, 0); 105 CHECK_EQ(err, 0);
111 #endif 106 #endif
112 } 107 }
113 108
114 void EnableNoiseSuppression(AudioProcessing* audio_processing) { 109 void EnableNoiseSuppression(AudioProcessing* audio_processing) {
115 int err = audio_processing->noise_suppression()->set_level( 110 int err = audio_processing->noise_suppression()->set_level(
116 webrtc::NoiseSuppression::kHigh); 111 webrtc::NoiseSuppression::kHigh);
117 err |= audio_processing->noise_suppression()->Enable(true); 112 err |= audio_processing->noise_suppression()->Enable(true);
118 CHECK_EQ(err, 0); 113 CHECK_EQ(err, 0);
119 } 114 }
120 115
121 void EnableHighPassFilter(AudioProcessing* audio_processing) { 116 void EnableHighPassFilter(AudioProcessing* audio_processing) {
122 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0); 117 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0);
123 } 118 }
124 119
125 // TODO(xians): stereo swapping
126 void EnableTypingDetection(AudioProcessing* audio_processing) { 120 void EnableTypingDetection(AudioProcessing* audio_processing) {
127 int err = audio_processing->voice_detection()->Enable(true); 121 int err = audio_processing->voice_detection()->Enable(true);
128 err |= audio_processing->voice_detection()->set_likelihood( 122 err |= audio_processing->voice_detection()->set_likelihood(
129 webrtc::VoiceDetection::kVeryLowLikelihood); 123 webrtc::VoiceDetection::kVeryLowLikelihood);
130 CHECK_EQ(err, 0); 124 CHECK_EQ(err, 0);
131 } 125 }
132 126
133 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { 127 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) {
134 webrtc::Config config; 128 webrtc::Config config;
135 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); 129 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
(...skipping 20 matching lines...) Expand all
156 #endif 150 #endif
157 if (audio_processing->StartDebugRecording(file_name.c_str())) 151 if (audio_processing->StartDebugRecording(file_name.c_str()))
158 DLOG(ERROR) << "Fail to start AEC debug recording"; 152 DLOG(ERROR) << "Fail to start AEC debug recording";
159 } 153 }
160 154
161 void StopAecDump(AudioProcessing* audio_processing) { 155 void StopAecDump(AudioProcessing* audio_processing) {
162 if (audio_processing->StopDebugRecording()) 156 if (audio_processing->StopDebugRecording())
163 DLOG(ERROR) << "Fail to stop AEC debug recording"; 157 DLOG(ERROR) << "Fail to stop AEC debug recording";
164 } 158 }
165 159
160 void EnableAutomaticGainControl(AudioProcessing* audio_processing) {
161 #if defined(OS_ANDROID) || defined(OS_IOS)
162 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital;
163 #else
164 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog;
165 #endif
166 int err = audio_processing->gain_control()->set_mode(mode);
167 err |= audio_processing->gain_control()->Enable(true);
168 CHECK_EQ(err, 0);
169 }
170
166 } // namespace content 171 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698