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 19 matching lines...) Expand all Loading... |
30 #include "content/common/content_export.h" | 30 #include "content/common/content_export.h" |
31 #include "content/common/media/media_stream_options.h" | 31 #include "content/common/media/media_stream_options.h" |
32 #include "media/capture/video/video_capture_device.h" | 32 #include "media/capture/video/video_capture_device.h" |
33 #include "media/capture/video/video_capture_device_factory.h" | 33 #include "media/capture/video/video_capture_device_factory.h" |
34 #include "media/capture/video_capture_types.h" | 34 #include "media/capture/video_capture_types.h" |
35 | 35 |
36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
37 #include "base/android/application_status_listener.h" | 37 #include "base/android/application_status_listener.h" |
38 #endif | 38 #endif |
39 | 39 |
| 40 namespace media { |
| 41 class VideoCaptureDeviceClient; |
| 42 } |
| 43 |
40 namespace content { | 44 namespace content { |
41 class VideoCaptureController; | 45 class VideoCaptureController; |
42 class VideoCaptureControllerEventHandler; | 46 class VideoCaptureControllerEventHandler; |
43 | 47 |
44 // VideoCaptureManager opens/closes and start/stops video capture devices. | 48 // VideoCaptureManager opens/closes and start/stops video capture devices. |
45 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 49 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
46 public: | 50 public: |
47 using VideoCaptureDevice = media::VideoCaptureDevice; | 51 using VideoCaptureDevice = media::VideoCaptureDevice; |
48 | 52 |
49 // Callback used to signal the completion of a controller lookup. | 53 // Callback used to signal the completion of a controller lookup. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Starting a capture device can take 1-2 seconds. | 237 // Starting a capture device can take 1-2 seconds. |
234 // To avoid multiple unnecessary start/stop commands to the OS, each start | 238 // To avoid multiple unnecessary start/stop commands to the OS, each start |
235 // request is queued in |device_start_queue_|. | 239 // request is queued in |device_start_queue_|. |
236 // QueueStartDevice creates a new entry in |device_start_queue_| and posts a | 240 // 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 | 241 // request to start the device on the device thread unless there is |
238 // another request pending start. | 242 // another request pending start. |
239 void QueueStartDevice(media::VideoCaptureSessionId session_id, | 243 void QueueStartDevice(media::VideoCaptureSessionId session_id, |
240 DeviceEntry* entry, | 244 DeviceEntry* entry, |
241 const media::VideoCaptureParams& params); | 245 const media::VideoCaptureParams& params); |
242 void OnDeviceStarted(int serial_id, | 246 void OnDeviceStarted(int serial_id, |
| 247 media::VideoCaptureDeviceClient* device_client_ptr, |
243 std::unique_ptr<VideoCaptureDevice> device); | 248 std::unique_ptr<VideoCaptureDevice> device); |
244 void DoStopDevice(DeviceEntry* entry); | 249 void DoStopDevice(DeviceEntry* entry); |
245 void HandleQueuedStartRequest(); | 250 void HandleQueuedStartRequest(); |
246 | 251 |
247 // Creates and Starts a new VideoCaptureDevice. The resulting | 252 // Creates and Starts a new VideoCaptureDevice. The resulting |
248 // VideoCaptureDevice is returned to the IO-thread and stored in | 253 // VideoCaptureDevice is returned to the IO-thread and stored in |
249 // a DeviceEntry in |devices_|. Ownership of |client| passes to | 254 // a DeviceEntry in |devices_|. Ownership of |client| passes to |
250 // the device. | 255 // the device. |
251 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread( | 256 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread( |
252 const VideoCaptureDeviceDescriptor& descriptor, | 257 const VideoCaptureDeviceDescriptor& descriptor, |
253 const media::VideoCaptureParams& params, | 258 const media::VideoCaptureParams& params, |
254 std::unique_ptr<VideoCaptureDevice::Client> client); | 259 std::unique_ptr<media::VideoCaptureDeviceClient> client); |
255 | 260 |
256 std::unique_ptr<VideoCaptureDevice> DoStartTabCaptureOnDeviceThread( | 261 std::unique_ptr<VideoCaptureDevice> DoStartTabCaptureOnDeviceThread( |
257 const std::string& device_id, | 262 const std::string& device_id, |
258 const media::VideoCaptureParams& params, | 263 const media::VideoCaptureParams& params, |
259 std::unique_ptr<VideoCaptureDevice::Client> client); | 264 std::unique_ptr<media::VideoCaptureDeviceClient> client); |
260 | 265 |
261 std::unique_ptr<VideoCaptureDevice> DoStartDesktopCaptureOnDeviceThread( | 266 std::unique_ptr<VideoCaptureDevice> DoStartDesktopCaptureOnDeviceThread( |
262 const std::string& device_id, | 267 const std::string& device_id, |
263 const media::VideoCaptureParams& params, | 268 const media::VideoCaptureParams& params, |
264 std::unique_ptr<VideoCaptureDevice::Client> client); | 269 std::unique_ptr<media::VideoCaptureDeviceClient> client); |
265 | 270 |
266 // Stops and destroys the VideoCaptureDevice held in |device|. | 271 // Stops and destroys the VideoCaptureDevice held in |device|. |
267 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device); | 272 void DoStopDeviceOnDeviceThread(std::unique_ptr<VideoCaptureDevice> device); |
268 | 273 |
269 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id); | 274 void MaybePostDesktopCaptureWindowId(media::VideoCaptureSessionId session_id); |
270 void SetDesktopCaptureWindowIdOnDeviceThread( | 275 void SetDesktopCaptureWindowIdOnDeviceThread( |
271 media::VideoCaptureDevice* device, | 276 media::VideoCaptureDevice* device, |
272 gfx::NativeViewId window_id); | 277 gfx::NativeViewId window_id); |
273 | 278 |
274 // Internal versions of the Image Capture public ones, for delayed execution. | 279 // Internal versions of the Image Capture public ones, for delayed execution. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // Map used by DesktopCapture. | 358 // Map used by DesktopCapture. |
354 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 359 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
355 notification_window_ids_; | 360 notification_window_ids_; |
356 | 361 |
357 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 362 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
358 }; | 363 }; |
359 | 364 |
360 } // namespace content | 365 } // namespace content |
361 | 366 |
362 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 367 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |