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..2322fe7677328aba55f3d658141ef36b50a9eabe 100644 |
| --- a/media/capture/video/linux/video_capture_device_chromeos.cc |
| +++ b/media/capture/video/linux/video_capture_device_chromeos.cc |
| @@ -11,12 +11,20 @@ |
| #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" |
|
kcwu
2016/11/28 10:11:37
unused?
shenghao
2016/11/29 10:22:27
Done.
|
| #include "ui/display/display.h" |
| #include "ui/display/display_observer.h" |
| #include "ui/display/screen.h" |
| namespace media { |
| +namespace { |
| + |
| +base::LazyInstance<CameraCharacteristics> g_camera_characteristics_ = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| // This is a delegate class used to transfer Display change events from the UI |
| // thread to the media thread. |
| class VideoCaptureDeviceChromeOS::ScreenObserverDelegate |
| @@ -99,12 +107,55 @@ 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_(g_camera_characteristics_.Get().GetCameraFacing( |
| + device_descriptor.device_id, |
| + device_descriptor.model_id)) {} |
| VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { |
| screen_observer_delegate_->RemoveObserver(); |
| } |
| +void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { |
| + // We assume external camera is facing the users. If not, the users can |
| + // rotate the camera manually by themselves. |
| + if (lens_facing_ == CameraDeviceInfo::LensFacing::kFacingBack) { |
| + // 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; |
| + } |
| + VideoCaptureDeviceLinux::SetRotation(rotation); |
| +} |
| + |
| void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
| const display::Display& display) { |
| if (display.IsInternal()) |