diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 06:57:55 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 06:57:55 +0000 |
commit | 6d752259c5c0e840b0053462a8d865ddb47461f9 (patch) | |
tree | 4389b1c57d81a24bc0a066efae548c375fe4b848 /content | |
parent | fcaa06b5f712788a96330e3da54cc1b64560fda4 (diff) | |
download | chromium_src-6d752259c5c0e840b0053462a8d865ddb47461f9.zip chromium_src-6d752259c5c0e840b0053462a8d865ddb47461f9.tar.gz chromium_src-6d752259c5c0e840b0053462a8d865ddb47461f9.tar.bz2 |
Hook up screen capture notification UI.
Screen capture notification should be shown whenever screen captur API is
being used. This CL hooks screen capture API to the UI (the UI itself is not
implemented yet).
Also updated MediaStreamManager to limit number of active screen capture
streams (this is necessary because initially the UI will support only one
stream).
BUG=190156
Review URL: https://chromiumcodereview.appspot.com/12900007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/media/media_stream_manager.cc | 42 | ||||
-rw-r--r-- | content/browser/renderer_host/media/media_stream_manager.h | 3 |
2 files changed, 38 insertions, 7 deletions
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 87dbfe2..a640dc5 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -151,7 +151,8 @@ MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager) ui_controller_(new MediaStreamUIController(this))), audio_manager_(audio_manager), monitoring_started_(false), - io_loop_(NULL) { + io_loop_(NULL), + screen_capture_active_(false) { DCHECK(audio_manager_); memset(active_enumeration_ref_count_, 0, sizeof(active_enumeration_ref_count_)); @@ -249,6 +250,23 @@ std::string MediaStreamManager::GenerateStream( } } + if (options.video_type == MEDIA_SCREEN_VIDEO_CAPTURE) { + if (options.audio_type != MEDIA_NO_SERVICE) { + // TODO(sergeyu): Surface error message to the calling JS code. + LOG(ERROR) << "Audio is not supported for screen capture streams."; + return std::string(); + } + + if (screen_capture_active_) { + // TODO(sergeyu): Implement support for more than one concurrent screen + // capture streams. + LOG(ERROR) << "Another screen capture stream is active."; + return std::string(); + } + + screen_capture_active_ = true; + } + // Create a new request based on options. DeviceRequest* request = new DeviceRequest(requester, options, @@ -274,7 +292,7 @@ void MediaStreamManager::CancelRequest(const std::string& label) { // TODO(xians): update the |state| to STATE_DONE to trigger a state // changed notification to UI before deleting the request? scoped_ptr<DeviceRequest> request(it->second); - requests_.erase(it); + RemoveRequest(it); for (int i = MEDIA_NO_SERVICE + 1; i < NUM_MEDIA_TYPES; ++i) { const MediaStreamType stream_type = static_cast<MediaStreamType>(i); MediaStreamProvider* device_manager = GetDeviceManager(stream_type); @@ -299,6 +317,7 @@ void MediaStreamManager::CancelRequest(const std::string& label) { void MediaStreamManager::StopGeneratedStream(const std::string& label) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + // Find the request and close all open devices for the request. DeviceRequests::iterator it = requests_.find(label); if (it != requests_.end()) { @@ -308,7 +327,7 @@ void MediaStreamManager::StopGeneratedStream(const std::string& label) { } scoped_ptr<DeviceRequest> request(it->second); - requests_.erase(it); + RemoveRequest(it); for (StreamDeviceInfoArray::const_iterator device_it = request->devices.begin(); device_it != request->devices.end(); ++device_it) { @@ -400,7 +419,7 @@ void MediaStreamManager::StopEnumerateDevices(const std::string& label) { DCHECK_EQ(it->second->type, MEDIA_ENUMERATE_DEVICES); // Delete the DeviceRequest. scoped_ptr<DeviceRequest> request(it->second); - requests_.erase(it); + RemoveRequest(it); } } @@ -539,6 +558,15 @@ std::string MediaStreamManager::AddRequest(DeviceRequest* request) { return unique_label; } +void MediaStreamManager::RemoveRequest(DeviceRequests::iterator it) { + if (it->second->options.video_type == MEDIA_SCREEN_VIDEO_CAPTURE) { + DCHECK(screen_capture_active_); + screen_capture_active_ = false; + } + + requests_.erase(it); +} + void MediaStreamManager::PostRequestToUI(const std::string& label) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DeviceRequest* request = requests_[label]; @@ -810,7 +838,7 @@ void MediaStreamManager::Error(MediaStreamType stream_type, if (request->requester) request->requester->StreamGenerationFailed(it->first); - requests_.erase(it); + RemoveRequest(it); } else { // 2. Not opened but other devices exists for this request -> remove // device from list, but don't signal an error. @@ -845,7 +873,7 @@ void MediaStreamManager::DevicesAccepted(const std::string& label, } // Delete the request since it is done. - requests_.erase(request_it); + RemoveRequest(request_it); return; } @@ -923,7 +951,7 @@ void MediaStreamManager::SettingsError(const std::string& label) { request->callback.Run(label, MediaStreamDevices()); } - requests_.erase(it); + RemoveRequest(it); } void MediaStreamManager::StopStreamFromUI(const std::string& label) { diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h index 4558e0f..205ddb2 100644 --- a/content/browser/renderer_host/media/media_stream_manager.h +++ b/content/browser/renderer_host/media/media_stream_manager.h @@ -203,6 +203,7 @@ class CONTENT_EXPORT MediaStreamManager MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); void StartEnumeration(DeviceRequest* request); std::string AddRequest(DeviceRequest* request); + void RemoveRequest(DeviceRequests::iterator it); void ClearEnumerationCache(EnumerationCache* cache); void PostRequestToUI(const std::string& label); void HandleRequest(const std::string& label); @@ -250,6 +251,8 @@ class CONTENT_EXPORT MediaStreamManager // managers on the right thread. MessageLoop* io_loop_; + bool screen_capture_active_; + DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); }; |