| 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 MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_ARC_CHROMEOS_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_ARC_CHROMEOS_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/threading/thread.h" |
| 12 #include "media/capture/video/chromeos/display_rotation_observer.h" |
| 13 #include "media/capture/video/chromeos/mojo/arc_camera3.mojom.h" |
| 14 #include "media/capture/video/video_capture_device.h" |
| 15 #include "media/capture/video/video_capture_device_descriptor.h" |
| 16 #include "media/capture/video_capture_types.h" |
| 17 |
| 18 namespace display { |
| 19 |
| 20 class Display; |
| 21 |
| 22 } // namespace display |
| 23 |
| 24 namespace media { |
| 25 |
| 26 class CameraHalDelegate; |
| 27 class CameraDeviceDelegate; |
| 28 |
| 29 // Implementation of VideoCaptureDevice for ChromeOS with ARC++ camera HALv3. |
| 30 class CAPTURE_EXPORT VideoCaptureDeviceArcChromeOS final |
| 31 : public VideoCaptureDevice, |
| 32 public DisplayRotationObserver { |
| 33 public: |
| 34 VideoCaptureDeviceArcChromeOS( |
| 35 scoped_refptr<base::SingleThreadTaskRunner> |
| 36 task_runner_for_screen_observer, |
| 37 const VideoCaptureDeviceDescriptor& device_descriptor, |
| 38 scoped_refptr<CameraHalDelegate> camera_hal_delegate); |
| 39 |
| 40 ~VideoCaptureDeviceArcChromeOS() final; |
| 41 |
| 42 // VideoCaptureDevice implementation. |
| 43 void AllocateAndStart(const VideoCaptureParams& params, |
| 44 std::unique_ptr<Client> client) final; |
| 45 void StopAndDeAllocate() final; |
| 46 void TakePhoto(TakePhotoCallback callback) final; |
| 47 void GetPhotoState(GetPhotoStateCallback callback) final; |
| 48 void SetPhotoOptions(mojom::PhotoSettingsPtr settings, |
| 49 SetPhotoOptionsCallback callback) final; |
| 50 |
| 51 private: |
| 52 // DisplayRotationDelegate implementation. |
| 53 void SetDisplayRotation(const display::Display& display) final; |
| 54 void SetRotation(int rotation); |
| 55 |
| 56 const VideoCaptureDeviceDescriptor device_descriptor_; |
| 57 |
| 58 // A reference to the CameraHalDelegate instance in the VCD factory. This is |
| 59 // used by AllocateAndStart to query camera info and create the camera device. |
| 60 const scoped_refptr<CameraHalDelegate> camera_hal_delegate_; |
| 61 |
| 62 // A reference to the thread that all the VideoCaptureDevice interface methods |
| 63 // are expected to be called on. |
| 64 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 65 |
| 66 // The thread that all the Mojo operations of |camera_device_delegate_| take |
| 67 // place. Started in AllocateAndStart and stopped in StopAndDeAllocate, where |
| 68 // the access to the base::Thread methods are sequenced on |
| 69 // |capture_task_runner_|. |
| 70 base::Thread camera_device_ipc_thread_; |
| 71 |
| 72 // Internal delegate doing the actual capture setting, buffer allocation and |
| 73 // circulation with the camera HAL. Created in AllocateAndStart and deleted in |
| 74 // StopAndDeAllocate on |capture_task_runner_|. All methods of |
| 75 // |camera_device_delegate_| operate on |camera_device_ipc_thread_|. |
| 76 scoped_refptr<CameraDeviceDelegate> camera_device_delegate_; |
| 77 |
| 78 scoped_refptr<ScreenObserverDelegate> screen_observer_delegate_; |
| 79 const VideoFacingMode lens_facing_; |
| 80 const int camera_orientation_; |
| 81 // Whether the incoming frames should rotate when the device rotates. |
| 82 const bool rotates_with_device_; |
| 83 int rotation_; |
| 84 |
| 85 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceArcChromeOS); |
| 86 }; |
| 87 |
| 88 } // namespace media |
| 89 |
| 90 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_ARC_CHROMEOS_H_ |
| OLD | NEW |