| 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/lazy_instance.h" | |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 13 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 16 #include "ui/display/display_observer.h" | 15 #include "ui/display/display_observer.h" |
| 17 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 18 | 17 |
| 19 namespace media { | 18 namespace media { |
| 20 | 19 |
| 21 namespace { | 20 static CameraConfigChromeOS* GetCameraConfig() { |
| 22 | 21 static CameraConfigChromeOS* config = new CameraConfigChromeOS(); |
| 23 base::LazyInstance<CameraConfigChromeOS>::Leaky g_camera_config_ = | 22 return config; |
| 24 LAZY_INSTANCE_INITIALIZER; | 23 } |
| 25 | |
| 26 } // namespace | |
| 27 | 24 |
| 28 // This is a delegate class used to transfer Display change events from the UI | 25 // This is a delegate class used to transfer Display change events from the UI |
| 29 // thread to the media thread. | 26 // thread to the media thread. |
| 30 class VideoCaptureDeviceChromeOS::ScreenObserverDelegate | 27 class VideoCaptureDeviceChromeOS::ScreenObserverDelegate |
| 31 : public display::DisplayObserver, | 28 : public display::DisplayObserver, |
| 32 public base::RefCountedThreadSafe<ScreenObserverDelegate> { | 29 public base::RefCountedThreadSafe<ScreenObserverDelegate> { |
| 33 public: | 30 public: |
| 34 ScreenObserverDelegate( | 31 ScreenObserverDelegate( |
| 35 VideoCaptureDeviceChromeOS* capture_device, | 32 VideoCaptureDeviceChromeOS* capture_device, |
| 36 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 33 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 DISALLOW_IMPLICIT_CONSTRUCTORS(ScreenObserverDelegate); | 99 DISALLOW_IMPLICIT_CONSTRUCTORS(ScreenObserverDelegate); |
| 103 }; | 100 }; |
| 104 | 101 |
| 105 VideoCaptureDeviceChromeOS::VideoCaptureDeviceChromeOS( | 102 VideoCaptureDeviceChromeOS::VideoCaptureDeviceChromeOS( |
| 106 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 107 const VideoCaptureDeviceDescriptor& device_descriptor) | 104 const VideoCaptureDeviceDescriptor& device_descriptor) |
| 108 : VideoCaptureDeviceLinux(device_descriptor), | 105 : VideoCaptureDeviceLinux(device_descriptor), |
| 109 screen_observer_delegate_( | 106 screen_observer_delegate_( |
| 110 new ScreenObserverDelegate(this, ui_task_runner)), | 107 new ScreenObserverDelegate(this, ui_task_runner)), |
| 111 lens_facing_( | 108 lens_facing_( |
| 112 g_camera_config_.Get().GetCameraFacing(device_descriptor.device_id, | 109 GetCameraConfig()->GetCameraFacing(device_descriptor.device_id, |
| 113 device_descriptor.model_id)), | 110 device_descriptor.model_id)), |
| 114 camera_orientation_( | 111 camera_orientation_( |
| 115 g_camera_config_.Get().GetOrientation(device_descriptor.device_id, | 112 GetCameraConfig()->GetOrientation(device_descriptor.device_id, |
| 116 device_descriptor.model_id)) {} | 113 device_descriptor.model_id)) {} |
| 117 | 114 |
| 118 VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { | 115 VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() { |
| 119 screen_observer_delegate_->RemoveObserver(); | 116 screen_observer_delegate_->RemoveObserver(); |
| 120 } | 117 } |
| 121 | 118 |
| 122 void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { | 119 void VideoCaptureDeviceChromeOS::SetRotation(int rotation) { |
| 123 // We assume external camera is facing the users. If not, the users can | 120 // We assume external camera is facing the users. If not, the users can |
| 124 // rotate the camera manually by themselves. | 121 // rotate the camera manually by themselves. |
| 125 if (lens_facing_ == VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT) { | 122 if (lens_facing_ == VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT) { |
| 126 // Original frame when |rotation| = 0 | 123 // Original frame when |rotation| = 0 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 VideoCaptureDeviceLinux::SetRotation(rotation); | 158 VideoCaptureDeviceLinux::SetRotation(rotation); |
| 162 } | 159 } |
| 163 | 160 |
| 164 void VideoCaptureDeviceChromeOS::SetDisplayRotation( | 161 void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
| 165 const display::Display& display) { | 162 const display::Display& display) { |
| 166 if (display.IsInternal()) | 163 if (display.IsInternal()) |
| 167 SetRotation(display.rotation() * 90); | 164 SetRotation(display.rotation() * 90); |
| 168 } | 165 } |
| 169 | 166 |
| 170 } // namespace media | 167 } // namespace media |
| OLD | NEW |