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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 500 } |
501 | 501 |
502 // Check if the driver have filled a buffer. | 502 // Check if the driver have filled a buffer. |
503 if (FD_ISSET(device_fd_, &r_set)) { | 503 if (FD_ISSET(device_fd_, &r_set)) { |
504 v4l2_buffer buffer; | 504 v4l2_buffer buffer; |
505 memset(&buffer, 0, sizeof(buffer)); | 505 memset(&buffer, 0, sizeof(buffer)); |
506 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 506 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
507 buffer.memory = V4L2_MEMORY_MMAP; | 507 buffer.memory = V4L2_MEMORY_MMAP; |
508 // Dequeue a buffer. | 508 // Dequeue a buffer. |
509 if (HANDLE_EINTR(ioctl(device_fd_, VIDIOC_DQBUF, &buffer)) == 0) { | 509 if (HANDLE_EINTR(ioctl(device_fd_, VIDIOC_DQBUF, &buffer)) == 0) { |
510 client_->OnIncomingCapturedFrame( | 510 client_->OnIncomingCapturedData( |
511 static_cast<uint8*>(buffer_pool_[buffer.index].start), | 511 static_cast<uint8*>(buffer_pool_[buffer.index].start), |
512 buffer.bytesused, | 512 buffer.bytesused, |
513 base::TimeTicks::Now(), | 513 capture_format_, |
514 0, | 514 0, |
515 capture_format_); | 515 base::TimeTicks::Now()); |
516 | 516 |
517 // Enqueue the buffer again. | 517 // Enqueue the buffer again. |
518 if (HANDLE_EINTR(ioctl(device_fd_, VIDIOC_QBUF, &buffer)) == -1) { | 518 if (HANDLE_EINTR(ioctl(device_fd_, VIDIOC_QBUF, &buffer)) == -1) { |
519 SetErrorState(base::StringPrintf( | 519 SetErrorState(base::StringPrintf( |
520 "Failed to enqueue capture buffer errno %d", errno)); | 520 "Failed to enqueue capture buffer errno %d", errno)); |
521 } | 521 } |
522 } else { | 522 } else { |
523 SetErrorState(base::StringPrintf( | 523 SetErrorState(base::StringPrintf( |
524 "Failed to dequeue capture buffer errno %d", errno)); | 524 "Failed to dequeue capture buffer errno %d", errno)); |
525 return; | 525 return; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 604 |
605 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { | 605 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { |
606 DCHECK(!v4l2_thread_.IsRunning() || | 606 DCHECK(!v4l2_thread_.IsRunning() || |
607 v4l2_thread_.message_loop() == base::MessageLoop::current()); | 607 v4l2_thread_.message_loop() == base::MessageLoop::current()); |
608 DVLOG(1) << reason; | 608 DVLOG(1) << reason; |
609 state_ = kError; | 609 state_ = kError; |
610 client_->OnError(reason); | 610 client_->OnError(reason); |
611 } | 611 } |
612 | 612 |
613 } // namespace media | 613 } // namespace media |
OLD | NEW |