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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 device_info_.device.matched_output.sample_rate, | 158 device_info_.device.matched_output.sample_rate, |
159 device_info_.device.matched_output.frames_per_buffer, | 159 device_info_.device.matched_output.frames_per_buffer, |
160 device_info_.device.input.effects)); | 160 device_info_.device.input.effects)); |
161 | 161 |
162 if (render_view_id_ == -1) { | 162 if (render_view_id_ == -1) { |
163 // Return true here to allow injecting a new source via | 163 // Return true here to allow injecting a new source via |
164 // SetCapturerSourceForTesting() at a later state. | 164 // SetCapturerSourceForTesting() at a later state. |
165 return true; | 165 return true; |
166 } | 166 } |
167 | 167 |
| 168 MediaAudioConstraints audio_constraints(constraints_, |
| 169 device_info_.device.input.effects); |
| 170 if (!audio_constraints.IsValid()) |
| 171 return false; |
| 172 |
168 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 173 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
169 device_info_.device.input.channel_layout); | 174 device_info_.device.input.channel_layout); |
170 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 175 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
171 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 176 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
172 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); | 177 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
173 | 178 |
174 // Verify that the reported input channel configuration is supported. | 179 // Verify that the reported input channel configuration is supported. |
175 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 180 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
176 channel_layout != media::CHANNEL_LAYOUT_STEREO && | 181 channel_layout != media::CHANNEL_LAYOUT_STEREO && |
177 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { | 182 channel_layout != media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 222 |
218 WebRtcAudioCapturer::WebRtcAudioCapturer( | 223 WebRtcAudioCapturer::WebRtcAudioCapturer( |
219 int render_view_id, | 224 int render_view_id, |
220 const StreamDeviceInfo& device_info, | 225 const StreamDeviceInfo& device_info, |
221 const blink::WebMediaConstraints& constraints, | 226 const blink::WebMediaConstraints& constraints, |
222 WebRtcAudioDeviceImpl* audio_device, | 227 WebRtcAudioDeviceImpl* audio_device, |
223 MediaStreamAudioSource* audio_source) | 228 MediaStreamAudioSource* audio_source) |
224 : constraints_(constraints), | 229 : constraints_(constraints), |
225 audio_processor_( | 230 audio_processor_( |
226 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 231 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
227 constraints, device_info.device.input.effects, | 232 constraints, device_info.device.input.effects, audio_device)), |
228 device_info.device.type, audio_device)), | |
229 running_(false), | 233 running_(false), |
230 render_view_id_(render_view_id), | 234 render_view_id_(render_view_id), |
231 device_info_(device_info), | 235 device_info_(device_info), |
232 volume_(0), | 236 volume_(0), |
233 peer_connection_mode_(false), | 237 peer_connection_mode_(false), |
234 key_pressed_(false), | 238 key_pressed_(false), |
235 need_audio_processing_(false), | 239 need_audio_processing_(false), |
236 audio_device_(audio_device), | 240 audio_device_(audio_device), |
237 audio_source_(audio_source), | 241 audio_source_(audio_source), |
238 audio_power_monitor_( | 242 audio_power_monitor_( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 329 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
326 channel_layout, 0, sample_rate, | 330 channel_layout, 0, sample_rate, |
327 16, buffer_size, | 331 16, buffer_size, |
328 device_info_.device.input.effects); | 332 device_info_.device.input.effects); |
329 | 333 |
330 { | 334 { |
331 base::AutoLock auto_lock(lock_); | 335 base::AutoLock auto_lock(lock_); |
332 // Notify the |audio_processor_| of the new format. | 336 // Notify the |audio_processor_| of the new format. |
333 audio_processor_->OnCaptureFormatChanged(params); | 337 audio_processor_->OnCaptureFormatChanged(params); |
334 | 338 |
335 need_audio_processing_ = NeedsAudioProcessing( | 339 MediaAudioConstraints audio_constraints(constraints_, |
336 constraints_, device_info_.device.input.effects); | 340 device_info_.device.input.effects); |
| 341 need_audio_processing_ = audio_constraints.NeedsAudioProcessing(); |
337 // Notify all tracks about the new format. | 342 // Notify all tracks about the new format. |
338 tracks_.TagAll(); | 343 tracks_.TagAll(); |
339 } | 344 } |
340 | 345 |
341 if (source.get()) | 346 if (source.get()) |
342 source->Initialize(params, this, session_id()); | 347 source->Initialize(params, this, session_id()); |
343 | 348 |
344 Start(); | 349 Start(); |
345 } | 350 } |
346 | 351 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 DCHECK(aec_dump_file.IsValid()); | 620 DCHECK(aec_dump_file.IsValid()); |
616 audio_processor_->StartAecDump(aec_dump_file.Pass()); | 621 audio_processor_->StartAecDump(aec_dump_file.Pass()); |
617 } | 622 } |
618 | 623 |
619 void WebRtcAudioCapturer::StopAecDump() { | 624 void WebRtcAudioCapturer::StopAecDump() { |
620 DCHECK(thread_checker_.CalledOnValidThread()); | 625 DCHECK(thread_checker_.CalledOnValidThread()); |
621 audio_processor_->StopAecDump(); | 626 audio_processor_->StopAecDump(); |
622 } | 627 } |
623 | 628 |
624 } // namespace content | 629 } // namespace content |
OLD | NEW |