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 device_info_.device.matched_output.sample_rate, | 149 device_info_.device.matched_output.sample_rate, |
150 device_info_.device.matched_output.frames_per_buffer, | 150 device_info_.device.matched_output.frames_per_buffer, |
151 device_info_.device.input.effects)); | 151 device_info_.device.input.effects)); |
152 | 152 |
153 if (render_view_id_ == -1) { | 153 if (render_view_id_ == -1) { |
154 // Return true here to allow injecting a new source via | 154 // Return true here to allow injecting a new source via |
155 // SetCapturerSourceForTesting() at a later state. | 155 // SetCapturerSourceForTesting() at a later state. |
156 return true; | 156 return true; |
157 } | 157 } |
158 | 158 |
| 159 if (!IsValid(constraints_)) { |
| 160 DLOG(ERROR) << "Constraints contain invalid mandatory keys"; |
| 161 return false; |
| 162 } |
| 163 |
159 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 164 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
160 device_info_.device.input.channel_layout); | 165 device_info_.device.input.channel_layout); |
161 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 166 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
162 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 167 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
163 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); | 168 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
164 | 169 |
165 // Verify that the reported input channel configuration is supported. | 170 // Verify that the reported input channel configuration is supported. |
166 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 171 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
167 channel_layout != media::CHANNEL_LAYOUT_STEREO) { | 172 channel_layout != media::CHANNEL_LAYOUT_STEREO) { |
168 DLOG(ERROR) << channel_layout | 173 DLOG(ERROR) << channel_layout |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 211 } |
207 | 212 |
208 WebRtcAudioCapturer::WebRtcAudioCapturer( | 213 WebRtcAudioCapturer::WebRtcAudioCapturer( |
209 int render_view_id, | 214 int render_view_id, |
210 const StreamDeviceInfo& device_info, | 215 const StreamDeviceInfo& device_info, |
211 const blink::WebMediaConstraints& constraints, | 216 const blink::WebMediaConstraints& constraints, |
212 WebRtcAudioDeviceImpl* audio_device) | 217 WebRtcAudioDeviceImpl* audio_device) |
213 : constraints_(constraints), | 218 : constraints_(constraints), |
214 audio_processor_( | 219 audio_processor_( |
215 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 220 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
216 constraints, device_info.device.input.effects, | 221 constraints, device_info.device.input.effects, audio_device)), |
217 device_info.device.type, audio_device)), | |
218 running_(false), | 222 running_(false), |
219 render_view_id_(render_view_id), | 223 render_view_id_(render_view_id), |
220 device_info_(device_info), | 224 device_info_(device_info), |
221 volume_(0), | 225 volume_(0), |
222 peer_connection_mode_(false), | 226 peer_connection_mode_(false), |
223 key_pressed_(false), | 227 key_pressed_(false), |
224 need_audio_processing_(false), | 228 need_audio_processing_(false), |
225 audio_device_(audio_device) { | 229 audio_device_(audio_device) { |
226 DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()"; | 230 DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()"; |
227 } | 231 } |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); | 585 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); |
582 audio_processor_->StartAecDump(aec_dump_file); | 586 audio_processor_->StartAecDump(aec_dump_file); |
583 } | 587 } |
584 | 588 |
585 void WebRtcAudioCapturer::StopAecDump() { | 589 void WebRtcAudioCapturer::StopAecDump() { |
586 DCHECK(thread_checker_.CalledOnValidThread()); | 590 DCHECK(thread_checker_.CalledOnValidThread()); |
587 audio_processor_->StopAecDump(); | 591 audio_processor_->StopAecDump(); |
588 } | 592 } |
589 | 593 |
590 } // namespace content | 594 } // namespace content |
OLD | NEW |