Chromium Code Reviews| Index: media/capture/video/linux/video_capture_device_linux.cc |
| diff --git a/media/capture/video/linux/video_capture_device_linux.cc b/media/capture/video/linux/video_capture_device_linux.cc |
| index a1b2855055e853b5e1d9210f5da139f8740ef7ec..f1987f704eb21e46d5cd3f2db1e62b2014b17550 100644 |
| --- a/media/capture/video/linux/video_capture_device_linux.cc |
| +++ b/media/capture/video/linux/video_capture_device_linux.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bind.h" |
| #include "base/single_thread_task_runner.h" |
| #include "build/build_config.h" |
| +#include "media/capture/video/linux/camera_characteristics.h" |
| #include "media/capture/video/linux/v4l2_capture_delegate.h" |
| #if defined(OS_OPENBSD) |
| @@ -37,8 +38,12 @@ std::list<uint32_t> VideoCaptureDeviceLinux::GetListOfUsableFourCCs( |
| VideoCaptureDeviceLinux::VideoCaptureDeviceLinux( |
| const VideoCaptureDeviceDescriptor& device_descriptor) |
| - : v4l2_thread_("V4L2CaptureThread"), |
| - device_descriptor_(device_descriptor) {} |
| + : v4l2_thread_("V4L2CaptureThread"), device_descriptor_(device_descriptor) { |
| + CameraCharacteristics characteristics; |
|
wuchengli
2016/11/22 07:59:34
base::LazyInstance<CameraCharacteristics> g_camera
shenghao
2016/11/24 07:13:04
Done.
|
| + is_back_camera_ = |
| + characteristics.GetCameraFacing(device_descriptor.model_id) == |
| + DeviceInfo::LENS_FACING_BACK; |
| +} |
| VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { |
| // Check if the thread is running. |
| @@ -113,6 +118,42 @@ void VideoCaptureDeviceLinux::SetPhotoOptions( |
| void VideoCaptureDeviceLinux::SetRotation(int rotation) { |
| if (v4l2_thread_.IsRunning()) { |
| + // We assume external camera is facing the users. If not, the users can |
| + // rotate the camera manually by theirselves. |
|
wuchengli
2016/11/22 03:47:06
s/theirselves/themselves/
shenghao
2016/11/24 07:13:04
Done.
|
| + if (is_back_camera_) { |
| + // Original frame when screen_rotation = 0 |
| + // ----------------------- |
| + // | | |
| + // | * | |
| + // | * * | |
| + // | ***** | |
|
wuchengli
2016/11/22 03:47:06
Great diagram! Can you make the A of the first one
shenghao
2016/11/24 07:13:04
Done.
|
| + // | * * | |
| + // | | |
| + // ----------------------- |
| + // |
| + // screen_rotation = 90, this is what back camera sees |
| + // ----------------------- |
| + // | ******** | |
| + // | * **** | |
| + // | * *** | |
| + // | * *** | |
| + // | * **** | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // screen_rotation = 90, this is what front camera sees |
| + // ----------------------- |
| + // | ******** | |
| + // | **** * | |
| + // | *** * | |
| + // | *** * | |
| + // | **** * | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // Therefore, for back camera, we need to rotate (360 - screen_rotation). |
| + rotation = (360 - rotation) % 360; |
| + } |
| v4l2_thread_.task_runner()->PostTask( |
| FROM_HERE, |
| base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation)); |