Chromium Code Reviews| Index: media/capture/video/linux/video_capture_device_chromeos.cc |
| diff --git a/media/capture/video/linux/video_capture_device_chromeos.cc b/media/capture/video/linux/video_capture_device_chromeos.cc |
| index 1e6006c734ab71b66f6353794a6f244571b424ae..6465e697285882502c1a44bf8a972017d4e1f911 100644 |
| --- a/media/capture/video/linux/video_capture_device_chromeos.cc |
| +++ b/media/capture/video/linux/video_capture_device_chromeos.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| +#include "media/capture/video/linux/v4l2_capture_delegate.h" |
| #include "ui/display/display.h" |
| #include "ui/display/display_observer.h" |
| #include "ui/display/screen.h" |
| @@ -99,12 +100,63 @@ VideoCaptureDeviceChromeOS::VideoCaptureDeviceChromeOS( |
| const VideoCaptureDeviceDescriptor& device_descriptor) |
| : VideoCaptureDeviceLinux(device_descriptor), |
| screen_observer_delegate_( |
| - new ScreenObserverDelegate(this, ui_task_runner)) {} |
| + new ScreenObserverDelegate(this, ui_task_runner)), |
| + lens_facing_(CameraDeviceInfo::UNINITIALIZED), |
| + camera_characteristics_(LAZY_INSTANCE_INITIALIZER) {} |
| VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { |
| screen_observer_delegate_->RemoveObserver(); |
| } |
| +void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { |
| + if (v4l2_thread_.IsRunning()) { |
| + if (lens_facing_ == CameraDeviceInfo::UNINITIALIZED) { |
| + camera_characteristics_.Get().InitializeDeviceInfo(); |
|
kcwu
2016/11/24 15:48:52
Will VideoCaptureDeviceChromeOS be created more th
shenghao
2016/11/28 08:52:04
Done.
|
| + lens_facing_ = camera_characteristics_.Get().GetCameraFacing( |
|
kcwu
2016/11/24 15:48:52
If there are two cameras starting capture at the s
kcwu
2016/11/28 05:48:43
FYI, http://stackoverflow.com/questions/5912539/st
shenghao
2016/11/28 08:52:04
Methods like find() can be called safely according
|
| + device_descriptor_.device_id, device_descriptor_.model_id); |
| + } |
| + // We assume external camera is facing the users. If not, the users can |
| + // rotate the camera manually by themselves. |
| + if (lens_facing_ == CameraDeviceInfo::LENS_FACING_BACK) { |
| + // Original frame when screen_rotation = 0 |
| + // ----------------------- |
| + // | * | |
| + // | * * | |
| + // | * * | |
| + // | ******* | |
| + // | * * | |
| + // | * * | |
| + // ----------------------- |
| + // |
| + // screen_rotation = 90, this is what back camera sees |
| + // ----------------------- |
| + // | ******** | |
| + // | * **** | |
| + // | * *** | |
| + // | * *** | |
| + // | * **** | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // screen_rotation = 90, this is what front camera sees |
|
kcwu
2016/11/24 15:48:52
270 ?
shenghao
2016/11/28 08:52:04
This is 90. We want to demonstrate the difference
|
| + // ----------------------- |
| + // | ******** | |
| + // | **** * | |
| + // | *** * | |
| + // | *** * | |
| + // | **** * | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // Therefore, for back camera, we need to rotate (360 - screen_rotation). |
| + rotation = (360 - rotation) % 360; |
| + } |
| + v4l2_thread_.task_runner()->PostTask( |
|
kcwu
2016/11/24 15:48:52
How about call
VideoCaptureDeviceLinux::SetRotatio
shenghao
2016/11/28 08:52:04
Done.
|
| + FROM_HERE, |
| + base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation)); |
| + } |
| +} |
| + |
| void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
| const display::Display& display) { |
| if (display.IsInternal()) |