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..40ad58cebb9ff7af7dfc96683a1fe5bea6610bb5 100644 |
| --- a/media/capture/video/linux/video_capture_device_chromeos.cc |
| +++ b/media/capture/video/linux/video_capture_device_chromeos.cc |
| @@ -7,6 +7,7 @@ |
| #include <stdint.h> |
| #include "base/bind.h" |
| +#include "base/lazy_instance.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/single_thread_task_runner.h" |
| @@ -17,6 +18,13 @@ |
| namespace media { |
| +namespace { |
| + |
| +base::LazyInstance<CameraFacingChromeOS>::Leaky g_camera_facing_ = |
| + 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)), |
| + kLensFacing( |
| + g_camera_facing_.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 (kLensFacing == CameraFacingChromeOS::LensFacing::BACK) { |
| + // Original frame when |rotation| = 0 |
| + // ----------------------- |
| + // | * | |
| + // | * * | |
| + // | * * | |
| + // | ******* | |
| + // | * * | |
| + // | * * | |
| + // ----------------------- |
| + // |
| + // |rotation| = 90, this is what back camera sees |
| + // ----------------------- |
| + // | ******** | |
| + // | * **** | |
| + // | * *** | |
| + // | * *** | |
| + // | * **** | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // |rotation| = 90, this is what front camera sees |
| + // ----------------------- |
| + // | ******** | |
| + // | **** * | |
| + // | *** * | |
| + // | *** * | |
| + // | **** * | |
| + // | ******** | |
| + // ----------------------- |
| + // |
| + // Therefore, for back camera, we need to rotate (360 - |rotation|). |
|
mcasas
2016/12/03 03:37:11
All this is to say that, same as Android, rotation
shenghao
2016/12/05 11:17:20
My team members were confused by why back camera s
|
| + rotation = (360 - rotation) % 360; |
| + } |
| + VideoCaptureDeviceLinux::SetRotation(rotation); |
| +} |
| + |
| void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
| const display::Display& display) { |
| if (display.IsInternal()) |