Index: content/browser/renderer_host/media/video_capture_manager.h |
diff --git a/content/browser/renderer_host/media/video_capture_manager.h b/content/browser/renderer_host/media/video_capture_manager.h |
index 6f0b0ec4702dedd2e9e2f43caecee942542ec5e8..9d75ee5634f769d2f257e522c9611e62a3d4a05a 100644 |
--- a/content/browser/renderer_host/media/video_capture_manager.h |
+++ b/content/browser/renderer_host/media/video_capture_manager.h |
@@ -17,6 +17,7 @@ |
#include <string> |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_vector.h" |
perkj_chrome
2013/11/12 11:10:58
remove if unused.
mcasas
2013/11/12 12:21:53
Done.
|
#include "base/memory/weak_ptr.h" |
#include "base/process/process_handle.h" |
#include "content/browser/renderer_host/media/media_stream_provider.h" |
@@ -59,7 +60,8 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
// Called by VideoCaptureHost to locate a capture device for |capture_params|, |
// adding the Host as a client of the device's controller if successful. The |
// value of |capture_params.session_id| controls which device is selected; |
- // this value should be a session id previously returned by Open(). |
+ // this value should be a session id previously returned by Open(). The device |
+ // capabilities are reduced to |capture_params|. |
// |
// If the device is not already started (i.e., no other client is currently |
// capturing from this device), this call will cause a VideoCaptureController |
@@ -82,9 +84,17 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
VideoCaptureControllerID client_id, |
VideoCaptureControllerEventHandler* client_handler); |
+ // Retrieve the available capture capabilities for a particular device. The |
+ // capabilities are cached during device(s) enumeration and updated as clients |
+ // open/close the device(s). |
+ void GetDeviceCapabilities(int capture_session_id, |
+ media::VideoCaptureCapabilities* capabilities); |
+ |
private: |
virtual ~VideoCaptureManager(); |
struct DeviceEntry; |
+ struct DeviceInfo; |
+ typedef std::vector<DeviceInfo> DevicesInfo; |
// Check to see if |entry| has no clients left on its controller. If so, |
// remove it from the list of devices, and delete it asynchronously. |entry| |
@@ -94,8 +104,9 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
// Helpers to report an event to our Listener. |
void OnOpened(MediaStreamType type, int capture_session_id); |
void OnClosed(MediaStreamType type, int capture_session_id); |
- void OnDevicesEnumerated(MediaStreamType stream_type, |
- const media::VideoCaptureDevice::Names& names); |
+ void OnDeviceNamesAndCapabilitiesEnumerated( |
+ MediaStreamType stream_type, |
+ DevicesInfo& new_devices_info_cache); |
// Find a DeviceEntry by its device ID and type, if it is already opened. |
DeviceEntry* GetDeviceEntryForMediaStreamDevice( |
@@ -111,9 +122,13 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
bool IsOnDeviceThread() const; |
- // Queries and returns the available device IDs. |
- media::VideoCaptureDevice::Names GetAvailableDevicesOnDeviceThread( |
- MediaStreamType stream_type); |
+ // Queries the Names of the devices in the system; the capabilities of the new |
+ // devices are also queried, and consolidated with the copy of the local |
+ // device info cache passed. The consolidated list of devices+capabilities is |
+ // returned. |
+ DevicesInfo GetAvailableDevicesAndCapabilitiesOnDeviceThread( |
+ MediaStreamType stream_type, |
+ const DevicesInfo& devices_info_cache_copy); |
// Create and Start a new VideoCaptureDevice, storing the result in |
// |entry->video_capture_device|. Ownership of |client| passes to |
@@ -127,6 +142,9 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
// |entry->video_capture_device|. |
void DoStopDeviceOnDeviceThread(DeviceEntry* entry); |
+ DeviceInfo* FindDeviceInfoById(const std::string& id, |
+ DevicesInfo& device_vector); |
+ |
// The message loop of media stream device thread, where VCD's live. |
scoped_refptr<base::MessageLoopProxy> device_loop_; |
@@ -171,11 +189,26 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
// default. This is only used for the MEDIA_DEVICE_VIDEO_CAPTURE device type. |
bool use_fake_device_; |
- // We cache the enumerated video capture devices in |
- // GetAvailableDevicesOnDeviceThread() and then later look up the requested ID |
- // when a device is created in DoStartDeviceOnDeviceThread(). Used only on the |
- // device thread. |
- media::VideoCaptureDevice::Names video_capture_devices_; |
+ // This data structure is a convenient wrap of a devices' name and associated |
+ // video capture capabilities, and a flag that indicates if in use. |
+ struct DeviceInfo { |
perkj_chrome
2013/11/12 11:10:58
Please replace your foward declaration of DeviceIn
mcasas
2013/11/12 12:21:53
Done.
|
+ DeviceInfo(); |
+ DeviceInfo(const media::VideoCaptureDevice::Name& name, |
+ const media::VideoCaptureCapabilities& capabilities); |
+ ~DeviceInfo(); |
+ |
+ bool device_in_use_; |
+ media::VideoCaptureDevice::Name name_; |
+ media::VideoCaptureCapabilities capabilities_; |
+ }; |
+ // Local cache of the enumerated video capture devices' names and capture |
+ // capabilities. A snapshot of the current devices and their capabilities is |
+ // composed in GetAvailableDevicesAndCapabilitiesOnDeviceThread() --coming |
+ // from EnumerateDevices()--, and this snapshot is used to update this list in |
+ // OnDeviceNamesAndCapabilitiesEnumerated(). The flag |device_in_use_| is |
+ // updated in StartCaptureForClient() and StopCaptureForClient() (if the |
+ // device is not in use anymore). |
+ DevicesInfo devices_info_cache_; |
DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
}; |