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_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "base/timer/elapsed_timer.h" | 20 #include "base/timer/elapsed_timer.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "content/browser/renderer_host/media/media_stream_provider.h" | 22 #include "content/browser/renderer_host/media/media_stream_provider.h" |
23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
| 24 #include "content/browser/renderer_host/media/video_capture_device_launch_observ
er.h" |
24 #include "content/browser/renderer_host/media/video_capture_provider.h" | 25 #include "content/browser/renderer_host/media/video_capture_provider.h" |
25 #include "content/common/content_export.h" | 26 #include "content/common/content_export.h" |
26 #include "content/common/media/media_stream_options.h" | 27 #include "content/common/media/media_stream_options.h" |
27 #include "media/base/video_facing.h" | 28 #include "media/base/video_facing.h" |
28 #include "media/capture/video/video_capture_device.h" | 29 #include "media/capture/video/video_capture_device.h" |
29 #include "media/capture/video/video_capture_device_info.h" | 30 #include "media/capture/video/video_capture_device_info.h" |
30 #include "media/capture/video_capture_types.h" | 31 #include "media/capture/video_capture_types.h" |
31 | 32 |
32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
33 #include "base/android/application_status_listener.h" | 34 #include "base/android/application_status_listener.h" |
34 #endif | 35 #endif |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 class VideoCaptureController; | 38 class VideoCaptureController; |
38 class VideoCaptureControllerEventHandler; | 39 class VideoCaptureControllerEventHandler; |
39 | 40 |
40 // VideoCaptureManager is used to open/close, start/stop, enumerate available | 41 // VideoCaptureManager is used to open/close, start/stop, enumerate available |
41 // video capture devices, and manage VideoCaptureController's. | 42 // video capture devices, and manage VideoCaptureController's. |
42 // In its main usage in production, an instance is created by MediaStreamManager | 43 // In its main usage in production, an instance is created by MediaStreamManager |
43 // on the Browser::IO thread. All public methods are expected to be called from | 44 // on the Browser::IO thread. All public methods are expected to be called from |
44 // the Browser::IO thread. A device can only be opened once. | 45 // the Browser::IO thread. A device can only be opened once. |
45 class CONTENT_EXPORT VideoCaptureManager | 46 class CONTENT_EXPORT VideoCaptureManager |
46 : public MediaStreamProvider, | 47 : public MediaStreamProvider, |
47 public BuildableVideoCaptureDevice::Callbacks { | 48 public VideoCaptureDeviceLaunchObserver { |
48 public: | 49 public: |
49 using VideoCaptureDevice = media::VideoCaptureDevice; | 50 using VideoCaptureDevice = media::VideoCaptureDevice; |
50 | 51 |
51 // Callback used to signal the completion of a controller lookup. | 52 // Callback used to signal the completion of a controller lookup. |
52 using DoneCB = | 53 using DoneCB = |
53 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>; | 54 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>; |
54 | 55 |
55 explicit VideoCaptureManager( | 56 explicit VideoCaptureManager( |
56 std::unique_ptr<VideoCaptureProvider> video_capture_provider); | 57 std::unique_ptr<VideoCaptureProvider> video_capture_provider); |
57 | 58 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // is hidden, see http://crbug.com/582295. | 173 // is hidden, see http://crbug.com/582295. |
173 void OnApplicationStateChange(base::android::ApplicationState state); | 174 void OnApplicationStateChange(base::android::ApplicationState state); |
174 #endif | 175 #endif |
175 | 176 |
176 using EnumerationCallback = | 177 using EnumerationCallback = |
177 base::Callback<void(const media::VideoCaptureDeviceDescriptors&)>; | 178 base::Callback<void(const media::VideoCaptureDeviceDescriptors&)>; |
178 // Asynchronously obtains descriptors for the available devices. | 179 // Asynchronously obtains descriptors for the available devices. |
179 // As a side-effect, updates |devices_info_cache_|. | 180 // As a side-effect, updates |devices_info_cache_|. |
180 void EnumerateDevices(const EnumerationCallback& client_callback); | 181 void EnumerateDevices(const EnumerationCallback& client_callback); |
181 | 182 |
182 // Implementation of BuildableVideoCaptureDevice::Callbacks: | 183 // VideoCaptureDeviceLaunchObserver implementation: |
183 void OnDeviceStarted(VideoCaptureController* controller) override; | 184 void OnDeviceLaunched(VideoCaptureController* controller) override; |
184 void OnDeviceStartFailed(VideoCaptureController* controller) override; | 185 void OnDeviceLaunchFailed(VideoCaptureController* controller) override; |
185 void OnDeviceStartAborted() override; | 186 void OnDeviceLaunchAborted() override; |
186 | 187 |
187 // Retrieves camera calibration information for a particular device. Returns | 188 // Retrieves camera calibration information for a particular device. Returns |
188 // nullopt_t if the |device_id| is not found or camera calibration information | 189 // nullopt_t if the |device_id| is not found or camera calibration information |
189 // is not available for the device. Camera calibration is cached during | 190 // is not available for the device. Camera calibration is cached during |
190 // device(s) enumeration. | 191 // device(s) enumeration. |
191 base::Optional<CameraCalibration> GetCameraCalibration( | 192 base::Optional<CameraCalibration> GetCameraCalibration( |
192 const std::string& device_id); | 193 const std::string& device_id); |
193 | 194 |
194 private: | 195 private: |
195 class CaptureDeviceStartRequest; | 196 class CaptureDeviceStartRequest; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // Map used by DesktopCapture. | 297 // Map used by DesktopCapture. |
297 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 298 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
298 notification_window_ids_; | 299 notification_window_ids_; |
299 | 300 |
300 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 301 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
301 }; | 302 }; |
302 | 303 |
303 } // namespace content | 304 } // namespace content |
304 | 305 |
305 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 306 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |