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

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: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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/sample_rates.h" 12 #include "media/audio/sample_rates.h"
13 #include "media/base/audio_bus.h"
16 #include "media/base/audio_parameters.h" 14 #include "media/base/audio_parameters.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),
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 DCHECK(worker_thread_checker_.CalledOnValidThread()); 351 DCHECK(worker_thread_checker_.CalledOnValidThread());
354 base::AutoLock auto_lock(lock_); 352 base::AutoLock auto_lock(lock_);
355 *delay_ms = static_cast<uint16_t>(output_delay_ms_); 353 *delay_ms = static_cast<uint16_t>(output_delay_ms_);
356 return 0; 354 return 0;
357 } 355 }
358 356
359 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const { 357 int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const {
360 DCHECK(signaling_thread_checker_.CalledOnValidThread()); 358 DCHECK(signaling_thread_checker_.CalledOnValidThread());
361 359
362 // There is no way to report a correct delay value to WebRTC since there 360 // There is no way to report a correct delay value to WebRTC since there
363 // might be multiple WebRtcAudioCapturer instances. 361 // might be multiple ProcessedLocalAudioSource instances.
364 NOTREACHED(); 362 NOTREACHED();
365 return -1; 363 return -1;
366 } 364 }
367 365
368 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate( 366 int32_t WebRtcAudioDeviceImpl::RecordingSampleRate(
369 uint32_t* sample_rate) const { 367 uint32_t* sample_rate) const {
370 DCHECK(signaling_thread_checker_.CalledOnValidThread()); 368 DCHECK(signaling_thread_checker_.CalledOnValidThread());
371 // We use the default capturer as the recording sample rate. 369 // We use the default capturer as the recording sample rate.
372 base::AutoLock auto_lock(lock_); 370 base::AutoLock auto_lock(lock_);
373 if (capturers_.empty()) 371 if (capturers_.empty())
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 audio_renderer_thread_checker_.DetachFromThread(); 412 audio_renderer_thread_checker_.DetachFromThread();
415 413
416 // We acquire |lock_| again and assert our precondition, since we are 414 // We acquire |lock_| again and assert our precondition, since we are
417 // accessing the internal state again. 415 // accessing the internal state again.
418 base::AutoLock auto_lock(lock_); 416 base::AutoLock auto_lock(lock_);
419 DCHECK(!renderer_.get()); 417 DCHECK(!renderer_.get());
420 renderer_ = renderer; 418 renderer_ = renderer;
421 return true; 419 return true;
422 } 420 }
423 421
424 void WebRtcAudioDeviceImpl::AddAudioCapturer(WebRtcAudioCapturer* capturer) { 422 void WebRtcAudioDeviceImpl::AddAudioCapturer(
423 ProcessedLocalAudioSource* capturer) {
425 DCHECK(main_thread_checker_.CalledOnValidThread()); 424 DCHECK(main_thread_checker_.CalledOnValidThread());
426 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; 425 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
427 DCHECK(capturer); 426 DCHECK(capturer);
428 DCHECK(!capturer->device_info().device.id.empty()); 427 DCHECK(!capturer->device_info().device.id.empty());
429 428
430 base::AutoLock auto_lock(lock_); 429 base::AutoLock auto_lock(lock_);
431 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == 430 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
432 capturers_.end()); 431 capturers_.end());
433 capturers_.push_back(capturer); 432 capturers_.push_back(capturer);
434 } 433 }
435 434
436 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(WebRtcAudioCapturer* capturer) { 435 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
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
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
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.h ('k') | content/renderer/media/webrtc_audio_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698