OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webrtc_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 return true; | 149 return true; |
150 } | 150 } |
151 | 151 |
152 MediaAudioConstraints audio_constraints(constraints_, | 152 MediaAudioConstraints audio_constraints(constraints_, |
153 device_info_.device.input.effects); | 153 device_info_.device.input.effects); |
154 if (!audio_constraints.IsValid()) | 154 if (!audio_constraints.IsValid()) |
155 return false; | 155 return false; |
156 | 156 |
157 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 157 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
158 device_info_.device.input.channel_layout); | 158 device_info_.device.input.channel_layout); |
159 | |
160 // If KEYBOARD_MIC effect is set, change the layout to the corresponding | |
161 // layout that includes the keyboard mic. | |
162 if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() && | |
163 audio_constraints.GetProperty( | |
164 MediaAudioConstraints::kGoogExperimentalNoiseSuppression) && | |
165 (device_info_.device.input.effects & | |
166 media::AudioParameters::KEYBOARD_MIC)) { | |
tommi (sloooow) - chröme
2014/09/23 17:27:00
nit: this seems like the fastest condition to be c
Henrik Grunell
2014/09/25 10:08:36
Done.
| |
167 if (channel_layout == media::CHANNEL_LAYOUT_STEREO) { | |
168 channel_layout = media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC; | |
169 DVLOG(1) << "Changed stereo layout to stereo + keyboard mic layout due " | |
170 << "to KEYBOARD_MIC effect."; | |
171 } else { | |
172 DVLOG(1) << "KEYBOARD_MIC effect ignored, not compatible with layout " | |
173 << channel_layout; | |
174 } | |
175 } | |
176 | |
159 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 177 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
160 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 178 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
161 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); | 179 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
162 | 180 |
163 // Verify that the reported input channel configuration is supported. | 181 // Verify that the reported input channel configuration is supported. |
164 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 182 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
165 channel_layout != media::CHANNEL_LAYOUT_STEREO && | 183 channel_layout != media::CHANNEL_LAYOUT_STEREO && |
166 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { | 184 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { |
167 DLOG(ERROR) << channel_layout | 185 DLOG(ERROR) << channel_layout |
168 << " is not a supported input channel configuration."; | 186 << " is not a supported input channel configuration."; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 | 600 |
583 void WebRtcAudioCapturer::SetCapturerSourceForTesting( | 601 void WebRtcAudioCapturer::SetCapturerSourceForTesting( |
584 const scoped_refptr<media::AudioCapturerSource>& source, | 602 const scoped_refptr<media::AudioCapturerSource>& source, |
585 media::AudioParameters params) { | 603 media::AudioParameters params) { |
586 // Create a new audio stream as source which uses the new source. | 604 // Create a new audio stream as source which uses the new source. |
587 SetCapturerSource(source, params.channel_layout(), | 605 SetCapturerSource(source, params.channel_layout(), |
588 static_cast<float>(params.sample_rate())); | 606 static_cast<float>(params.sample_rate())); |
589 } | 607 } |
590 | 608 |
591 } // namespace content | 609 } // namespace content |
OLD | NEW |