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

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

Issue 133903004: Cleaned up the WebRtcAudioCapturer a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 6 years, 11 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 | Annotate | Revision Log
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" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 renderer_ = renderer; 430 renderer_ = renderer;
431 return true; 431 return true;
432 } 432 }
433 433
434 void WebRtcAudioDeviceImpl::AddAudioCapturer( 434 void WebRtcAudioDeviceImpl::AddAudioCapturer(
435 const scoped_refptr<WebRtcAudioCapturer>& capturer) { 435 const scoped_refptr<WebRtcAudioCapturer>& capturer) {
436 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; 436 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
437 DCHECK(thread_checker_.CalledOnValidThread()); 437 DCHECK(thread_checker_.CalledOnValidThread());
438 DCHECK(capturer.get()); 438 DCHECK(capturer.get());
439 DCHECK(!capturer->device_id().empty());
440 base::AutoLock auto_lock(lock_);
441 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
442 capturers_.end());
443 capturers_.push_back(capturer);
444 }
439 445
440 // We only support one microphone today, which means the list can contain 446 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
441 // only one capturer with a valid device id. 447 const scoped_refptr<WebRtcAudioCapturer>& capturer) {
442 DCHECK(capturer->device_id().empty() || !GetDefaultCapturer()); 448 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
449 DCHECK(thread_checker_.CalledOnValidThread());
450 DCHECK(capturer.get());
443 base::AutoLock auto_lock(lock_); 451 base::AutoLock auto_lock(lock_);
444 capturers_.push_back(capturer); 452 capturers_.remove(capturer);
445 } 453 }
446 454
447 scoped_refptr<WebRtcAudioCapturer> 455 scoped_refptr<WebRtcAudioCapturer>
448 WebRtcAudioDeviceImpl::GetDefaultCapturer() const { 456 WebRtcAudioDeviceImpl::GetDefaultCapturer() const {
449 base::AutoLock auto_lock(lock_); 457 base::AutoLock auto_lock(lock_);
450 for (CapturerList::const_iterator iter = capturers_.begin(); 458 for (CapturerList::const_iterator iter = capturers_.begin();
451 iter != capturers_.end(); ++iter) { 459 iter != capturers_.end(); ++iter) {
452 if (!(*iter)->device_id().empty()) 460 // TODO(xians): It is a bit debatable to determine which one is the default
453 return *iter; 461 // capturer, the first one or the last one.
perkj_chrome 2014/01/14 08:42:40 And how many can you currently have? You create on
no longer working on chromium 2014/01/14 11:10:21 OK, then lets switch over to the last one.
462 return *iter;
454 } 463 }
455 464
456 return NULL; 465 return NULL;
457 } 466 }
458 467
468 bool WebRtcAudioDeviceImpl::GetAuthorizedDeviceInfoForAudioRenderer(
469 int* session_id,
470 int* output_sample_rate,
471 int* output_frames_per_buffer) {
472 DCHECK(thread_checker_.CalledOnValidThread());
473 // If there is no capturer or there are more than one open capture devices,
474 // return false.
475 if (capturers_.empty() || capturers_.size() > 1)
476 return false;
477
478 return GetDefaultCapturer()->GetPairedOutputParameters(
479 session_id, output_sample_rate, output_frames_per_buffer);
480 }
481
459 } // namespace content 482 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698