| Index: media/video/capture/linux/video_capture_device_linux.cc
|
| ===================================================================
|
| --- media/video/capture/linux/video_capture_device_linux.cc (revision 271940)
|
| +++ media/video/capture/linux/video_capture_device_linux.cc (working copy)
|
| @@ -23,6 +23,10 @@
|
| #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 {
|
|
|
| // Max number of video buffers VideoCaptureDeviceLinux can allocate.
|
| @@ -248,8 +252,15 @@
|
| return usb_id;
|
| }
|
|
|
| -VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
|
| +VideoCaptureDevice* VideoCaptureDevice::Create(
|
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
| + const Name& device_name) {
|
| +#if defined(OS_CHROMEOS)
|
| + VideoCaptureDeviceChromeOS* self =
|
| + new VideoCaptureDeviceChromeOS(ui_task_runner, 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 +282,9 @@
|
| v4l2_thread_("V4L2Thread"),
|
| buffer_pool_(NULL),
|
| buffer_pool_size_(0),
|
| - timeout_count_(0) {}
|
| + timeout_count_(0),
|
| + rotation_(0) {
|
| +}
|
|
|
| VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() {
|
| state_ = kIdle;
|
| @@ -313,6 +326,25 @@
|
| 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_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0);
|
| + rotation_ = rotation;
|
| +}
|
| +
|
| void VideoCaptureDeviceLinux::OnAllocateAndStart(int width,
|
| int height,
|
| int frame_rate,
|
| @@ -521,7 +553,7 @@
|
| static_cast<uint8*>(buffer_pool_[buffer.index].start),
|
| buffer.bytesused,
|
| capture_format_,
|
| - 0,
|
| + rotation_,
|
| base::TimeTicks::Now());
|
|
|
| // Enqueue the buffer again.
|
|
|