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 11 matching lines...) Expand all Loading... | |
22 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
24 #include "base/process/process_handle.h" | 24 #include "base/process/process_handle.h" |
25 #include "base/threading/thread_checker.h" | 25 #include "base/threading/thread_checker.h" |
26 #include "base/timer/elapsed_timer.h" | 26 #include "base/timer/elapsed_timer.h" |
27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
28 #include "content/browser/renderer_host/media/media_stream_provider.h" | 28 #include "content/browser/renderer_host/media/media_stream_provider.h" |
29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
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/base/video_facing.h" | |
32 #include "media/capture/video/video_capture_device.h" | 33 #include "media/capture/video/video_capture_device.h" |
33 #include "media/capture/video/video_capture_device_factory.h" | 34 #include "media/capture/video/video_capture_device_factory.h" |
34 #include "media/capture/video_capture_types.h" | 35 #include "media/capture/video_capture_types.h" |
35 | 36 |
36 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
37 #include "base/android/application_status_listener.h" | 38 #include "base/android/application_status_listener.h" |
38 #endif | 39 #endif |
39 | 40 |
40 namespace content { | 41 namespace content { |
41 class VideoCaptureController; | 42 class VideoCaptureController; |
42 class VideoCaptureControllerEventHandler; | 43 class VideoCaptureControllerEventHandler; |
43 | 44 |
44 // VideoCaptureManager opens/closes and start/stops video capture devices. | 45 // VideoCaptureManager opens/closes and start/stops video capture devices. |
45 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 46 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
46 public: | 47 public: |
47 using VideoCaptureDevice = media::VideoCaptureDevice; | 48 using VideoCaptureDevice = media::VideoCaptureDevice; |
48 | 49 |
49 // Callback used to signal the completion of a controller lookup. | 50 // Callback used to signal the completion of a controller lookup. |
50 using DoneCB = | 51 using DoneCB = |
51 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>; | 52 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>; |
52 | 53 |
53 explicit VideoCaptureManager( | 54 explicit VideoCaptureManager( |
54 std::unique_ptr<media::VideoCaptureDeviceFactory> factory); | 55 std::unique_ptr<media::VideoCaptureDeviceFactory> factory); |
55 | 56 |
57 // This can be called in anytime during the VideoCaptureManager lifecycle. | |
58 // It can be called more than once and it's ok to not call at all if the | |
59 // client is not interested in receiving media::VideoCaptureObserver callacks. | |
60 // This method can be called on whatever thread. The callbacks of | |
61 // media::VideoCaptureObserver arrive on browser threads. | |
chfremer
2017/01/30 19:49:28
This seems too permissive to be true.
If we could
shenghao
2017/02/08 02:07:10
Done.
| |
62 void SetVideoCaptureObserver( | |
63 std::unique_ptr<media::VideoCaptureObserver> observer); | |
64 | |
56 void Unregister(); | 65 void Unregister(); |
57 | 66 |
58 // Implements MediaStreamProvider. | 67 // Implements MediaStreamProvider. |
59 void Register(MediaStreamProviderListener* listener, | 68 void Register(MediaStreamProviderListener* listener, |
60 const scoped_refptr<base::SingleThreadTaskRunner>& | 69 const scoped_refptr<base::SingleThreadTaskRunner>& |
61 device_task_runner) override; | 70 device_task_runner) override; |
62 int Open(const StreamDeviceInfo& device) override; | 71 int Open(const StreamDeviceInfo& device) override; |
63 void Close(int capture_session_id) override; | 72 void Close(int capture_session_id) override; |
64 | 73 |
65 // Called by VideoCaptureHost to locate a capture device for |capture_params|, | 74 // Called by VideoCaptureHost to locate a capture device for |capture_params|, |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 // Queue to keep photo-associated requests waiting for a device to initialize, | 325 // Queue to keep photo-associated requests waiting for a device to initialize, |
317 // bundles a session id integer and an associated photo-related request. | 326 // bundles a session id integer and an associated photo-related request. |
318 std::list<std::pair<int, base::Callback<void(media::VideoCaptureDevice*)>>> | 327 std::list<std::pair<int, base::Callback<void(media::VideoCaptureDevice*)>>> |
319 photo_request_queue_; | 328 photo_request_queue_; |
320 | 329 |
321 // Device creation factory injected on construction from MediaStreamManager or | 330 // Device creation factory injected on construction from MediaStreamManager or |
322 // from the test harness. | 331 // from the test harness. |
323 std::unique_ptr<media::VideoCaptureDeviceFactory> | 332 std::unique_ptr<media::VideoCaptureDeviceFactory> |
324 video_capture_device_factory_; | 333 video_capture_device_factory_; |
325 | 334 |
335 std::unique_ptr<media::VideoCaptureObserver> capture_observer_; | |
336 | |
326 // Local cache of the enumerated video capture devices' names and capture | 337 // Local cache of the enumerated video capture devices' names and capture |
327 // supported formats. A snapshot of the current devices and their capabilities | 338 // supported formats. A snapshot of the current devices and their capabilities |
328 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and | 339 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and |
329 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update | 340 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update |
330 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will | 341 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will |
331 // use this list if the device is not started, otherwise it will retrieve the | 342 // use this list if the device is not started, otherwise it will retrieve the |
332 // active device capture format from the VideoCaptureController associated. | 343 // active device capture format from the VideoCaptureController associated. |
333 DeviceInfos devices_info_cache_; | 344 DeviceInfos devices_info_cache_; |
334 | 345 |
335 // Map used by DesktopCapture. | 346 // Map used by DesktopCapture. |
336 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 347 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
337 notification_window_ids_; | 348 notification_window_ids_; |
338 | 349 |
339 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 350 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
340 }; | 351 }; |
341 | 352 |
342 } // namespace content | 353 } // namespace content |
343 | 354 |
344 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 355 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |