Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 device_info_.device.matched_output.sample_rate, | 156 device_info_.device.matched_output.sample_rate, |
| 157 device_info_.device.matched_output.frames_per_buffer, | 157 device_info_.device.matched_output.frames_per_buffer, |
| 158 device_info_.device.input.effects)); | 158 device_info_.device.input.effects)); |
| 159 | 159 |
| 160 if (render_view_id_ == -1) { | 160 if (render_view_id_ == -1) { |
| 161 // Return true here to allow injecting a new source via | 161 // Return true here to allow injecting a new source via |
| 162 // SetCapturerSourceForTesting() at a later state. | 162 // SetCapturerSourceForTesting() at a later state. |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 MediaAudioConstraints audio_constraints(constraints_, | |
| 167 device_info_.device.input.effects); | |
| 168 if (!audio_constraints.IsValid()) { | |
|
no longer working on chromium
2014/04/11 16:47:05
Per, after thinking a bit more, I am not sure if w
perkj_chrome
2014/04/14 12:15:19
If they are mandatory, we should fail. But if that
| |
| 169 DLOG(ERROR) << "Constraints contain invalid mandatory keys"; | |
| 170 return false; | |
| 171 } | |
| 172 | |
| 166 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( | 173 media::ChannelLayout channel_layout = static_cast<media::ChannelLayout>( |
| 167 device_info_.device.input.channel_layout); | 174 device_info_.device.input.channel_layout); |
| 168 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; | 175 DVLOG(1) << "Audio input hardware channel layout: " << channel_layout; |
| 169 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", | 176 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", |
| 170 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); | 177 channel_layout, media::CHANNEL_LAYOUT_MAX + 1); |
| 171 | 178 |
| 172 // Verify that the reported input channel configuration is supported. | 179 // Verify that the reported input channel configuration is supported. |
| 173 if (channel_layout != media::CHANNEL_LAYOUT_MONO && | 180 if (channel_layout != media::CHANNEL_LAYOUT_MONO && |
| 174 channel_layout != media::CHANNEL_LAYOUT_STEREO) { | 181 channel_layout != media::CHANNEL_LAYOUT_STEREO) { |
| 175 DLOG(ERROR) << channel_layout | 182 DLOG(ERROR) << channel_layout |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 } | 220 } |
| 214 | 221 |
| 215 WebRtcAudioCapturer::WebRtcAudioCapturer( | 222 WebRtcAudioCapturer::WebRtcAudioCapturer( |
| 216 int render_view_id, | 223 int render_view_id, |
| 217 const StreamDeviceInfo& device_info, | 224 const StreamDeviceInfo& device_info, |
| 218 const blink::WebMediaConstraints& constraints, | 225 const blink::WebMediaConstraints& constraints, |
| 219 WebRtcAudioDeviceImpl* audio_device) | 226 WebRtcAudioDeviceImpl* audio_device) |
| 220 : constraints_(constraints), | 227 : constraints_(constraints), |
| 221 audio_processor_( | 228 audio_processor_( |
| 222 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 229 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| 223 constraints, device_info.device.input.effects, | 230 constraints, device_info.device.input.effects, audio_device)), |
| 224 device_info.device.type, audio_device)), | |
| 225 running_(false), | 231 running_(false), |
| 226 render_view_id_(render_view_id), | 232 render_view_id_(render_view_id), |
| 227 device_info_(device_info), | 233 device_info_(device_info), |
| 228 volume_(0), | 234 volume_(0), |
| 229 peer_connection_mode_(false), | 235 peer_connection_mode_(false), |
| 230 key_pressed_(false), | 236 key_pressed_(false), |
| 231 need_audio_processing_(false), | 237 need_audio_processing_(false), |
| 232 audio_device_(audio_device), | 238 audio_device_(audio_device), |
| 233 audio_power_monitor_( | 239 audio_power_monitor_( |
| 234 device_info_.device.input.sample_rate, | 240 device_info_.device.input.sample_rate, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 319 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 314 channel_layout, 0, sample_rate, | 320 channel_layout, 0, sample_rate, |
| 315 16, buffer_size, | 321 16, buffer_size, |
| 316 device_info_.device.input.effects); | 322 device_info_.device.input.effects); |
| 317 | 323 |
| 318 { | 324 { |
| 319 base::AutoLock auto_lock(lock_); | 325 base::AutoLock auto_lock(lock_); |
| 320 // Notify the |audio_processor_| of the new format. | 326 // Notify the |audio_processor_| of the new format. |
| 321 audio_processor_->OnCaptureFormatChanged(params); | 327 audio_processor_->OnCaptureFormatChanged(params); |
| 322 | 328 |
| 323 need_audio_processing_ = NeedsAudioProcessing( | 329 MediaAudioConstraints audio_constraints(constraints_, |
| 324 constraints_, device_info_.device.input.effects); | 330 device_info_.device.input.effects); |
| 331 need_audio_processing_ = audio_constraints.NeedsAudioProcessing(); | |
| 325 // Notify all tracks about the new format. | 332 // Notify all tracks about the new format. |
| 326 tracks_.TagAll(); | 333 tracks_.TagAll(); |
| 327 } | 334 } |
| 328 | 335 |
| 329 if (source.get()) | 336 if (source.get()) |
| 330 source->Initialize(params, this, session_id()); | 337 source->Initialize(params, this, session_id()); |
| 331 | 338 |
| 332 if (restart_source) | 339 if (restart_source) |
| 333 Start(); | 340 Start(); |
| 334 } | 341 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); | 612 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); |
| 606 audio_processor_->StartAecDump(aec_dump_file); | 613 audio_processor_->StartAecDump(aec_dump_file); |
| 607 } | 614 } |
| 608 | 615 |
| 609 void WebRtcAudioCapturer::StopAecDump() { | 616 void WebRtcAudioCapturer::StopAecDump() { |
| 610 DCHECK(thread_checker_.CalledOnValidThread()); | 617 DCHECK(thread_checker_.CalledOnValidThread()); |
| 611 audio_processor_->StopAecDump(); | 618 audio_processor_->StopAecDump(); |
| 612 } | 619 } |
| 613 | 620 |
| 614 } // namespace content | 621 } // namespace content |
| OLD | NEW |