| Index: content/renderer/media/video_capture_impl_manager.h
|
| diff --git a/content/renderer/media/video_capture_impl_manager.h b/content/renderer/media/video_capture_impl_manager.h
|
| index 1b7c28b3fb7218017e03aa6b80eb3e57c062f4cc..005e70dd3e253aa0a58f5668c4c3a4509c8fa5c0 100644
|
| --- a/content/renderer/media/video_capture_impl_manager.h
|
| +++ b/content/renderer/media/video_capture_impl_manager.h
|
| @@ -5,8 +5,8 @@
|
| #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_
|
| #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_
|
|
|
| -#include <map>
|
| #include <memory>
|
| +#include <vector>
|
|
|
| #include "base/callback.h"
|
| #include "base/macros.h"
|
| @@ -77,6 +77,10 @@ class CONTENT_EXPORT VideoCaptureImplManager {
|
| // picture loss or quality issues).
|
| void RequestRefreshFrame(media::VideoCaptureSessionId id);
|
|
|
| + // Requests frame delivery be suspended/resumed for a given capture session.
|
| + void Suspend(media::VideoCaptureSessionId id);
|
| + void Resume(media::VideoCaptureSessionId id);
|
| +
|
| // Get supported formats supported by the device for the given session
|
| // ID. |callback| will be called on the IO thread.
|
| void GetDeviceSupportedFormats(media::VideoCaptureSessionId id,
|
| @@ -88,7 +92,9 @@ class CONTENT_EXPORT VideoCaptureImplManager {
|
| const VideoCaptureDeviceFormatsCB& callback);
|
|
|
| // Make all existing VideoCaptureImpl instances stop/resume delivering
|
| - // video frames to their clients, depends on flag |suspend|.
|
| + // video frames to their clients, depends on flag |suspend|. This is called in
|
| + // response to a RenderView-wide PageHidden/Shown() event. To suspend/resume
|
| + // an individual session, please call Suspend(id) or Resume(id).
|
| void SuspendDevices(bool suspend);
|
|
|
| VideoCaptureMessageFilter* video_capture_message_filter() const {
|
| @@ -96,21 +102,19 @@ class CONTENT_EXPORT VideoCaptureImplManager {
|
| }
|
|
|
| protected:
|
| - virtual VideoCaptureImpl* CreateVideoCaptureImplForTesting(
|
| + virtual std::unique_ptr<VideoCaptureImpl> CreateVideoCaptureImplForTesting(
|
| media::VideoCaptureSessionId id,
|
| VideoCaptureMessageFilter* filter) const;
|
|
|
| private:
|
| + // Holds bookkeeping info for each VideoCaptureImpl shared by clients.
|
| + struct DeviceEntry;
|
| +
|
| void StopCapture(int client_id, media::VideoCaptureSessionId id);
|
| void UnrefDevice(media::VideoCaptureSessionId id);
|
|
|
| - // The int is used to count clients of the corresponding VideoCaptureImpl.
|
| - // VideoCaptureImpl objects are owned by this object. But they are
|
| - // destroyed on the IO thread. These are raw pointers because we destroy
|
| - // them manually.
|
| - typedef std::map<media::VideoCaptureSessionId,
|
| - std::pair<int, VideoCaptureImpl*>> VideoCaptureDeviceMap;
|
| - VideoCaptureDeviceMap devices_;
|
| + // Devices currently in use.
|
| + std::vector<DeviceEntry> devices_;
|
|
|
| // This is an internal ID for identifying clients of VideoCaptureImpl.
|
| // The ID is global for the render process.
|
| @@ -122,6 +126,11 @@ class CONTENT_EXPORT VideoCaptureImplManager {
|
| // right thread.
|
| const scoped_refptr<base::SingleThreadTaskRunner> render_main_task_runner_;
|
|
|
| + // Set to true if SuspendDevices(true) was called. This, along with
|
| + // DeviceEntry::is_individually_suspended, is used to determine whether to
|
| + // take action when suspending/resuming each device.
|
| + bool is_suspending_all_;
|
| +
|
| // Bound to the render thread.
|
| // NOTE: Weak pointers must be invalidated before all other member variables.
|
| base::WeakPtrFactory<VideoCaptureImplManager> weak_factory_;
|
|
|