OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/capture/video/linux/v4l2_capture_delegate.h" | 5 #include "media/capture/video/linux/v4l2_capture_delegate.h" |
6 | 6 |
7 #include <poll.h> | 7 #include <poll.h> |
8 #include <sys/fcntl.h> | 8 #include <sys/fcntl.h> |
9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| 11 #include <utility> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
14 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
18 #include "media/capture/video/linux/v4l2_capture_delegate_multi_plane.h" | 19 #include "media/capture/video/linux/v4l2_capture_delegate_multi_plane.h" |
19 #include "media/capture/video/linux/v4l2_capture_delegate_single_plane.h" | 20 #include "media/capture/video/linux/v4l2_capture_delegate_single_plane.h" |
20 #include "media/capture/video/linux/video_capture_device_linux.h" | 21 #include "media/capture/video/linux/video_capture_device_linux.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 V4L2CaptureDelegate::~V4L2CaptureDelegate() { | 170 V4L2CaptureDelegate::~V4L2CaptureDelegate() { |
170 } | 171 } |
171 | 172 |
172 void V4L2CaptureDelegate::AllocateAndStart( | 173 void V4L2CaptureDelegate::AllocateAndStart( |
173 int width, | 174 int width, |
174 int height, | 175 int height, |
175 float frame_rate, | 176 float frame_rate, |
176 scoped_ptr<VideoCaptureDevice::Client> client) { | 177 scoped_ptr<VideoCaptureDevice::Client> client) { |
177 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); | 178 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
178 DCHECK(client); | 179 DCHECK(client); |
179 client_ = client.Pass(); | 180 client_ = std::move(client); |
180 | 181 |
181 // Need to open camera with O_RDWR after Linux kernel 3.3. | 182 // Need to open camera with O_RDWR after Linux kernel 3.3. |
182 device_fd_.reset(HANDLE_EINTR(open(device_name_.id().c_str(), O_RDWR))); | 183 device_fd_.reset(HANDLE_EINTR(open(device_name_.id().c_str(), O_RDWR))); |
183 if (!device_fd_.is_valid()) { | 184 if (!device_fd_.is_valid()) { |
184 SetErrorState(FROM_HERE, "Failed to open V4L2 device driver file."); | 185 SetErrorState(FROM_HERE, "Failed to open V4L2 device driver file."); |
185 return; | 186 return; |
186 } | 187 } |
187 | 188 |
188 v4l2_capability cap = {}; | 189 v4l2_capability cap = {}; |
189 if (!((HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QUERYCAP, &cap)) == 0) && | 190 if (!((HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QUERYCAP, &cap)) == 0) && |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 421 |
421 void V4L2CaptureDelegate::SetErrorState( | 422 void V4L2CaptureDelegate::SetErrorState( |
422 const tracked_objects::Location& from_here, | 423 const tracked_objects::Location& from_here, |
423 const std::string& reason) { | 424 const std::string& reason) { |
424 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); | 425 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
425 is_capturing_ = false; | 426 is_capturing_ = false; |
426 client_->OnError(from_here, reason); | 427 client_->OnError(from_here, reason); |
427 } | 428 } |
428 | 429 |
429 } // namespace media | 430 } // namespace media |
OLD | NEW |