Chromium Code Reviews| Index: content/renderer/media/webrtc_audio_device_impl.cc |
| diff --git a/content/renderer/media/webrtc_audio_device_impl.cc b/content/renderer/media/webrtc_audio_device_impl.cc |
| index 7519de90a85bac94b98d79171c201c7bdbaea235..239b4cfc435520712d078f2d071e0a0fe611460d 100644 |
| --- a/content/renderer/media/webrtc_audio_device_impl.cc |
| +++ b/content/renderer/media/webrtc_audio_device_impl.cc |
| @@ -436,24 +436,47 @@ void WebRtcAudioDeviceImpl::AddAudioCapturer( |
| DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK(capturer.get()); |
| - |
| - // We only support one microphone today, which means the list can contain |
| - // only one capturer with a valid device id. |
| - DCHECK(capturer->device_id().empty() || !GetDefaultCapturer()); |
| + DCHECK(!capturer->device_id().empty()); |
| base::AutoLock auto_lock(lock_); |
| + DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == |
| + capturers_.end()); |
| capturers_.push_back(capturer); |
| } |
| +void WebRtcAudioDeviceImpl::RemoveAudioCapturer( |
| + const scoped_refptr<WebRtcAudioCapturer>& capturer) { |
| + DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK(capturer.get()); |
| + base::AutoLock auto_lock(lock_); |
| + capturers_.remove(capturer); |
| +} |
| + |
| scoped_refptr<WebRtcAudioCapturer> |
| WebRtcAudioDeviceImpl::GetDefaultCapturer() const { |
| base::AutoLock auto_lock(lock_); |
| for (CapturerList::const_iterator iter = capturers_.begin(); |
| iter != capturers_.end(); ++iter) { |
| - if (!(*iter)->device_id().empty()) |
| - return *iter; |
| + // TODO(xians): It is a bit debatable to determine which one is the default |
| + // 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.
|
| + return *iter; |
| } |
| return NULL; |
| } |
| +bool WebRtcAudioDeviceImpl::GetAuthorizedDeviceInfoForAudioRenderer( |
| + int* session_id, |
| + int* output_sample_rate, |
| + int* output_frames_per_buffer) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + // If there is no capturer or there are more than one open capture devices, |
| + // return false. |
| + if (capturers_.empty() || capturers_.size() > 1) |
| + return false; |
| + |
| + return GetDefaultCapturer()->GetPairedOutputParameters( |
| + session_id, output_sample_rate, output_frames_per_buffer); |
| +} |
| + |
| } // namespace content |