| 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..9ce0c17973fffcf0fd17ddac1cc9a97605b8b9f7 100644
|
| --- a/media/video/capture/linux/video_capture_device_linux.cc
|
| +++ b/media/video/capture/linux/video_capture_device_linux.cc
|
| @@ -22,6 +22,9 @@
|
| #include "base/files/scoped_file.h"
|
| #include "base/posix/eintr_wrapper.h"
|
| #include "base/strings/stringprintf.h"
|
| +#if defined(OS_CHROMEOS)
|
| +#include "media/video/capture/linux/video_capture_device_chromeos.h"
|
| +#endif
|
|
|
| namespace media {
|
|
|
| @@ -249,7 +252,12 @@ const std::string VideoCaptureDevice::Name::GetModel() const {
|
| }
|
|
|
| VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
|
| +#if defined(OS_CHROMEOS)
|
| + VideoCaptureDeviceChromeOS* self =
|
| + new VideoCaptureDeviceChromeOS(device_name);
|
| +#else
|
| VideoCaptureDeviceLinux* self = new VideoCaptureDeviceLinux(device_name);
|
| +#endif
|
| if (!self)
|
| return NULL;
|
| // Test opening the device driver. This is to make sure it is available.
|
| @@ -271,7 +279,9 @@ VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name)
|
| v4l2_thread_("V4L2Thread"),
|
| buffer_pool_(NULL),
|
| buffer_pool_size_(0),
|
| - timeout_count_(0) {}
|
| + timeout_count_(0),
|
| + rotation_(0) {
|
| +}
|
|
|
| VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() {
|
| state_ = kIdle;
|
| @@ -313,6 +323,25 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() {
|
| DeAllocateVideoBuffers();
|
| }
|
|
|
| +void VideoCaptureDeviceLinux::SetRotation(int rotation) {
|
| + if (v4l2_thread_.IsRunning()) {
|
| + v4l2_thread_.message_loop()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&VideoCaptureDeviceLinux::SetRotationOnV4L2Thread,
|
| + base::Unretained(this), rotation));
|
| + } else {
|
| + // If the |v4l2_thread_| is not running, there's no race condition and
|
| + // |rotation_| can be set directly.
|
| + rotation_ = rotation;
|
| + }
|
| +}
|
| +
|
| +void VideoCaptureDeviceLinux::SetRotationOnV4L2Thread(int rotation) {
|
| + DCHECK(v4l2_thread_.IsRunning() &&
|
| + v4l2_thread_.message_loop() == base::MessageLoop::current());
|
| + rotation_ = rotation;
|
| +}
|
| +
|
| void VideoCaptureDeviceLinux::OnAllocateAndStart(int width,
|
| int height,
|
| int frame_rate,
|
| @@ -521,7 +550,7 @@ void VideoCaptureDeviceLinux::OnCaptureTask() {
|
| static_cast<uint8*>(buffer_pool_[buffer.index].start),
|
| buffer.bytesused,
|
| capture_format_,
|
| - 0,
|
| + rotation_,
|
| base::TimeTicks::Now());
|
|
|
| // Enqueue the buffer again.
|
|
|