OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_device_entry.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_device_factory.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::VideoCaptureDeviceFactory* device_factory); |
| 28 ~InProcessBuildableVideoCaptureDevice() override; |
| 29 |
| 30 // DeviceEntryBuilder implementation: |
| 31 void CreateAndStartDeviceAsync( |
| 32 VideoCaptureDeviceEntry* entry, |
| 33 VideoCaptureController* controller, |
| 34 const media::VideoCaptureParams& params, |
| 35 BuildableDeviceCallbacks* callbacks, |
| 36 std::unique_ptr<Ownership> context_reference) override; |
| 37 void ReleaseDeviceAsync( |
| 38 VideoCaptureController* controller, |
| 39 std::unique_ptr<Ownership> context_reference) override; |
| 40 bool HasDevice() const override; |
| 41 void GetPhotoCapabilities( |
| 42 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) |
| 43 const override; |
| 44 void SetPhotoOptions( |
| 45 media::mojom::PhotoSettingsPtr settings, |
| 46 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) override; |
| 47 void TakePhoto( |
| 48 media::VideoCaptureDevice::TakePhotoCallback callback) override; |
| 49 void MaybeSuspendDevice() override; |
| 50 void ResumeDevice() override; |
| 51 void RequestRefreshFrame() override; |
| 52 |
| 53 void SetDesktopCaptureWindowIdAsync( |
| 54 gfx::NativeViewId window_id, |
| 55 std::unique_ptr<Ownership> context_reference) override; |
| 56 |
| 57 private: |
| 58 using ReceiveDeviceCallback = |
| 59 base::Callback<void(std::unique_ptr<media::VideoCaptureDevice> device)>; |
| 60 |
| 61 bool IsOnDeviceThread() const; |
| 62 |
| 63 std::unique_ptr<media::VideoCaptureDeviceClient> CreateDeviceClient( |
| 64 int buffer_pool_max_buffer_count, |
| 65 base::WeakPtr<media::VideoFrameReceiver> receiver); |
| 66 |
| 67 void OnDeviceStarted(VideoCaptureDeviceEntry* entry, |
| 68 VideoCaptureController* controller, |
| 69 BuildableDeviceCallbacks* callbacks, |
| 70 std::unique_ptr<Ownership> ownership, |
| 71 std::unique_ptr<media::VideoCaptureDevice> device); |
| 72 |
| 73 void DoStartDeviceCaptureOnDeviceThread( |
| 74 const media::VideoCaptureDeviceDescriptor& descriptor, |
| 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 std::unique_ptr<Ownership> ownership); |
| 95 |
| 96 void ReleaseDeviceAsyncNonVirtual(); |
| 97 |
| 98 const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 99 media::VideoCaptureDeviceFactory* const device_factory_; |
| 100 std::unique_ptr<media::VideoCaptureDevice> device_; |
| 101 }; |
| 102 |
| 103 } // namespace content |
| 104 |
| 105 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_IN_PROCESS_BUILDABLE_VIDEO_CAPTUR
E_DEVICE_H_ |
OLD | NEW |