| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/capture/video/linux/video_capture_device_chromeos.h" | 5 #include "media/capture/video/linux/video_capture_device_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 104 const VideoCaptureDeviceDescriptor& device_descriptor) | 104 const VideoCaptureDeviceDescriptor& device_descriptor) |
| 105 : VideoCaptureDeviceLinux(device_descriptor), | 105 : VideoCaptureDeviceLinux(device_descriptor), |
| 106 screen_observer_delegate_( | 106 screen_observer_delegate_( |
| 107 new ScreenObserverDelegate(this, ui_task_runner)), | 107 new ScreenObserverDelegate(this, ui_task_runner)), |
| 108 lens_facing_( | 108 lens_facing_( |
| 109 GetCameraConfig()->GetCameraFacing(device_descriptor.device_id, | 109 GetCameraConfig()->GetCameraFacing(device_descriptor.device_id, |
| 110 device_descriptor.model_id)), | 110 device_descriptor.model_id)), |
| 111 camera_orientation_( | 111 camera_orientation_( |
| 112 GetCameraConfig()->GetOrientation(device_descriptor.device_id, | 112 GetCameraConfig()->GetOrientation(device_descriptor.device_id, |
| 113 device_descriptor.model_id)) {} | 113 device_descriptor.model_id)), |
| 114 // External cameras have lens_facing as MEDIA_VIDEO_FACING_NONE. |
| 115 // We don't want to rotate the frame even if the device rotates. |
| 116 rotates_with_device_(lens_facing_ != |
| 117 VideoFacingMode::MEDIA_VIDEO_FACING_NONE) {} |
| 114 | 118 |
| 115 VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { | 119 VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { |
| 116 screen_observer_delegate_->RemoveObserver(); | 120 screen_observer_delegate_->RemoveObserver(); |
| 117 } | 121 } |
| 118 | 122 |
| 119 void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { | 123 void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { |
| 120 // We assume external camera is facing the users. If not, the users can | 124 if (!rotates_with_device_) { |
| 121 // rotate the camera manually by themselves. | 125 rotation = 0; |
| 122 if (lens_facing_ == VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT) { | 126 } else if (lens_facing_ == VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT) { |
| 123 // Original frame when |rotation| = 0 | 127 // Original frame when |rotation| = 0 |
| 124 // ----------------------- | 128 // ----------------------- |
| 125 // | * | | 129 // | * | |
| 126 // | * * | | 130 // | * * | |
| 127 // | * * | | 131 // | * * | |
| 128 // | ******* | | 132 // | ******* | |
| 129 // | * * | | 133 // | * * | |
| 130 // | * * | | 134 // | * * | |
| 131 // ----------------------- | 135 // ----------------------- |
| 132 // | 136 // |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 // | **** * | | 150 // | **** * | |
| 147 // | *** * | | 151 // | *** * | |
| 148 // | *** * | | 152 // | *** * | |
| 149 // | **** * | | 153 // | **** * | |
| 150 // | ******** | | 154 // | ******** | |
| 151 // ----------------------- | 155 // ----------------------- |
| 152 // | 156 // |
| 153 // Therefore, for back camera, we need to rotate (360 - |rotation|). | 157 // Therefore, for back camera, we need to rotate (360 - |rotation|). |
| 154 rotation = (360 - rotation) % 360; | 158 rotation = (360 - rotation) % 360; |
| 155 } | 159 } |
| 156 // Take into account camera orientation w.r.t. the display. | 160 // Take into account camera orientation w.r.t. the display. External cameras |
| 161 // would have camera_orientation_ as 0. |
| 157 rotation = (rotation + camera_orientation_) % 360; | 162 rotation = (rotation + camera_orientation_) % 360; |
| 158 VideoCaptureDeviceLinux::SetRotation(rotation); | 163 VideoCaptureDeviceLinux::SetRotation(rotation); |
| 159 } | 164 } |
| 160 | 165 |
| 161 void VideoCaptureDeviceChromeOS::SetDisplayRotation( | 166 void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
| 162 const display::Display& display) { | 167 const display::Display& display) { |
| 163 if (display.IsInternal()) | 168 if (display.IsInternal()) |
| 164 SetRotation(display.rotation() * 90); | 169 SetRotation(display.rotation() * 90); |
| 165 } | 170 } |
| 166 | 171 |
| 167 } // namespace media | 172 } // namespace media |
| OLD | NEW |