Chromium Code Reviews| 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 47450d366a74ffde6df3bd7299f1c1ec6fcac032..19986fbdda5cc11d3087727e5308ffb27f801a85 100644 |
| --- a/content/browser/renderer_host/media/video_capture_manager.h |
| +++ b/content/browser/renderer_host/media/video_capture_manager.h |
| @@ -19,7 +19,6 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/memory/scoped_vector.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/process/process_handle.h" |
| @@ -175,14 +174,10 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| private: |
| class DeviceEntry; |
| + using DeviceEntries = std::vector<std::unique_ptr<DeviceEntry>>; |
| ~VideoCaptureManager() override; |
| - // Checks 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| |
| - // may be freed by this function. |
| - void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); |
| - |
| // Helpers to report an event to our Listener. |
| void OnOpened(MediaStreamType type, |
| media::VideoCaptureSessionId capture_session_id); |
| @@ -193,24 +188,6 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| base::ElapsedTimer* timer, |
| const media::VideoCaptureDeviceInfos& new_devices_info_cache); |
| - // Finds a DeviceEntry by its device ID and type, if it is already opened. |
| - DeviceEntry* GetDeviceEntryForMediaStreamDevice( |
| - const MediaStreamDevice& device_info); |
| - |
| - // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr |
| - // if not found. |
| - VideoCaptureDevice* GetVideoCaptureDeviceFromSessionId(int session_id); |
| - |
| - // Finds a DeviceEntry entry for the indicated session, creating a fresh one |
| - // if necessary. Returns NULL if the session id is invalid. |
| - DeviceEntry* GetOrCreateDeviceEntry( |
| - media::VideoCaptureSessionId capture_session_id, |
| - const media::VideoCaptureParams& params); |
| - |
| - // Finds the DeviceEntry that owns a particular controller pointer. |
| - DeviceEntry* GetDeviceEntryForController( |
| - const VideoCaptureController* controller) const; |
| - |
| bool IsOnDeviceThread() const; |
| // Consolidates the cached devices list with the list of currently connected |
| @@ -223,6 +200,33 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| const media::VideoCaptureDeviceInfos& old_device_info_cache, |
| std::unique_ptr<VideoCaptureDevice::Names> names_snapshot); |
| + // Checks 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| |
| + // may be freed by this function. |
| + void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); |
| + |
| + // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr |
| + // if not found. |
| + VideoCaptureDevice* GetVideoCaptureDeviceBySessionId(int session_id); |
| + |
| + // Finds a DeviceEntry in different ways: by its device ID and type (if it is |
| + // already opened), by its |controller| or by its |serial_id|. In all cases, |
| + // if not found, nullptr is returned. |
| + DeviceEntry* GetDeviceEntryByTypeAndId(MediaStreamType type, |
| + const std::string& id) const; |
| + DeviceEntry* GetDeviceEntryByController( |
| + const VideoCaptureController* controller) const; |
| + DeviceEntry* GetDeviceEntryBySerialId(int serial_id) const; |
| + |
| + // Finds the device info by |id| in |devices_info_cache_|, or nullptr. |
| + media::VideoCaptureDeviceInfo* GetDeviceInfoById(const std::string& id); |
| + |
| + // Finds a DeviceEntry entry for the indicated session, creating a fresh one |
| + // if necessary. Returns NULL if the session id is invalid. |
| + DeviceEntry* GetOrCreateDeviceEntry( |
| + media::VideoCaptureSessionId capture_session_id, |
| + const media::VideoCaptureParams& params); |
| + |
| // Starting a capture device can take 1-2 seconds. |
| // To avoid multiple unnecessary start/stop commands to the OS, each start |
| // request is queued in |device_start_queue_|. |
| @@ -259,10 +263,6 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| // Stops and destroys the VideoCaptureDevice held in |device|. |
| void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device); |
| - media::VideoCaptureDeviceInfo* FindDeviceInfoById( |
| - const std::string& id, |
| - media::VideoCaptureDeviceInfos& device_vector); |
| - |
| void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id); |
| void SetDesktopCaptureWindowIdOnDeviceThread( |
| media::VideoCaptureDevice* device, |
| @@ -308,16 +308,15 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| // the Open() entry point. The keys are session_id's. This map is used to |
| // determine which device to use when StartCaptureForClient() occurs. Used |
| // only on the IO thread. |
| - typedef std::map<media::VideoCaptureSessionId, MediaStreamDevice> SessionMap; |
| + using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>; |
| SessionMap sessions_; |
| - // Currently opened devices. The device may or may not be started. This member |
| - // is only accessed on IO tbhread. |
| - typedef ScopedVector<DeviceEntry> DeviceEntries; |
| + // Currently opened devices and associate controller. The device may or may |
|
chfremer
2016/06/30 17:08:52
Is there only one controller associated with all d
mcasas
2016/06/30 17:43:18
Yeah, there is a one-to-one relationship
between a
|
| + // not be started. This member is only accessed on IO tbhread. |
| DeviceEntries devices_; |
| class CaptureDeviceStartRequest; |
| - typedef std::list<CaptureDeviceStartRequest> DeviceStartQueue; |
| + using DeviceStartQueue = std::list<CaptureDeviceStartRequest>; |
| DeviceStartQueue device_start_queue_; |
| // Device creation factory injected on construction from MediaStreamManager or |