OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/video/capture/linux/video_capture_device_linux.h" | 5 #include "media/video/capture/linux/video_capture_device_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
10 #include <sys/videoio.h> | 10 #include <sys/videoio.h> |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 void VideoCaptureDeviceLinux::SetRotationOnV4L2Thread(int rotation) { | 199 void VideoCaptureDeviceLinux::SetRotationOnV4L2Thread(int rotation) { |
200 DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current()); | 200 DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current()); |
201 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); | 201 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); |
202 rotation_ = rotation; | 202 rotation_ = rotation; |
203 } | 203 } |
204 | 204 |
205 void VideoCaptureDeviceLinux::OnAllocateAndStart(int width, | 205 void VideoCaptureDeviceLinux::OnAllocateAndStart(int width, |
206 int height, | 206 int height, |
207 int frame_rate, | 207 float frame_rate, |
208 scoped_ptr<Client> client) { | 208 scoped_ptr<Client> client) { |
209 DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current()); | 209 DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current()); |
210 | 210 |
211 client_ = client.Pass(); | 211 client_ = client.Pass(); |
212 | 212 |
213 // Need to open camera with O_RDWR after Linux kernel 3.3. | 213 // Need to open camera with O_RDWR after Linux kernel 3.3. |
214 device_fd_.reset(HANDLE_EINTR(open(device_name_.id().c_str(), O_RDWR))); | 214 device_fd_.reset(HANDLE_EINTR(open(device_name_.id().c_str(), O_RDWR))); |
215 if (!device_fd_.is_valid()) { | 215 if (!device_fd_.is_valid()) { |
216 SetErrorState("Failed to open V4L2 device driver."); | 216 SetErrorState("Failed to open V4L2 device driver."); |
217 return; | 217 return; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 | 506 |
507 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { | 507 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { |
508 DCHECK(!v4l2_thread_.IsRunning() || | 508 DCHECK(!v4l2_thread_.IsRunning() || |
509 v4l2_thread_.message_loop() == base::MessageLoop::current()); | 509 v4l2_thread_.message_loop() == base::MessageLoop::current()); |
510 state_ = kError; | 510 state_ = kError; |
511 client_->OnError(reason); | 511 client_->OnError(reason); |
512 } | 512 } |
513 | 513 |
514 } // namespace media | 514 } // namespace media |
OLD | NEW |