| 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 // VideoCaptureManager is used to open/close, start/stop, enumerate available | 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available |
| 6 // video capture devices, and manage VideoCaptureController's. | 6 // video capture devices, and manage VideoCaptureController's. |
| 7 // All functions are expected to be called from Browser::IO thread. Some helper | 7 // All functions are expected to be called from Browser::IO thread. Some helper |
| 8 // functions (*OnDeviceThread) will dispatch operations to the device thread. | 8 // functions (*OnDeviceThread) will dispatch operations to the device thread. |
| 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. | 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. |
| 10 // A device can only be opened once. | 10 // A device can only be opened once. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // is hidden, see http://crbug.com/582295. | 167 // is hidden, see http://crbug.com/582295. |
| 168 void OnApplicationStateChange(base::android::ApplicationState state); | 168 void OnApplicationStateChange(base::android::ApplicationState state); |
| 169 #endif | 169 #endif |
| 170 | 170 |
| 171 using EnumerationCallback = | 171 using EnumerationCallback = |
| 172 base::Callback<void(const media::VideoCaptureDeviceDescriptors&)>; | 172 base::Callback<void(const media::VideoCaptureDeviceDescriptors&)>; |
| 173 void EnumerateDevices(const EnumerationCallback& client_callback); | 173 void EnumerateDevices(const EnumerationCallback& client_callback); |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 class CaptureDeviceStartRequest; | 176 class CaptureDeviceStartRequest; |
| 177 struct DeviceEntry; | 177 class DeviceEntry; |
| 178 struct DeviceInfo; | 178 struct DeviceInfo; |
| 179 | 179 |
| 180 using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>; | 180 using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>; |
| 181 using DeviceEntries = std::vector<std::unique_ptr<DeviceEntry>>; | 181 using DeviceEntries = std::vector<std::unique_ptr<DeviceEntry>>; |
| 182 using DeviceInfos = std::vector<DeviceInfo>; | 182 using DeviceInfos = std::vector<DeviceInfo>; |
| 183 using DeviceStartQueue = std::list<CaptureDeviceStartRequest>; | 183 using DeviceStartQueue = std::list<CaptureDeviceStartRequest>; |
| 184 using VideoCaptureDeviceDescriptor = media::VideoCaptureDeviceDescriptor; | 184 using VideoCaptureDeviceDescriptor = media::VideoCaptureDeviceDescriptor; |
| 185 using VideoCaptureDeviceDescriptors = media::VideoCaptureDeviceDescriptors; | 185 using VideoCaptureDeviceDescriptors = media::VideoCaptureDeviceDescriptors; |
| 186 | 186 |
| 187 ~VideoCaptureManager() override; | 187 ~VideoCaptureManager() override; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 // Starting a capture device can take 1-2 seconds. | 233 // Starting a capture device can take 1-2 seconds. |
| 234 // To avoid multiple unnecessary start/stop commands to the OS, each start | 234 // To avoid multiple unnecessary start/stop commands to the OS, each start |
| 235 // request is queued in |device_start_queue_|. | 235 // request is queued in |device_start_queue_|. |
| 236 // QueueStartDevice creates a new entry in |device_start_queue_| and posts a | 236 // QueueStartDevice creates a new entry in |device_start_queue_| and posts a |
| 237 // request to start the device on the device thread unless there is | 237 // request to start the device on the device thread unless there is |
| 238 // another request pending start. | 238 // another request pending start. |
| 239 void QueueStartDevice(media::VideoCaptureSessionId session_id, | 239 void QueueStartDevice(media::VideoCaptureSessionId session_id, |
| 240 DeviceEntry* entry, | 240 DeviceEntry* entry, |
| 241 const media::VideoCaptureParams& params); | 241 const media::VideoCaptureParams& params); |
| 242 void OnDeviceStarted( | 242 void OnDeviceStarted(int serial_id, |
| 243 int serial_id, | 243 std::unique_ptr<VideoCaptureDevice> device); |
| 244 std::unique_ptr<media::FrameBufferPool> frame_buffer_pool, | |
| 245 std::unique_ptr<VideoCaptureDevice> device); | |
| 246 void DoStopDevice(DeviceEntry* entry); | 244 void DoStopDevice(DeviceEntry* entry); |
| 247 void HandleQueuedStartRequest(); | 245 void HandleQueuedStartRequest(); |
| 248 | 246 |
| 249 // Creates and Starts a new VideoCaptureDevice. The resulting | 247 // Creates and Starts a new VideoCaptureDevice. The resulting |
| 250 // VideoCaptureDevice is returned to the IO-thread and stored in | 248 // VideoCaptureDevice is returned to the IO-thread and stored in |
| 251 // a DeviceEntry in |devices_|. Ownership of |client| passes to | 249 // a DeviceEntry in |devices_|. Ownership of |client| passes to |
| 252 // the device. | 250 // the device. |
| 253 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread( | 251 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread( |
| 254 const VideoCaptureDeviceDescriptor& descriptor, | 252 const VideoCaptureDeviceDescriptor& descriptor, |
| 255 const media::VideoCaptureParams& params, | 253 const media::VideoCaptureParams& params, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // Map used by DesktopCapture. | 333 // Map used by DesktopCapture. |
| 336 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 334 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
| 337 notification_window_ids_; | 335 notification_window_ids_; |
| 338 | 336 |
| 339 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 337 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
| 340 }; | 338 }; |
| 341 | 339 |
| 342 } // namespace content | 340 } // namespace content |
| 343 | 341 |
| 344 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 342 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
| OLD | NEW |