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

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

Issue 146923002: Revert 246894 "Wire up AGC to the MediaStreamAudioProcessor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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.
42 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, 44 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection,
43 webrtc::MediaConstraintsInterface::kValueTrue }, 45 webrtc::MediaConstraintsInterface::kValueFalse },
44 }; 46 };
45 47
46 } // namespace 48 } // namespace
47 49
48 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { 50 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) {
49 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { 51 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) {
50 bool already_set_value; 52 bool already_set_value;
51 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, 53 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key,
52 &already_set_value, NULL)) { 54 &already_set_value, NULL)) {
53 constraints->AddMandatory(kDefaultAudioConstraints[i].key, 55 constraints->AddMandatory(kDefaultAudioConstraints[i].key,
(...skipping 27 matching lines...) Expand all
81 return false; 83 return false;
82 } 84 }
83 85
84 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, 86 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints,
85 const std::string& key) { 87 const std::string& key) {
86 bool value = false; 88 bool value = false;
87 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; 89 return webrtc::FindConstraint(constraints, key, &value, NULL) && value;
88 } 90 }
89 91
90 void EnableEchoCancellation(AudioProcessing* audio_processing) { 92 void EnableEchoCancellation(AudioProcessing* audio_processing) {
91 #if defined(OS_ANDROID) 93 #if defined(OS_IOS)
94 // On iOS, VPIO provides built-in EC and AGC.
95 return;
96 #elif defined(OS_ANDROID)
92 // Mobile devices are using AECM. 97 // Mobile devices are using AECM.
93 int err = audio_processing->echo_control_mobile()->set_routing_mode( 98 int err = audio_processing->echo_control_mobile()->Enable(true);
99 err |= audio_processing->echo_control_mobile()->set_routing_mode(
94 webrtc::EchoControlMobile::kSpeakerphone); 100 webrtc::EchoControlMobile::kSpeakerphone);
95 err |= audio_processing->echo_control_mobile()->Enable(true);
96 CHECK_EQ(err, 0); 101 CHECK_EQ(err, 0);
97 #else 102 #else
98 int err = audio_processing->echo_cancellation()->set_suppression_level( 103 int err = audio_processing->echo_cancellation()->Enable(true);
104 err |= audio_processing->echo_cancellation()->set_suppression_level(
99 webrtc::EchoCancellation::kHighSuppression); 105 webrtc::EchoCancellation::kHighSuppression);
100 106
101 // Enable the metrics for AEC. 107 // Enable the metrics for AEC.
102 err |= audio_processing->echo_cancellation()->enable_metrics(true); 108 err |= audio_processing->echo_cancellation()->enable_metrics(true);
103 err |= audio_processing->echo_cancellation()->enable_delay_logging(true); 109 err |= audio_processing->echo_cancellation()->enable_delay_logging(true);
104 err |= audio_processing->echo_cancellation()->Enable(true);
105 CHECK_EQ(err, 0); 110 CHECK_EQ(err, 0);
106 #endif 111 #endif
107 } 112 }
108 113
109 void EnableNoiseSuppression(AudioProcessing* audio_processing) { 114 void EnableNoiseSuppression(AudioProcessing* audio_processing) {
110 int err = audio_processing->noise_suppression()->set_level( 115 int err = audio_processing->noise_suppression()->set_level(
111 webrtc::NoiseSuppression::kHigh); 116 webrtc::NoiseSuppression::kHigh);
112 err |= audio_processing->noise_suppression()->Enable(true); 117 err |= audio_processing->noise_suppression()->Enable(true);
113 CHECK_EQ(err, 0); 118 CHECK_EQ(err, 0);
114 } 119 }
115 120
116 void EnableHighPassFilter(AudioProcessing* audio_processing) { 121 void EnableHighPassFilter(AudioProcessing* audio_processing) {
117 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0); 122 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0);
118 } 123 }
119 124
125 // TODO(xians): stereo swapping
120 void EnableTypingDetection(AudioProcessing* audio_processing) { 126 void EnableTypingDetection(AudioProcessing* audio_processing) {
121 int err = audio_processing->voice_detection()->Enable(true); 127 int err = audio_processing->voice_detection()->Enable(true);
122 err |= audio_processing->voice_detection()->set_likelihood( 128 err |= audio_processing->voice_detection()->set_likelihood(
123 webrtc::VoiceDetection::kVeryLowLikelihood); 129 webrtc::VoiceDetection::kVeryLowLikelihood);
124 CHECK_EQ(err, 0); 130 CHECK_EQ(err, 0);
125 } 131 }
126 132
127 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { 133 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) {
128 webrtc::Config config; 134 webrtc::Config config;
129 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); 135 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
(...skipping 20 matching lines...) Expand all
150 #endif 156 #endif
151 if (audio_processing->StartDebugRecording(file_name.c_str())) 157 if (audio_processing->StartDebugRecording(file_name.c_str()))
152 DLOG(ERROR) << "Fail to start AEC debug recording"; 158 DLOG(ERROR) << "Fail to start AEC debug recording";
153 } 159 }
154 160
155 void StopAecDump(AudioProcessing* audio_processing) { 161 void StopAecDump(AudioProcessing* audio_processing) {
156 if (audio_processing->StopDebugRecording()) 162 if (audio_processing->StopDebugRecording())
157 DLOG(ERROR) << "Fail to stop AEC debug recording"; 163 DLOG(ERROR) << "Fail to stop AEC debug recording";
158 } 164 }
159 165
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
171 } // namespace content 166 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698