diff options
author | mflodman@chromium.org <mflodman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 06:22:04 +0000 |
---|---|---|
committer | mflodman@chromium.org <mflodman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 06:22:04 +0000 |
commit | ddc8eb2ad91c15b5984a0c1dc14058da5ce31090 (patch) | |
tree | efe2039f0641e3b7cb3baadc3b8bbca731d4d036 /content | |
parent | 8d03f30627426f5258bef297d259f81888762fb9 (diff) | |
download | chromium_src-ddc8eb2ad91c15b5984a0c1dc14058da5ce31090.zip chromium_src-ddc8eb2ad91c15b5984a0c1dc14058da5ce31090.tar.gz chromium_src-ddc8eb2ad91c15b5984a0c1dc14058da5ce31090.tar.bz2 |
Connecting MediaStreamManager and AudioInputRenderHost/AudioInputDeviceManager.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8065011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
5 files changed, 31 insertions, 26 deletions
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index b5d5d5b..2228cd8 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -359,7 +359,8 @@ void BrowserRenderProcessHost::CreateMessageFilters() { content::GetContentClient()->browser()->GetResourceDispatcherHost()); channel_->AddFilter(resource_message_filter); - channel_->AddFilter(new AudioInputRendererHost()); + channel_->AddFilter(new AudioInputRendererHost( + &browser_context()->GetResourceContext())); channel_->AddFilter( new AudioRendererHost(&browser_context()->GetResourceContext())); channel_->AddFilter( diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc index 84532ba..fd50045 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc @@ -11,6 +11,7 @@ #include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/audio_input_sync_writer.h" #include "content/browser/renderer_host/media/media_stream_manager.h" +#include "content/browser/resource_context.h" #include "content/common/media/audio_messages.h" #include "ipc/ipc_logging.h" @@ -22,7 +23,10 @@ AudioInputRendererHost::AudioEntry::AudioEntry() AudioInputRendererHost::AudioEntry::~AudioEntry() {} -AudioInputRendererHost::AudioInputRendererHost() {} +AudioInputRendererHost::AudioInputRendererHost( + const content::ResourceContext* resource_context) + : resource_context_(resource_context) { +} AudioInputRendererHost::~AudioInputRendererHost() { DCHECK(audio_entries_.empty()); @@ -185,12 +189,8 @@ void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { << stream_id << ", session_id = " << session_id << ")"; // Get access to the AudioInputDeviceManager to start the device. - // TODO(mflodman): Get AudioInputDeviceManager from MediaStreamManager. - media_stream::AudioInputDeviceManager* audio_input_man = NULL; - if (!audio_input_man) { - SendErrorMessage(stream_id); - return; - } + media_stream::AudioInputDeviceManager* audio_input_man = + resource_context_->media_stream_manager()->audio_input_device_manager(); // Add the session entry to the map. session_entries_[session_id] = stream_id; @@ -366,10 +366,9 @@ void AudioInputRendererHost::OnDeviceStopped(int session_id) { void AudioInputRendererHost::StopAndDeleteDevice(int session_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // TODO(mflodman): Get AudioInputDeviceManager from MediaStreamManager. - media_stream::AudioInputDeviceManager* audio_input_man = NULL; - if (audio_input_man) - audio_input_man->Stop(session_id); + media_stream::AudioInputDeviceManager* audio_input_man = + resource_context_->media_stream_manager()->audio_input_device_manager(); + audio_input_man->Stop(session_id); // Delete the session entry. session_entries_.erase(session_id); diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.h b/content/browser/renderer_host/media/audio_input_renderer_host.h index 94ef85e..e1fb65f 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.h +++ b/content/browser/renderer_host/media/audio_input_renderer_host.h @@ -69,6 +69,10 @@ #include "media/audio/audio_io.h" #include "media/audio/simple_sources.h" +namespace content { +class ResourceContext; +} + class AudioManager; struct AudioParameters; @@ -99,7 +103,8 @@ class AudioInputRendererHost }; // Called from UI thread from the owner of this object. - AudioInputRendererHost(); + explicit AudioInputRendererHost( + const content::ResourceContext* resource_context); // BrowserMessageFilter implementation. virtual void OnChannelClosing(); @@ -199,6 +204,9 @@ class AudioInputRendererHost // Returns 0 if not found. int LookupSessionById(int stream_id); + // Used to get an instance of AudioInputDeviceManager. + const content::ResourceContext* resource_context_; + // A map of stream IDs to audio sources. typedef std::map<int, AudioEntry*> AudioEntryMap; AudioEntryMap audio_entries_; diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index f37636e..ce216b4 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/rand_util.h" #include "content/browser/browser_thread.h" +#include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/media_stream_device_settings.h" #include "content/browser/renderer_host/media/media_stream_requester.h" #include "content/browser/renderer_host/media/video_capture_manager.h" @@ -67,8 +68,11 @@ VideoCaptureManager* MediaStreamManager::video_capture_manager() { AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // TODO(mflodman): Add when audio input manager is available. - return NULL; + if (!audio_input_device_manager_.get()) { + audio_input_device_manager_.reset(new AudioInputDeviceManager()); + audio_input_device_manager_->Register(this); + } + return audio_input_device_manager_.get(); } void MediaStreamManager::GenerateStream(MediaStreamRequester* requester, @@ -79,9 +83,6 @@ void MediaStreamManager::GenerateStream(MediaStreamRequester* requester, std::string* label) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // TODO(mflodman): Remove next line when audio is supported. - (const_cast<StreamOptions&>(options)).audio = false; - // Create a new request based on options. DeviceRequest new_request = DeviceRequest(requester, options); if (Requested(new_request.options, kAudioCapture)) { @@ -119,7 +120,7 @@ void MediaStreamManager::CancelRequests(MediaStreamRequester* requester) { request->audio_devices.begin(); it != request->audio_devices.end(); ++it) { if (it->in_use == true) { - // TODO(mflodman): Add when audio input device manager is available. + audio_input_device_manager()->Close(it->session_id); } } } @@ -147,8 +148,7 @@ void MediaStreamManager::StopGeneratedStream(const std::string& label) { for (StreamDeviceInfoArray::iterator audio_it = it->second.audio_devices.begin(); audio_it != it->second.audio_devices.end(); ++audio_it) { - // TODO(mflodman): Add code when audio input manager exists. - NOTREACHED(); + audio_input_device_manager()->Close(audio_it->session_id); } for (StreamDeviceInfoArray::iterator video_it = it->second.video_devices.begin(); @@ -364,7 +364,6 @@ void MediaStreamManager::UseFakeDevice() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); video_capture_manager()->UseFakeDevice(); device_settings_->UseFakeUI(); - // TODO(mflodman): Add audio manager when available. } bool MediaStreamManager::RequestDone(const DeviceRequest& request) const { @@ -397,9 +396,7 @@ MediaStreamProvider* MediaStreamManager::GetDeviceManager( if (stream_type == kVideoCapture) { return video_capture_manager(); } else if (stream_type == kAudioCapture) { - // TODO(mflodman): Add support when audio input manager is available. - NOTREACHED(); - return NULL; + return audio_input_device_manager(); } NOTREACHED(); return NULL; diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h index 9ddda6b..a5d74c4 100644 --- a/content/browser/renderer_host/media/media_stream_manager.h +++ b/content/browser/renderer_host/media/media_stream_manager.h @@ -115,7 +115,7 @@ class CONTENT_EXPORT MediaStreamManager scoped_ptr<MediaStreamDeviceSettings> device_settings_; scoped_ptr<VideoCaptureManager> video_capture_manager_; - // TODO(mflodman) Add AudioInputManager. + scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; // Keeps track of device types currently being enumerated to not enumerate // when not necessary. |