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..c4558bd115468b0d934566474ae7970f90482cae 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,24 +79,21 @@ 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); |
- |
+ MediaStreamManager(); |
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 |
// creates a new request which is identified by a unique |label| that's |
// returned to the caller. |
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); |
// Cancel generate stream. |
@@ -146,6 +146,13 @@ class CONTENT_EXPORT MediaStreamManager |
virtual void OnDevicesChanged( |
base::SystemMonitor::DeviceType device_type) OVERRIDE; |
+ // Used by unit tests to provide an alternate AudioManager instance. |
+ // Normally, BrowserMainLoop::GetAudioManager() is used to gain access to the |
+ // AudioManager. This function must be called before any |
+ // AudioInputDeviceManager is accessed or streaming/opening of an audio |
+ // device is attempted. |
+ void SetAudioManager(media::AudioManager* audio_manager); |
+ |
// Used by unit test to make sure fake devices are used instead of a real |
// devices, which is needed for server based testing. |
// TODO(xians): Remove this hack since we can create our own |
@@ -187,9 +194,10 @@ class CONTENT_EXPORT MediaStreamManager |
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,20 +214,23 @@ 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* 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_; |
// Stores most recently enumerated device lists. The cache is cleared when |
// monitoring is stopped or there is no request for that type of device. |
- EnumerationCache audio_enumeration_cache_; |
- EnumerationCache video_enumeration_cache_; |
+ EnumerationCache user_audio_enumeration_cache_; |
+ EnumerationCache user_video_enumeration_cache_; |
// 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; |