Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WebRtcLocalAudioTrackAdapter-->WebRtcAudioSink, MediaStreamAudioDeliverer; and PS3 comments address… Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
10 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
11 #include "content/renderer/media/media_stream_audio_processor.h" 10 #include "content/renderer/media/webrtc/processed_local_audio_source.h"
12 #include "content/renderer/media/webrtc_audio_capturer.h"
13 #include "content/renderer/media/webrtc_audio_renderer.h" 11 #include "content/renderer/media/webrtc_audio_renderer.h"
14 #include "content/renderer/render_thread_impl.h"
15 #include "media/audio/audio_parameters.h" 12 #include "media/audio/audio_parameters.h"
16 #include "media/audio/sample_rates.h" 13 #include "media/audio/sample_rates.h"
14 #include "media/base/audio_bus.h"
17 15
18 using media::AudioParameters; 16 using media::AudioParameters;
19 using media::ChannelLayout; 17 using media::ChannelLayout;
20 18
21 namespace content { 19 namespace content {
22 20
23 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() 21 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()
24 : ref_count_(0), 22 : ref_count_(0),
25 audio_transport_callback_(NULL), 23 audio_transport_callback_(NULL),
26 output_delay_ms_(0), 24 output_delay_ms_(0),
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 DCHECK(worker_thread_checker_.CalledOnValidThread()); 352 DCHECK(worker_thread_checker_.CalledOnValidThread());
355 base::AutoLock auto_lock(lock_); 353 base::AutoLock auto_lock(lock_);
356 *delay_ms = static_cast<uint16_t>(output_delay_ms_); 354 *delay_ms = static_cast<uint16_t>(output_delay_ms_);
357 return 0; 355 return 0;
358 } 356 }
359 357
360 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const { 358 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const {
361 DCHECK(signaling_thread_checker_.CalledOnValidThread()); 359 DCHECK(signaling_thread_checker_.CalledOnValidThread());
362 360
363 // There is no way to report a correct delay value to WebRTC since there 361 // There is no way to report a correct delay value to WebRTC since there
364 // might be multiple WebRtcAudioCapturer instances. 362 // might be multiple ProcessedLocalAudioSource instances.
365 NOTREACHED(); 363 NOTREACHED();
366 return -1; 364 return -1;
367 } 365 }
368 366
369 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate( 367 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate(
370 uint32_t* sample_rate) const { 368 uint32_t* sample_rate) const {
371 DCHECK(signaling_thread_checker_.CalledOnValidThread()); 369 DCHECK(signaling_thread_checker_.CalledOnValidThread());
372 // We use the default capturer as the recording sample rate. 370 // We use the default capturer as the recording sample rate.
373 base::AutoLock auto_lock(lock_); 371 base::AutoLock auto_lock(lock_);
374 if (capturers_.empty()) 372 if (capturers_.empty())
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 audio_renderer_thread_checker_.DetachFromThread(); 413 audio_renderer_thread_checker_.DetachFromThread();
416 414
417 // We acquire |lock_| again and assert our precondition, since we are 415 // We acquire |lock_| again and assert our precondition, since we are
418 // accessing the internal state again. 416 // accessing the internal state again.
419 base::AutoLock auto_lock(lock_); 417 base::AutoLock auto_lock(lock_);
420 DCHECK(!renderer_.get()); 418 DCHECK(!renderer_.get());
421 renderer_ = renderer; 419 renderer_ = renderer;
422 return true; 420 return true;
423 } 421 }
424 422
425 void WebRtcAudioDeviceImpl::AddAudioCapturer(WebRtcAudioCapturer* capturer) { 423 void WebRtcAudioDeviceImpl::AddAudioCapturer(
424 ProcessedLocalAudioSource* capturer) {
426 DCHECK(main_thread_checker_.CalledOnValidThread()); 425 DCHECK(main_thread_checker_.CalledOnValidThread());
427 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; 426 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
428 DCHECK(capturer); 427 DCHECK(capturer);
429 DCHECK(!capturer->device_info().device.id.empty()); 428 DCHECK(!capturer->device_info().device.id.empty());
430 429
431 base::AutoLock auto_lock(lock_); 430 base::AutoLock auto_lock(lock_);
432 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == 431 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
433 capturers_.end()); 432 capturers_.end());
434 capturers_.push_back(capturer); 433 capturers_.push_back(capturer);
435 } 434 }
436 435
437 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(WebRtcAudioCapturer* capturer) { 436 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
437 ProcessedLocalAudioSource* capturer) {
438 DCHECK(main_thread_checker_.CalledOnValidThread()); 438 DCHECK(main_thread_checker_.CalledOnValidThread());
439 DVLOG(1) << "WebRtcAudioDeviceImpl::RemoveAudioCapturer()"; 439 DVLOG(1) << "WebRtcAudioDeviceImpl::RemoveAudioCapturer()";
440 DCHECK(capturer); 440 DCHECK(capturer);
441 base::AutoLock auto_lock(lock_); 441 base::AutoLock auto_lock(lock_);
442 capturers_.remove(capturer); 442 capturers_.remove(capturer);
443 } 443 }
444 444
445 void WebRtcAudioDeviceImpl::AddPlayoutSink( 445 void WebRtcAudioDeviceImpl::AddPlayoutSink(
446 WebRtcPlayoutDataSource::Sink* sink) { 446 WebRtcPlayoutDataSource::Sink* sink) {
447 DCHECK(main_thread_checker_.CalledOnValidThread()); 447 DCHECK(main_thread_checker_.CalledOnValidThread());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 *session_id = device_info.session_id; 482 *session_id = device_info.session_id;
483 *output_sample_rate = device_info.device.matched_output.sample_rate; 483 *output_sample_rate = device_info.device.matched_output.sample_rate;
484 *output_frames_per_buffer = 484 *output_frames_per_buffer =
485 device_info.device.matched_output.frames_per_buffer; 485 device_info.device.matched_output.frames_per_buffer;
486 486
487 return true; 487 return true;
488 } 488 }
489 489
490 } // namespace content 490 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698