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/video/capture/linux/v4l2_capture_delegate.h" | 5 #include "media/video/capture/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> |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // Deenqueue, send and reenqueue a buffer if the driver has filled one in. | 392 // Deenqueue, send and reenqueue a buffer if the driver has filled one in. |
393 if (device_pfd.revents & POLLIN) { | 393 if (device_pfd.revents & POLLIN) { |
394 v4l2_buffer buffer; | 394 v4l2_buffer buffer; |
395 FillV4L2Buffer(&buffer, 0); | 395 FillV4L2Buffer(&buffer, 0); |
396 | 396 |
397 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) { | 397 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) { |
398 SetErrorState("Failed to dequeue capture buffer"); | 398 SetErrorState("Failed to dequeue capture buffer"); |
399 return; | 399 return; |
400 } | 400 } |
401 | 401 |
402 SendBuffer(buffer_tracker_pool_[buffer.index], video_fmt_); | 402 SendBuffer(buffer_tracker_pool_[buffer.index], video_fmt_, |
| 403 buffer.bytesused); |
403 | 404 |
404 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) { | 405 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) { |
405 SetErrorState("Failed to enqueue capture buffer"); | 406 SetErrorState("Failed to enqueue capture buffer"); |
406 return; | 407 return; |
407 } | 408 } |
408 } | 409 } |
409 | 410 |
410 v4l2_task_runner_->PostTask( | 411 v4l2_task_runner_->PostTask( |
411 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); | 412 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); |
412 } | 413 } |
413 | 414 |
414 void V4L2CaptureDelegate::SetErrorState(const std::string& reason) { | 415 void V4L2CaptureDelegate::SetErrorState(const std::string& reason) { |
415 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); | 416 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
416 is_capturing_ = false; | 417 is_capturing_ = false; |
417 client_->OnError(reason); | 418 client_->OnError(reason); |
418 } | 419 } |
419 | 420 |
420 } // namespace media | 421 } // namespace media |
OLD | NEW |