OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
9 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
10 #include "content/renderer/media/webrtc/processed_local_audio_source.h" | 11 #include "content/renderer/media/media_stream_audio_processor.h" |
| 12 #include "content/renderer/media/webrtc_audio_capturer.h" |
11 #include "content/renderer/media/webrtc_audio_renderer.h" | 13 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 14 #include "content/renderer/render_thread_impl.h" |
12 #include "media/audio/sample_rates.h" | 15 #include "media/audio/sample_rates.h" |
13 #include "media/base/audio_bus.h" | |
14 #include "media/base/audio_parameters.h" | 16 #include "media/base/audio_parameters.h" |
15 | 17 |
16 using media::AudioParameters; | 18 using media::AudioParameters; |
17 using media::ChannelLayout; | 19 using media::ChannelLayout; |
18 | 20 |
19 namespace content { | 21 namespace content { |
20 | 22 |
21 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() | 23 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() |
22 : ref_count_(0), | 24 : ref_count_(0), |
23 audio_transport_callback_(NULL), | 25 audio_transport_callback_(NULL), |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 DCHECK(worker_thread_checker_.CalledOnValidThread()); | 353 DCHECK(worker_thread_checker_.CalledOnValidThread()); |
352 base::AutoLock auto_lock(lock_); | 354 base::AutoLock auto_lock(lock_); |
353 *delay_ms = static_cast<uint16_t>(output_delay_ms_); | 355 *delay_ms = static_cast<uint16_t>(output_delay_ms_); |
354 return 0; | 356 return 0; |
355 } | 357 } |
356 | 358 |
357 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const { | 359 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const { |
358 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 360 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
359 | 361 |
360 // There is no way to report a correct delay value to WebRTC since there | 362 // There is no way to report a correct delay value to WebRTC since there |
361 // might be multiple ProcessedLocalAudioSource instances. | 363 // might be multiple WebRtcAudioCapturer instances. |
362 NOTREACHED(); | 364 NOTREACHED(); |
363 return -1; | 365 return -1; |
364 } | 366 } |
365 | 367 |
366 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate( | 368 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate( |
367 uint32_t* sample_rate) const { | 369 uint32_t* sample_rate) const { |
368 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 370 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
369 // We use the default capturer as the recording sample rate. | 371 // We use the default capturer as the recording sample rate. |
370 base::AutoLock auto_lock(lock_); | 372 base::AutoLock auto_lock(lock_); |
371 if (capturers_.empty()) | 373 if (capturers_.empty()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 audio_renderer_thread_checker_.DetachFromThread(); | 414 audio_renderer_thread_checker_.DetachFromThread(); |
413 | 415 |
414 // We acquire |lock_| again and assert our precondition, since we are | 416 // We acquire |lock_| again and assert our precondition, since we are |
415 // accessing the internal state again. | 417 // accessing the internal state again. |
416 base::AutoLock auto_lock(lock_); | 418 base::AutoLock auto_lock(lock_); |
417 DCHECK(!renderer_.get()); | 419 DCHECK(!renderer_.get()); |
418 renderer_ = renderer; | 420 renderer_ = renderer; |
419 return true; | 421 return true; |
420 } | 422 } |
421 | 423 |
422 void WebRtcAudioDeviceImpl::AddAudioCapturer( | 424 void WebRtcAudioDeviceImpl::AddAudioCapturer(WebRtcAudioCapturer* capturer) { |
423 ProcessedLocalAudioSource* capturer) { | |
424 DCHECK(main_thread_checker_.CalledOnValidThread()); | 425 DCHECK(main_thread_checker_.CalledOnValidThread()); |
425 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; | 426 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; |
426 DCHECK(capturer); | 427 DCHECK(capturer); |
427 DCHECK(!capturer->device_info().device.id.empty()); | 428 DCHECK(!capturer->device_info().device.id.empty()); |
428 | 429 |
429 base::AutoLock auto_lock(lock_); | 430 base::AutoLock auto_lock(lock_); |
430 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == | 431 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == |
431 capturers_.end()); | 432 capturers_.end()); |
432 capturers_.push_back(capturer); | 433 capturers_.push_back(capturer); |
433 } | 434 } |
434 | 435 |
435 void WebRtcAudioDeviceImpl::RemoveAudioCapturer( | 436 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(WebRtcAudioCapturer* capturer) { |
436 ProcessedLocalAudioSource* capturer) { | |
437 DCHECK(main_thread_checker_.CalledOnValidThread()); | 437 DCHECK(main_thread_checker_.CalledOnValidThread()); |
438 DVLOG(1) << "WebRtcAudioDeviceImpl::RemoveAudioCapturer()"; | 438 DVLOG(1) << "WebRtcAudioDeviceImpl::RemoveAudioCapturer()"; |
439 DCHECK(capturer); | 439 DCHECK(capturer); |
440 base::AutoLock auto_lock(lock_); | 440 base::AutoLock auto_lock(lock_); |
441 capturers_.remove(capturer); | 441 capturers_.remove(capturer); |
442 } | 442 } |
443 | 443 |
444 void WebRtcAudioDeviceImpl::AddPlayoutSink( | 444 void WebRtcAudioDeviceImpl::AddPlayoutSink( |
445 WebRtcPlayoutDataSource::Sink* sink) { | 445 WebRtcPlayoutDataSource::Sink* sink) { |
446 DCHECK(main_thread_checker_.CalledOnValidThread()); | 446 DCHECK(main_thread_checker_.CalledOnValidThread()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 *session_id = device_info.session_id; | 481 *session_id = device_info.session_id; |
482 *output_sample_rate = device_info.device.matched_output.sample_rate; | 482 *output_sample_rate = device_info.device.matched_output.sample_rate; |
483 *output_frames_per_buffer = | 483 *output_frames_per_buffer = |
484 device_info.device.matched_output.frames_per_buffer; | 484 device_info.device.matched_output.frames_per_buffer; |
485 | 485 |
486 return true; | 486 return true; |
487 } | 487 } |
488 | 488 |
489 } // namespace content | 489 } // namespace content |
OLD | NEW |