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/public/common/media_stream_request.h" |
| 10 #include "media/capture/video/video_capture_device.h" |
| 11 #include "media/capture/video/video_capture_device_client.h" |
| 12 #include "media/capture/video/video_capture_device_descriptor.h" |
| 13 #include "media/capture/video/video_capture_device_factory.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // Implementation of BuildableVideoCaptureDevice that creates capture devices |
| 18 // in the same process as it is being operated on, which must be the Browser |
| 19 // process. The devices are operated on the given |device_task_runner|. |
| 20 // Instances of this class must be operated from the Browser process IO thread. |
| 21 class InProcessBuildableVideoCaptureDevice |
| 22 : public BuildableVideoCaptureDevice { |
| 23 public: |
| 24 InProcessBuildableVideoCaptureDevice( |
| 25 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner, |
| 26 media::VideoCaptureDeviceFactory* device_factory); |
| 27 ~InProcessBuildableVideoCaptureDevice() override; |
| 28 |
| 29 // BuildableVideoCaptureDevice implementation: |
| 30 void CreateAndStartDeviceAsync(VideoCaptureController* controller, |
| 31 const media::VideoCaptureParams& params, |
| 32 DeviceBuildContext context) override; |
| 33 void ReleaseDeviceAsync(VideoCaptureController* controller, |
| 34 base::OnceClosure done_cb) override; |
| 35 bool IsDeviceAlive() const override; |
| 36 void GetPhotoCapabilities( |
| 37 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) |
| 38 const override; |
| 39 void SetPhotoOptions( |
| 40 media::mojom::PhotoSettingsPtr settings, |
| 41 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) override; |
| 42 void TakePhoto( |
| 43 media::VideoCaptureDevice::TakePhotoCallback callback) override; |
| 44 void MaybeSuspendDevice() override; |
| 45 void ResumeDevice() override; |
| 46 void RequestRefreshFrame() override; |
| 47 |
| 48 void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id, |
| 49 base::OnceClosure done_cb) override; |
| 50 |
| 51 private: |
| 52 using ReceiveDeviceCallback = |
| 53 base::Callback<void(std::unique_ptr<media::VideoCaptureDevice> device)>; |
| 54 |
| 55 std::unique_ptr<media::VideoCaptureDeviceClient> CreateDeviceClient( |
| 56 int buffer_pool_max_buffer_count, |
| 57 base::WeakPtr<media::VideoFrameReceiver> receiver); |
| 58 |
| 59 void OnDeviceStarted(VideoCaptureController* controller, |
| 60 DeviceBuildContext context, |
| 61 std::unique_ptr<media::VideoCaptureDevice> device); |
| 62 |
| 63 void DoStartDeviceCaptureOnDeviceThread( |
| 64 const media::VideoCaptureDeviceDescriptor& descriptor, |
| 65 const media::VideoCaptureParams& params, |
| 66 std::unique_ptr<media::VideoCaptureDeviceClient> client, |
| 67 ReceiveDeviceCallback result_callback); |
| 68 |
| 69 void DoStartTabCaptureOnDeviceThread( |
| 70 const std::string& device_id, |
| 71 const media::VideoCaptureParams& params, |
| 72 std::unique_ptr<media::VideoCaptureDeviceClient> client, |
| 73 ReceiveDeviceCallback result_callback); |
| 74 |
| 75 void DoStartDesktopCaptureOnDeviceThread( |
| 76 const std::string& device_id, |
| 77 const media::VideoCaptureParams& params, |
| 78 std::unique_ptr<media::VideoCaptureDeviceClient> client, |
| 79 ReceiveDeviceCallback result_callback); |
| 80 |
| 81 void SetDesktopCaptureWindowIdOnDeviceThread( |
| 82 media::VideoCaptureDevice* device, |
| 83 gfx::NativeViewId window_id, |
| 84 base::OnceClosure done_cb); |
| 85 |
| 86 const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 87 media::VideoCaptureDeviceFactory* const device_factory_; |
| 88 std::unique_ptr<media::VideoCaptureDevice> device_; |
| 89 }; |
| 90 |
| 91 } // namespace content |
| 92 |
| 93 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_IN_PROCESS_BUILDABLE_VIDEO_CAPTUR
E_DEVICE_H_ |
OLD | NEW |