Chromium Code Reviews| Index: content/browser/renderer_host/media/audio_input_device_manager.cc |
| diff --git a/content/browser/renderer_host/media/audio_input_device_manager.cc b/content/browser/renderer_host/media/audio_input_device_manager.cc |
| index 42728f7f42079b2f1341ed34b3457f1f000909c1..09a54aeecc07103cd72b24e73e49c65cd39bd044 100644 |
| --- a/content/browser/renderer_host/media/audio_input_device_manager.cc |
| +++ b/content/browser/renderer_host/media/audio_input_device_manager.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "content/browser/renderer_host/media/audio_input_device_manager_event_handler.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/common/media_stream_request.h" |
| #include "media/audio/audio_input_ipc.h" |
| #include "media/audio/audio_manager_base.h" |
| @@ -15,16 +16,23 @@ using content::BrowserThread; |
| namespace media_stream { |
| +namespace { |
| +const char kStubTabAudioDeviceId[] = "<<tab audio id here>>"; |
| +} |
| + |
| const int AudioInputDeviceManager::kFakeOpenSessionId = 1; |
| // Starting id for the first capture session. |
| const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; |
| AudioInputDeviceManager::AudioInputDeviceManager( |
| - media::AudioManager* audio_manager) |
| - : listener_(NULL), |
| + media::AudioManager* audio_manager, |
| + media_stream::MediaStreamType device_type) |
| + : device_type_(device_type), |
| + listener_(NULL), |
| next_capture_session_id_(kFirstSessionId), |
| audio_manager_(audio_manager) { |
| + DCHECK(content::IsAudioMediaStreamDeviceType(device_type_)); |
| } |
| AudioInputDeviceManager::~AudioInputDeviceManager() { |
| @@ -84,18 +92,30 @@ void AudioInputDeviceManager::Close(int session_id) { |
| void AudioInputDeviceManager::EnumerateOnDeviceThread() { |
| DCHECK(IsOnDeviceThread()); |
| - // AudioManager is guaranteed to outlive MediaStreamManager in |
| - // BrowserMainloop. |
| - media::AudioDeviceNames device_names; |
| - audio_manager_->GetAudioInputDeviceNames(&device_names); |
| StreamDeviceInfoArray* devices = new StreamDeviceInfoArray; |
| - for (media::AudioDeviceNames::iterator it = device_names.begin(); |
| - it != device_names.end(); |
| - ++it) { |
| - devices->push_back(StreamDeviceInfo( |
| - content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, it->device_name, |
| - it->unique_id, false)); |
| + switch (device_type_) { |
| + case content::MEDIA_STREAM_DEVICE_TYPE_USER_AUDIO_CAPTURE: { |
| + // AudioManager is guaranteed to outlive MediaStreamManager in |
| + // BrowserMainloop. |
| + media::AudioDeviceNames device_names; |
| + audio_manager_->GetAudioInputDeviceNames(&device_names); |
| + for (media::AudioDeviceNames::iterator it = device_names.begin(); |
| + it != device_names.end(); ++it) { |
| + devices->push_back(StreamDeviceInfo( |
| + device_type_, it->device_name, it->unique_id, false)); |
| + } |
| + break; |
| + } |
| + case content::MEDIA_STREAM_DEVICE_TYPE_TAB_AUDIO_CAPTURE: |
| + // TODO(miu): Replace this stub with the actual implementation. |
| + devices->push_back(StreamDeviceInfo( |
| + device_type_, "Stub Tab Audio Capture", kStubTabAudioDeviceId, |
| + false)); |
| + break; |
| + default: |
| + NOTIMPLEMENTED(); |
| + break; |
| } |
| // Returns the device list through the listener by posting a task on |
| @@ -116,6 +136,7 @@ void AudioInputDeviceManager::OpenOnDeviceThread( |
| // Adds the session_id and device to the list. |
| media::AudioDeviceName target_device(device.name, device.device_id); |
| devices_[session_id] = target_device; |
| + // TODO(miu): Complete the implementation (i.e., actually open a device). |
|
no longer working on chromium
2012/08/31 13:38:23
I am not sure if we should actually open a device
miu
2012/09/01 01:32:00
Thanks for the explanation. I've removed this TOD
|
| // Returns the |session_id| through the listener by posting a task on |
| // IO thread since MediaStreamManager handles the callback asynchronously. |
| @@ -131,6 +152,7 @@ void AudioInputDeviceManager::CloseOnDeviceThread(int session_id) { |
| if (devices_.find(session_id) != devices_.end()) |
| devices_.erase(session_id); |
| + // TODO(miu): Complete the implementation (i.e., actually close a device). |
|
no longer working on chromium
2012/08/31 13:38:23
Stop() has already close the device, not sure if w
miu
2012/09/01 01:32:00
Removed this comment too.
|
| // Posts a callback through the listener on IO thread since |
| // MediaStreamManager handles the callback asynchronously. |
| @@ -185,24 +207,20 @@ void AudioInputDeviceManager::DevicesEnumeratedOnIOThread( |
| // Ensures that |devices| gets deleted on exit. |
| scoped_ptr<StreamDeviceInfoArray> devices_array(devices); |
| if (listener_) { |
| - listener_->DevicesEnumerated( |
| - content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
| - *devices_array); |
| + listener_->DevicesEnumerated(device_type_, *devices_array); |
| } |
| } |
| void AudioInputDeviceManager::OpenedOnIOThread(int session_id) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| if (listener_) |
| - listener_->Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
| - session_id); |
| + listener_->Opened(device_type_, session_id); |
| } |
| void AudioInputDeviceManager::ClosedOnIOThread(int session_id) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| if (listener_) |
| - listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
| - session_id); |
| + listener_->Closed(device_type_, session_id); |
| } |
| bool AudioInputDeviceManager::IsOnDeviceThread() const { |