Chromium Code Reviews| Index: content/browser/renderer_host/media/media_stream_manager.h |
| diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h |
| index bb407cea0a373851c4a85a058f1fdd5b3730a0a1..44820fa147dea6e7f65d8ada77faadee912f71b0 100644 |
| --- a/content/browser/renderer_host/media/media_stream_manager.h |
| +++ b/content/browser/renderer_host/media/media_stream_manager.h |
| @@ -24,7 +24,6 @@ |
| #include <map> |
| #include <string> |
| -#include <vector> |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -44,6 +43,10 @@ class ScopedCOMInitializer; |
| } |
| } |
| +namespace media { |
| +class AudioManager; |
| +} |
| + |
| namespace media_stream { |
| class AudioInputDeviceManager; |
| @@ -76,33 +79,40 @@ class CONTENT_EXPORT MediaStreamManager |
| public SettingsRequester, |
| public base::SystemMonitor::DevicesChangedObserver { |
| public: |
| - // This class takes the ownerships of the |audio_input_device_manager| |
| - // and |video_capture_manager|. |
| - MediaStreamManager(AudioInputDeviceManager* audio_input_device_manager, |
| - VideoCaptureManager* video_capture_manager); |
| - |
| + explicit MediaStreamManager(media::AudioManager* audio_manager); |
| virtual ~MediaStreamManager(); |
| - // Used to access VideoCaptureManager. |
| - VideoCaptureManager* video_capture_manager(); |
| + // Used to access the VideoCaptureManager for the given |stream_type|. |
| + VideoCaptureManager* GetVideoCaptureManager(MediaStreamType stream_type); |
| - // Used to access AudioInputDeviceManager. |
| - AudioInputDeviceManager* audio_input_device_manager(); |
| + // Used to access the AudioInputDeviceManager for the given |stream_type|. |
| + AudioInputDeviceManager* GetAudioInputDeviceManager( |
| + MediaStreamType stream_type); |
| - // GenerateStream opens new media devices according to |components|. It |
| + // GenerateStream opens new media devices according to |components|. It |
| // creates a new request which is identified by a unique |label| that's |
| - // returned to the caller. |
| + // returned to the caller. |render_process_id| and |render_view_id| refer to |
| + // the view where the infobar will appear to the user. |
| void GenerateStream(MediaStreamRequester* requester, int render_process_id, |
| - int render_view_id, const StreamOptions& options, |
| + int render_view_id, const StreamOptions& components, |
| const GURL& security_origin, std::string* label); |
| + // Like GenerateStream above, except the user is only able to allow/deny the |
| + // request for the device specified by |device_id|. |
| + void GenerateStreamForDevice(MediaStreamRequester* requester, |
|
no longer working on chromium
2012/09/10 09:11:04
use the label instead?
miu
2012/09/10 21:24:38
I don't quite follow you here. Are you suggesting
no longer working on chromium
2012/09/10 22:12:38
Sorry, wrong comment, I meant returning the label,
|
| + int render_process_id, int render_view_id, |
| + const StreamOptions& components, |
| + const std::string& device_id, |
| + const GURL& security_origin, std::string* label); |
| + |
| // Cancel generate stream. |
| void CancelGenerateStream(const std::string& label); |
| // Closes generated stream. |
| void StopGeneratedStream(const std::string& label); |
| - // Gets a list of devices of |type|. |
| + // Gets a list of devices of |type|, which must be MEDIA_DEVICE_AUDIO_CAPTURE |
| + // or MEDIA_DEVICE_VIDEO_CAPTURE. |
| // The request is identified using |label|, which is pointing to a |
| // std::string. |
| // The request is persistent, which means the client keeps listening to |
| @@ -115,7 +125,8 @@ class CONTENT_EXPORT MediaStreamManager |
| const GURL& security_origin, |
| std::string* label); |
| - // Open a device identified by |device_id|. |
| + // Open a device identified by |device_id|. |type| must be either |
| + // MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. |
| // The request is identified using |label|, which is pointing to a |
| // std::string. |
| void OpenDevice(MediaStreamRequester* requester, |
| @@ -182,14 +193,15 @@ class CONTENT_EXPORT MediaStreamManager |
| MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); |
| void StartEnumeration(DeviceRequest* new_request, |
| std::string* label); |
| - void AddRequest(DeviceRequest* new_request, std::string* label); |
| + void AddRequest(const DeviceRequest& new_request, std::string* label); |
| bool HasEnumerationRequest(MediaStreamType type); |
| bool HasEnumerationRequest(); |
| void ClearEnumerationCache(EnumerationCache* cache); |
| - // Helper to ensure the device thread and pass the message loop to device |
| - // managers, it also register itself as the listener to the device managers. |
| - void EnsureDeviceThreadAndListener(); |
| + // Helper to create the device manager for the given stream_type, if needed. |
| + // Auto-starts the device thread and registers this as a listener with the |
| + // device managers. |
| + void EnsureDeviceManagerStarted(MediaStreamType stream_type); |
| // Sends cached device list to a client corresponding to the request |
| // identified by |label|. |
| @@ -206,8 +218,11 @@ class CONTENT_EXPORT MediaStreamManager |
| scoped_ptr<base::Thread> device_thread_; |
| scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
| - scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; |
| - scoped_refptr<VideoCaptureManager> video_capture_manager_; |
| + |
| + media::AudioManager* const audio_manager_; // not owned |
| + |
| + // Device managers, instantiated on-demand. |
| + scoped_refptr<MediaStreamProvider> device_manager_[content::NUM_MEDIA_TYPES]; |
| // Indicator of device monitoring state. |
| bool monitoring_started_; |
| @@ -219,7 +234,7 @@ class CONTENT_EXPORT MediaStreamManager |
| // Keeps track of live enumeration commands sent to VideoCaptureManager or |
| // AudioInputDeviceManager, in order to only enumerate when necessary. |
| - int active_enumeration_ref_count_[content::NUM_MEDIA_STREAM_DEVICE_TYPES]; |
| + int active_enumeration_ref_count_[content::NUM_MEDIA_TYPES]; |
| // All non-closed request. |
| typedef std::map<std::string, DeviceRequest> DeviceRequests; |