Chromium Code Reviews| Index: media/video/capture/linux/video_capture_device_linux.cc |
| diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc |
| index 6893743d5110db0f634b58820b69718cf55a5a1d..0b1b28a09ce03d11b81f03846462a852afa9933f 100644 |
| --- a/media/video/capture/linux/video_capture_device_linux.cc |
| +++ b/media/video/capture/linux/video_capture_device_linux.cc |
| @@ -22,6 +22,7 @@ |
| #include "base/files/scoped_file.h" |
| #include "base/posix/eintr_wrapper.h" |
| #include "base/strings/stringprintf.h" |
| +#include "ui/gfx/screen.h" |
| namespace media { |
| @@ -271,9 +272,22 @@ VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name) |
| v4l2_thread_("V4L2Thread"), |
| buffer_pool_(NULL), |
| buffer_pool_size_(0), |
| - timeout_count_(0) {} |
| + timeout_count_(0), |
| + display_rotation_(gfx::Display::ROTATE_0) { |
| + gfx::Screen* screen = |
|
perkj_chrome
2014/05/09 10:11:28
This will be called on a special thread used only
|
| + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
| + if (screen) { |
| + SetDisplayRotation(screen->GetPrimaryDisplay()); |
| + screen->AddObserver(this); |
| + } |
| +} |
| VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { |
| + gfx::Screen* screen = |
| + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
|
perkj_chrome
2014/05/09 10:11:28
Can there be a race here? ie, is it ok to not call
|
| + if (screen) |
| + screen->RemoveObserver(this); |
| + |
| state_ = kIdle; |
| // Check if the thread is running. |
| // This means that the device have not been DeAllocated properly. |
| @@ -313,6 +327,27 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() { |
| DeAllocateVideoBuffers(); |
| } |
| +void VideoCaptureDeviceLinux::OnDisplayBoundsChanged( |
| + const gfx::Display& display) { |
| + v4l2_thread_.message_loop()->PostTask( |
|
perkj_chrome
2014/05/09 10:11:28
This thread is started in AllocateAndStart. So you
perkj_chrome
2014/05/09 10:28:44
oh- btw - this need a thread check to make sure it
|
| + FROM_HERE, |
| + base::Bind(&VideoCaptureDeviceLinux::SetDisplayRotation, |
| + base::Unretained(this), display)); |
| +} |
| + |
| +void VideoCaptureDeviceLinux::OnDisplayAdded( |
| + const gfx::Display& /*new_display*/) {} |
| + |
| +void VideoCaptureDeviceLinux::OnDisplayRemoved( |
| + const gfx::Display& /*old_display*/) {} |
| + |
| +void VideoCaptureDeviceLinux::SetDisplayRotation(const gfx::Display& display) { |
| + DCHECK(!v4l2_thread_.IsRunning() || |
| + v4l2_thread_.message_loop() == base::MessageLoop::current()); |
| + if (display.IsInternal()) |
| + display_rotation_ = display.rotation(); |
|
perkj_chrome
2014/05/09 10:18:52
Add a todo and a comment that this will in fact ro
|
| +} |
| + |
| void VideoCaptureDeviceLinux::OnAllocateAndStart(int width, |
| int height, |
| int frame_rate, |
| @@ -521,7 +556,7 @@ void VideoCaptureDeviceLinux::OnCaptureTask() { |
| static_cast<uint8*>(buffer_pool_[buffer.index].start), |
| buffer.bytesused, |
| capture_format_, |
| - 0, |
| + display_rotation_ * 90, |
| base::TimeTicks::Now()); |
| // Enqueue the buffer again. |