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..4a3eb75b263f5161f2e47a0aa32d3e1812e38eb9 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) |
| @@ -38,7 +39,14 @@ std::list<uint32_t> VideoCaptureDeviceLinux::GetListOfUsableFourCCs( |
| VideoCaptureDeviceLinux::VideoCaptureDeviceLinux( |
| const VideoCaptureDeviceDescriptor& device_descriptor) |
| : v4l2_thread_("V4L2CaptureThread"), |
| - device_descriptor_(device_descriptor) {} |
| + device_descriptor_(device_descriptor), |
| + camera_characteristics_(LAZY_INSTANCE_INITIALIZER) { |
| + CameraCharacteristics characteristics; |
| + is_back_camera_ = |
|
kcwu
2016/11/24 10:16:08
Do you intent to have this in normal linux? If not
shenghao
2016/11/24 14:13:25
Done.
|
| + camera_characteristics_.Get().GetCameraFacing( |
|
kcwu
2016/11/24 10:16:08
per coding style, don't do non-trivial thing in ct
shenghao
2016/11/24 14:13:25
Done.
kcwu
2016/11/25 09:09:03
I found the style guide changed the suggestion. It
|
| + device_descriptor.model_id, device_descriptor.device_id) == |
| + CameraDeviceInfo::LENS_FACING_BACK; |
| +} |
| VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { |
| // Check if the thread is running. |
| @@ -113,6 +121,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 themselves. |
| + if (is_back_camera_) { |
| + // Original frame when screen_rotation = 0 |
| + // ----------------------- |
| + // | * | |
| + // | * * | |
| + // | * * | |
| + // | ******* | |
| + // | * * | |
| + // | * * | |
| + // ----------------------- |
| + // |
| + // 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)); |