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) |
tommi (sloooow) - chröme
2014/05/13 11:02:51
nit: we don't check the return value from new()
Zachary Kuznia
2014/05/13 13:54:29
Done.
|
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()); |
tommi (sloooow) - chröme
2014/05/13 11:02:51
BelongsToCurrentThread()?
Zachary Kuznia
2014/05/13 13:54:29
Done.
|
+ rotation_ = rotation; |
tommi (sloooow) - chröme
2014/05/13 11:02:51
DCHECK valid values of rotation?
Zachary Kuznia
2014/05/13 13:54:29
Done.
|
+} |
+ |
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. |