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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (render_view_id_ == -1) { | 145 if (render_view_id_ == -1) { |
146 // Return true here to allow injecting a new source via | 146 // Return true here to allow injecting a new source via |
147 // SetCapturerSourceForTesting() at a later state. | 147 // SetCapturerSourceForTesting() at a later state. |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 151 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
152 device_info_.device.input.channel_layout); | 152 device_info_.device.input.channel_layout); |
153 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 153 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
154 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 154 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
155 channel_layout, media::CHANNEL_LAYOUT_MAX); | 155 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
156 | 156 |
157 // Verify that the reported input channel configuration is supported. | 157 // Verify that the reported input channel configuration is supported. |
158 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 158 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
159 channel_layout != media::CHANNEL_LAYOUT_STEREO) { | 159 channel_layout != media::CHANNEL_LAYOUT_STEREO) { |
160 DLOG(ERROR) << channel_layout | 160 DLOG(ERROR) << channel_layout |
161 << " is not a supported input channel configuration."; | 161 << " is not a supported input channel configuration."; |
162 return false; | 162 return false; |
163 } | 163 } |
164 | 164 |
165 DVLOG(1) << "Audio input hardware sample rate: " | 165 DVLOG(1) << "Audio input hardware sample rate: " |
166 << device_info_.device.input.sample_rate; | 166 << device_info_.device.input.sample_rate; |
167 media::AudioSampleRate asr = media::AsAudioSampleRate( | 167 media::AudioSampleRate asr; |
168 device_info_.device.input.sample_rate); | 168 if (media::ToAudioSampleRate(device_info_.device.input.sample_rate, &asr)) { |
169 if (asr != media::kUnexpectedAudioSampleRate) { | |
170 UMA_HISTOGRAM_ENUMERATION( | 169 UMA_HISTOGRAM_ENUMERATION( |
171 "WebRTC.AudioInputSampleRate", asr, media::kUnexpectedAudioSampleRate); | 170 "WebRTC.AudioInputSampleRate", asr, media::kAudioSampleRateMax + 1); |
172 } else { | 171 } else { |
173 UMA_HISTOGRAM_COUNTS("WebRTC.AudioInputSampleRateUnexpected", | 172 UMA_HISTOGRAM_COUNTS("WebRTC.AudioInputSampleRateUnexpected", |
174 device_info_.device.input.sample_rate); | 173 device_info_.device.input.sample_rate); |
175 } | 174 } |
176 | 175 |
177 // Verify that the reported input hardware sample rate is supported | 176 // Verify that the reported input hardware sample rate is supported |
178 // on the current platform. | 177 // on the current platform. |
179 if (std::find(&kValidInputRates[0], | 178 if (std::find(&kValidInputRates[0], |
180 &kValidInputRates[0] + arraysize(kValidInputRates), | 179 &kValidInputRates[0] + arraysize(kValidInputRates), |
181 device_info_.device.input.sample_rate) == | 180 device_info_.device.input.sample_rate) == |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 const scoped_refptr<media::AudioCapturerSource>& source, | 580 const scoped_refptr<media::AudioCapturerSource>& source, |
582 media::AudioParameters params) { | 581 media::AudioParameters params) { |
583 // Create a new audio stream as source which uses the new source. | 582 // Create a new audio stream as source which uses the new source. |
584 SetCapturerSource(source, params.channel_layout(), | 583 SetCapturerSource(source, params.channel_layout(), |
585 static_cast<float>(params.sample_rate()), | 584 static_cast<float>(params.sample_rate()), |
586 params.effects(), | 585 params.effects(), |
587 constraints_); | 586 constraints_); |
588 } | 587 } |
589 | 588 |
590 } // namespace content | 589 } // namespace content |
OLD | NEW |