| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Get supported formats supported by the device for the given session | 83 // Get supported formats supported by the device for the given session |
| 84 // ID. |callback| will be called on the IO thread. | 84 // ID. |callback| will be called on the IO thread. |
| 85 void GetDeviceSupportedFormats(media::VideoCaptureSessionId id, | 85 void GetDeviceSupportedFormats(media::VideoCaptureSessionId id, |
| 86 const VideoCaptureDeviceFormatsCB& callback); | 86 const VideoCaptureDeviceFormatsCB& callback); |
| 87 | 87 |
| 88 // Get supported formats currently in use for the given session ID. | 88 // Get supported formats currently in use for the given session ID. |
| 89 // |callback| will be called on the IO thread. | 89 // |callback| will be called on the IO thread. |
| 90 void GetDeviceFormatsInUse(media::VideoCaptureSessionId id, | 90 void GetDeviceFormatsInUse(media::VideoCaptureSessionId id, |
| 91 const VideoCaptureDeviceFormatsCB& callback); | 91 const VideoCaptureDeviceFormatsCB& callback); |
| 92 | 92 |
| 93 // Make all existing VideoCaptureImpl instances stop/resume delivering | |
| 94 // video frames to their clients, depends on flag |suspend|. This is called in | |
| 95 // response to a RenderView-wide PageHidden/Shown() event. To suspend/resume | |
| 96 // an individual session, please call Suspend(id) or Resume(id). | |
| 97 void SuspendDevices(bool suspend); | |
| 98 | |
| 99 virtual std::unique_ptr<VideoCaptureImpl> CreateVideoCaptureImplForTesting( | 93 virtual std::unique_ptr<VideoCaptureImpl> CreateVideoCaptureImplForTesting( |
| 100 media::VideoCaptureSessionId session_id) const; | 94 media::VideoCaptureSessionId session_id) const; |
| 101 | 95 |
| 102 private: | 96 private: |
| 103 // Holds bookkeeping info for each VideoCaptureImpl shared by clients. | 97 // Holds bookkeeping info for each VideoCaptureImpl shared by clients. |
| 104 struct DeviceEntry; | 98 struct DeviceEntry; |
| 105 | 99 |
| 106 void StopCapture(int client_id, media::VideoCaptureSessionId id); | 100 void StopCapture(int client_id, media::VideoCaptureSessionId id); |
| 107 void UnrefDevice(media::VideoCaptureSessionId id); | 101 void UnrefDevice(media::VideoCaptureSessionId id); |
| 108 | 102 |
| 109 // Devices currently in use. | 103 // Devices currently in use. |
| 110 std::vector<DeviceEntry> devices_; | 104 std::vector<DeviceEntry> devices_; |
| 111 | 105 |
| 112 // This is an internal ID for identifying clients of VideoCaptureImpl. | 106 // This is an internal ID for identifying clients of VideoCaptureImpl. |
| 113 // The ID is global for the render process. | 107 // The ID is global for the render process. |
| 114 int next_client_id_; | 108 int next_client_id_; |
| 115 | 109 |
| 116 // Hold a pointer to the Render Main message loop to check we operate on the | 110 // Hold a pointer to the Render Main message loop to check we operate on the |
| 117 // right thread. | 111 // right thread. |
| 118 const scoped_refptr<base::SingleThreadTaskRunner> render_main_task_runner_; | 112 const scoped_refptr<base::SingleThreadTaskRunner> render_main_task_runner_; |
| 119 | 113 |
| 120 // Set to true if SuspendDevices(true) was called. This, along with | |
| 121 // DeviceEntry::is_individually_suspended, is used to determine whether to | |
| 122 // take action when suspending/resuming each device. | |
| 123 bool is_suspending_all_; | |
| 124 | |
| 125 // Bound to the render thread. | 114 // Bound to the render thread. |
| 126 // NOTE: Weak pointers must be invalidated before all other member variables. | 115 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 127 base::WeakPtrFactory<VideoCaptureImplManager> weak_factory_; | 116 base::WeakPtrFactory<VideoCaptureImplManager> weak_factory_; |
| 128 | 117 |
| 129 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplManager); | 118 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplManager); |
| 130 }; | 119 }; |
| 131 | 120 |
| 132 } // namespace content | 121 } // namespace content |
| 133 | 122 |
| 134 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 123 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
| OLD | NEW |