| 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 DLOG(ERROR) << channel_layout | 182 DLOG(ERROR) << channel_layout |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 221 |
| 217 WebRtcAudioCapturer::WebRtcAudioCapturer( | 222 WebRtcAudioCapturer::WebRtcAudioCapturer( |
| 218 int render_view_id, | 223 int render_view_id, |
| 219 const StreamDeviceInfo& device_info, | 224 const StreamDeviceInfo& device_info, |
| 220 const blink::WebMediaConstraints& constraints, | 225 const blink::WebMediaConstraints& constraints, |
| 221 WebRtcAudioDeviceImpl* audio_device, | 226 WebRtcAudioDeviceImpl* audio_device, |
| 222 MediaStreamAudioSource* audio_source) | 227 MediaStreamAudioSource* audio_source) |
| 223 : constraints_(constraints), | 228 : constraints_(constraints), |
| 224 audio_processor_( | 229 audio_processor_( |
| 225 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 230 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| 226 constraints, device_info.device.input.effects, | 231 constraints, device_info.device.input.effects, audio_device)), |
| 227 device_info.device.type, audio_device)), | |
| 228 running_(false), | 232 running_(false), |
| 229 render_view_id_(render_view_id), | 233 render_view_id_(render_view_id), |
| 230 device_info_(device_info), | 234 device_info_(device_info), |
| 231 volume_(0), | 235 volume_(0), |
| 232 peer_connection_mode_(false), | 236 peer_connection_mode_(false), |
| 233 key_pressed_(false), | 237 key_pressed_(false), |
| 234 need_audio_processing_(false), | 238 need_audio_processing_(false), |
| 235 audio_device_(audio_device), | 239 audio_device_(audio_device), |
| 236 audio_source_(audio_source), | 240 audio_source_(audio_source), |
| 237 audio_power_monitor_( | 241 audio_power_monitor_( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 328 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 325 channel_layout, 0, sample_rate, | 329 channel_layout, 0, sample_rate, |
| 326 16, buffer_size, | 330 16, buffer_size, |
| 327 device_info_.device.input.effects); | 331 device_info_.device.input.effects); |
| 328 | 332 |
| 329 { | 333 { |
| 330 base::AutoLock auto_lock(lock_); | 334 base::AutoLock auto_lock(lock_); |
| 331 // Notify the |audio_processor_| of the new format. | 335 // Notify the |audio_processor_| of the new format. |
| 332 audio_processor_->OnCaptureFormatChanged(params); | 336 audio_processor_->OnCaptureFormatChanged(params); |
| 333 | 337 |
| 334 need_audio_processing_ = NeedsAudioProcessing( | 338 MediaAudioConstraints audio_constraints(constraints_, |
| 335 constraints_, device_info_.device.input.effects); | 339 device_info_.device.input.effects); |
| 340 need_audio_processing_ = audio_constraints.NeedsAudioProcessing(); |
| 336 // Notify all tracks about the new format. | 341 // Notify all tracks about the new format. |
| 337 tracks_.TagAll(); | 342 tracks_.TagAll(); |
| 338 } | 343 } |
| 339 | 344 |
| 340 if (source.get()) | 345 if (source.get()) |
| 341 source->Initialize(params, this, session_id()); | 346 source->Initialize(params, this, session_id()); |
| 342 | 347 |
| 343 Start(); | 348 Start(); |
| 344 } | 349 } |
| 345 | 350 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 DCHECK(aec_dump_file.IsValid()); | 619 DCHECK(aec_dump_file.IsValid()); |
| 615 audio_processor_->StartAecDump(aec_dump_file.Pass()); | 620 audio_processor_->StartAecDump(aec_dump_file.Pass()); |
| 616 } | 621 } |
| 617 | 622 |
| 618 void WebRtcAudioCapturer::StopAecDump() { | 623 void WebRtcAudioCapturer::StopAecDump() { |
| 619 DCHECK(thread_checker_.CalledOnValidThread()); | 624 DCHECK(thread_checker_.CalledOnValidThread()); |
| 620 audio_processor_->StopAecDump(); | 625 audio_processor_->StopAecDump(); |
| 621 } | 626 } |
| 622 | 627 |
| 623 } // namespace content | 628 } // namespace content |
| OLD | NEW |