Chromium Code Reviews| Index: media/capture/video/chromeos/video_capture_device_arc_chromeos.h |
| diff --git a/media/capture/video/chromeos/video_capture_device_arc_chromeos.h b/media/capture/video/chromeos/video_capture_device_arc_chromeos.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff9a49c4c56e4382408d2531d13e73480426deb0 |
| --- /dev/null |
| +++ b/media/capture/video/chromeos/video_capture_device_arc_chromeos.h |
| @@ -0,0 +1,133 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// blah blah blah... |
|
wuchengli
2017/04/28 06:29:28
Update this.
jcliang
2017/04/28 08:27:49
Removed.
|
| + |
| +#ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_ |
| +#define MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/threading/thread.h" |
| +#include "media/capture/video/chromeos/mojo/arc_camera3.mojom.h" |
| +#include "media/capture/video/video_capture_device.h" |
| +#include "media/capture/video/video_capture_device_descriptor.h" |
| +#include "media/capture/video_capture_types.h" |
| + |
| +namespace display { |
| + |
| +class Display; |
| + |
| +} // namespace display |
| + |
| +namespace media { |
| + |
| +class CameraHalDelegate; |
| +class CameraDeviceDelegate; |
| + |
| +// Implementation of VideoCaptureDevice for ChromeOS with ARC++ camera HALv3. |
| +class CAPTURE_EXPORT VideoCaptureDeviceArcChromeOS final |
| + : public VideoCaptureDevice { |
| + public: |
| + // Converts the HAL pixel format |from| to Chromium pixel format. Returns |
| + // PIXEL_FORMAT_UNKNOWN if |from| is not supported. |
| + static VideoPixelFormat PixFormatHalToChromium( |
| + arc::mojom::HalPixelFormat from); |
| + |
| + // Converts the Chromium pixel format |from| to DRM pixel format. Returns 0 |
| + // if |from| is not supported. |
| + static uint32_t PixFormatChromiumToDrm(VideoPixelFormat from); |
| + |
| + VideoCaptureDeviceArcChromeOS( |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| + const VideoCaptureDeviceDescriptor& device_descriptor, |
| + scoped_refptr<CameraHalDelegate> camera_hal_delegate); |
| + |
| + ~VideoCaptureDeviceArcChromeOS() final; |
| + |
| + // VideoCaptureDevice implementation. |
| + void AllocateAndStart(const VideoCaptureParams& params, |
| + std::unique_ptr<Client> client) final; |
| + void StopAndDeAllocate() final; |
| + void TakePhoto(TakePhotoCallback callback) final; |
| + void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) final; |
| + void SetPhotoOptions(mojom::PhotoSettingsPtr settings, |
| + SetPhotoOptionsCallback callback) final; |
| + |
| + private: |
| + // Internal methods which AllocateAndStart depends on to create a camera |
| + // device. OnGotCameraInfo and OnOpenDevice are callbacks provided to the |
| + // |camera_hal_delegate_| Mojo IPC calls, and are run on the |
| + // |module_task_runner_| of |camera_hal_delegate_|. |
| + void OnGotCameraInfo(const VideoCaptureParams& params, |
| + std::unique_ptr<Client> client, |
| + int32_t result, |
| + arc::mojom::CameraInfoPtr camera_info); |
| + void OnOpenedDevice(const VideoCaptureParams& params, |
| + std::unique_ptr<Client> client, |
| + arc::mojom::CameraMetadataPtr static_metadata, |
| + int32_t result, |
| + arc::mojom::Camera3DeviceOpsPtr device_ops); |
| + |
| + // CreateDeviceOnCaptureThread creates the CameraDeviceDelegate instance and |
| + // assigns to |camera_device_delegate_|. This method runs on |
| + // |capture_task_runner_| to make sure the access to |camera_device_delegate_| |
| + // and |device_thread_| is sequenced. |
| + void CreateDeviceOnCaptureThread( |
| + const VideoCaptureParams& params, |
| + std::unique_ptr<Client> client, |
| + arc::mojom::CameraMetadataPtr static_metadata, |
| + int32_t result, |
| + mojo::InterfacePtrInfo<arc::mojom::Camera3DeviceOps> device_ops_info); |
| + |
| + const VideoCaptureDeviceDescriptor device_descriptor_; |
| + |
| + // A reference to the CameraHalDelegate instance in the VCD factory. This is |
| + // used by AllocateAndStart to query camera info and create the camera device. |
| + const scoped_refptr<CameraHalDelegate> camera_hal_delegate_; |
| + |
| + // A reference to the thread that all the VideoCaptureDevice interface methods |
| + // are called. |
| + const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| + |
| + // The thread that all the Mojo operations of |camera_device_delegate_| take |
| + // place. Started in CreateDeviceOnCaptureThread and stopped in |
| + // StopAndDeAllocate, where the access to the base::Thread methods are |
| + // sequenced on |capture_task_runner_|. |
| + base::Thread device_thread_; |
| + |
| + // Variable indicating whether VideoCaptureDevice instance is being stopped. |
| + // We need |stopping_| to ensure correct behavior because AllocateAndStart is |
| + // asynchronous and StopAndDeAllocate may be called between when |
| + // AllocateAndStart is called and when |camera_device_delegate_| is actually |
| + // created. |stopping_| must only be accessed on |capture_task_runner_|. |
| + bool stopping_; |
| + |
| + // Internal delegate doing the actual capture setting, buffer allocation and |
| + // circulation with the camera HAL. Created and deleted in the thread where |
| + // VideoCaptureDeviceArcChromeOS lives, but otherwise operates on |
| + // |device_thread_|. |
| + scoped_refptr<CameraDeviceDelegate> camera_device_delegate_; |
| + |
| + class ScreenObserverDelegate; |
| + |
| + void SetRotation(int rotation); |
| + void SetDisplayRotation(const display::Display& display); |
| + |
| + scoped_refptr<ScreenObserverDelegate> screen_observer_delegate_; |
| + const VideoFacingMode lens_facing_; |
| + const int camera_orientation_; |
| + // Whether the incoming frames should rotate when the device rotates. |
| + const bool rotates_with_device_; |
| + |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceArcChromeOS); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_ |