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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return true; | 165 return true; |
166 } | 166 } |
167 | 167 |
168 MediaAudioConstraints audio_constraints(constraints_, | 168 MediaAudioConstraints audio_constraints(constraints_, |
169 device_info_.device.input.effects); | 169 device_info_.device.input.effects); |
170 if (!audio_constraints.IsValid()) | 170 if (!audio_constraints.IsValid()) |
171 return false; | 171 return false; |
172 | 172 |
173 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 173 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
174 device_info_.device.input.channel_layout); | 174 device_info_.device.input.channel_layout); |
| 175 |
| 176 // If the KEYBOARD_MIC effect is set, change the layout to the corresponding |
| 177 // layout that includes the keyboard mic. |
| 178 if (device_info_.device.input.effects & |
| 179 media::AudioParameters::KEYBOARD_MIC) { |
| 180 if (channel_layout == media::CHANNEL_LAYOUT_STEREO) { |
| 181 channel_layout = media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC; |
| 182 DVLOG(1) << "Changed stereo layout to stereo + keyboard mic layout due " |
| 183 << "to KEYBOARD_MIC effect."; |
| 184 } else { |
| 185 DVLOG(1) << "KEYBOARD_MIC effect ignored, not compatible with layout " |
| 186 << channel_layout; |
| 187 } |
| 188 } |
| 189 |
175 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 190 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
176 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 191 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
177 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); | 192 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
178 | 193 |
179 // Verify that the reported input channel configuration is supported. | 194 // Verify that the reported input channel configuration is supported. |
180 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 195 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
181 channel_layout != media::CHANNEL_LAYOUT_STEREO && | 196 channel_layout != media::CHANNEL_LAYOUT_STEREO && |
182 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { | 197 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { |
183 DLOG(ERROR) << channel_layout | 198 DLOG(ERROR) << channel_layout |
184 << " is not a supported input channel configuration."; | 199 << " is not a supported input channel configuration."; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 624 |
610 void WebRtcAudioCapturer::SetCapturerSourceForTesting( | 625 void WebRtcAudioCapturer::SetCapturerSourceForTesting( |
611 const scoped_refptr<media::AudioCapturerSource>& source, | 626 const scoped_refptr<media::AudioCapturerSource>& source, |
612 media::AudioParameters params) { | 627 media::AudioParameters params) { |
613 // Create a new audio stream as source which uses the new source. | 628 // Create a new audio stream as source which uses the new source. |
614 SetCapturerSource(source, params.channel_layout(), | 629 SetCapturerSource(source, params.channel_layout(), |
615 static_cast<float>(params.sample_rate())); | 630 static_cast<float>(params.sample_rate())); |
616 } | 631 } |
617 | 632 |
618 } // namespace content | 633 } // namespace content |
OLD | NEW |