OLD | NEW |
| (Empty) |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_IN_PROCESS_BUILDABLE_VIDEO_CAPTURE_D
EVICE_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_IN_PROCESS_BUILDABLE_VIDEO_CAPTURE_D
EVICE_H_ | |
7 | |
8 #include "content/browser/renderer_host/media/video_capture_controller.h" | |
9 #include "content/browser/renderer_host/media/video_capture_provider.h" | |
10 #include "content/public/common/media_stream_request.h" | |
11 #include "media/capture/video/video_capture_device.h" | |
12 #include "media/capture/video/video_capture_device_client.h" | |
13 #include "media/capture/video/video_capture_device_descriptor.h" | |
14 #include "media/capture/video/video_capture_system.h" | |
15 | |
16 namespace content { | |
17 | |
18 // Implementation of BuildableVideoCaptureDevice that creates capture devices | |
19 // in the same process as it is being operated on, which must be the Browser | |
20 // process. The devices are operated on the given |device_task_runner|. | |
21 // Instances of this class must be operated from the Browser process IO thread. | |
22 class InProcessBuildableVideoCaptureDevice | |
23 : public BuildableVideoCaptureDevice { | |
24 public: | |
25 InProcessBuildableVideoCaptureDevice( | |
26 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner, | |
27 media::VideoCaptureSystem* video_capture_system); | |
28 ~InProcessBuildableVideoCaptureDevice() override; | |
29 | |
30 // BuildableVideoCaptureDevice implementation: | |
31 void CreateAndStartDeviceAsync(VideoCaptureController* controller, | |
32 const media::VideoCaptureParams& params, | |
33 Callbacks* callbacks, | |
34 base::OnceClosure done_cb) override; | |
35 void ReleaseDeviceAsync(VideoCaptureController* controller, | |
36 base::OnceClosure done_cb) override; | |
37 bool IsDeviceAlive() const override; | |
38 void GetPhotoCapabilities( | |
39 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) | |
40 const override; | |
41 void SetPhotoOptions( | |
42 media::mojom::PhotoSettingsPtr settings, | |
43 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) override; | |
44 void TakePhoto( | |
45 media::VideoCaptureDevice::TakePhotoCallback callback) override; | |
46 void MaybeSuspendDevice() override; | |
47 void ResumeDevice() override; | |
48 void RequestRefreshFrame() override; | |
49 | |
50 void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id, | |
51 base::OnceClosure done_cb) override; | |
52 | |
53 private: | |
54 using ReceiveDeviceCallback = | |
55 base::Callback<void(std::unique_ptr<media::VideoCaptureDevice> device)>; | |
56 | |
57 enum class State { | |
58 NO_DEVICE, | |
59 DEVICE_START_IN_PROGRESS, | |
60 DEVICE_START_ABORTING, | |
61 DEVICE_STARTED | |
62 }; | |
63 | |
64 std::unique_ptr<media::VideoCaptureDeviceClient> CreateDeviceClient( | |
65 int buffer_pool_max_buffer_count, | |
66 base::WeakPtr<media::VideoFrameReceiver> receiver); | |
67 | |
68 void OnDeviceStarted(VideoCaptureController* controller, | |
69 Callbacks* callbacks, | |
70 base::OnceClosure done_cb, | |
71 std::unique_ptr<media::VideoCaptureDevice> device); | |
72 | |
73 void DoStartDeviceCaptureOnDeviceThread( | |
74 const std::string& device_id, | |
75 const media::VideoCaptureParams& params, | |
76 std::unique_ptr<media::VideoCaptureDeviceClient> client, | |
77 ReceiveDeviceCallback result_callback); | |
78 | |
79 void DoStartTabCaptureOnDeviceThread( | |
80 const std::string& device_id, | |
81 const media::VideoCaptureParams& params, | |
82 std::unique_ptr<media::VideoCaptureDeviceClient> client, | |
83 ReceiveDeviceCallback result_callback); | |
84 | |
85 void DoStartDesktopCaptureOnDeviceThread( | |
86 const std::string& device_id, | |
87 const media::VideoCaptureParams& params, | |
88 std::unique_ptr<media::VideoCaptureDeviceClient> client, | |
89 ReceiveDeviceCallback result_callback); | |
90 | |
91 void SetDesktopCaptureWindowIdOnDeviceThread( | |
92 media::VideoCaptureDevice* device, | |
93 gfx::NativeViewId window_id, | |
94 base::OnceClosure done_cb); | |
95 | |
96 const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | |
97 media::VideoCaptureSystem* const video_capture_system_; | |
98 std::unique_ptr<media::VideoCaptureDevice> device_; | |
99 State state_ = State::NO_DEVICE; | |
100 }; | |
101 | |
102 } // namespace content | |
103 | |
104 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_IN_PROCESS_BUILDABLE_VIDEO_CAPTUR
E_DEVICE_H_ | |
OLD | NEW |