Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 48113011: Remove media::VideoFrame from media::VideoCaptureDevice::Client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: ffdbaeb83 Trybot failures. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 402 }
403 DVLOG(2) << "Actual camera driverframerate: " 403 DVLOG(2) << "Actual camera driverframerate: "
404 << streamparm.parm.capture.timeperframe.denominator << "/" 404 << streamparm.parm.capture.timeperframe.denominator << "/"
405 << streamparm.parm.capture.timeperframe.numerator; 405 << streamparm.parm.capture.timeperframe.numerator;
406 } 406 }
407 } 407 }
408 // TODO(mcasas): what should be done if the camera driver does not allow 408 // TODO(mcasas): what should be done if the camera driver does not allow
409 // framerate configuration, or the actual one is different from the desired? 409 // framerate configuration, or the actual one is different from the desired?
410 410
411 // Store our current width and height. 411 // Store our current width and height.
412 frame_info_.color = V4l2ColorToVideoCaptureColorFormat( 412 frame_info_.color =
413 video_fmt.fmt.pix.pixelformat); 413 V4l2ColorToVideoCaptureColorFormat(video_fmt.fmt.pix.pixelformat);
414 frame_info_.width = video_fmt.fmt.pix.width; 414 frame_info_.width = video_fmt.fmt.pix.width;
415 frame_info_.height = video_fmt.fmt.pix.height; 415 frame_info_.height = video_fmt.fmt.pix.height;
416 frame_info_.frame_rate = frame_rate; 416 frame_info_.frame_rate = frame_rate;
417 frame_info_.frame_size_type = VariableResolutionVideoCaptureDevice; 417 frame_info_.frame_size_type = VariableResolutionVideoCaptureDevice;
418 418
419 // Start capturing. 419 // Start capturing.
420 if (!AllocateVideoBuffers()) { 420 if (!AllocateVideoBuffers()) {
421 // Error, We can not recover. 421 // Error, We can not recover.
422 SetErrorState("Allocate buffer failed"); 422 SetErrorState("Allocate buffer failed");
423 return; 423 return;
424 } 424 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 // Check if the driver have filled a buffer. 507 // Check if the driver have filled a buffer.
508 if (FD_ISSET(device_fd_, &r_set)) { 508 if (FD_ISSET(device_fd_, &r_set)) {
509 v4l2_buffer buffer; 509 v4l2_buffer buffer;
510 memset(&buffer, 0, sizeof(buffer)); 510 memset(&buffer, 0, sizeof(buffer));
511 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 511 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
512 buffer.memory = V4L2_MEMORY_MMAP; 512 buffer.memory = V4L2_MEMORY_MMAP;
513 // Dequeue a buffer. 513 // Dequeue a buffer.
514 if (ioctl(device_fd_, VIDIOC_DQBUF, &buffer) == 0) { 514 if (ioctl(device_fd_, VIDIOC_DQBUF, &buffer) == 0) {
515 client_->OnIncomingCapturedFrame( 515 client_->OnIncomingCapturedFrame(
516 static_cast<uint8*> (buffer_pool_[buffer.index].start), 516 static_cast<uint8*>(buffer_pool_[buffer.index].start),
517 buffer.bytesused, base::Time::Now(), 0, false, false, frame_info_); 517 buffer.bytesused,
518 base::Time::Now(),
519 0,
520 false,
521 false,
522 frame_info_);
518 523
519 // Enqueue the buffer again. 524 // Enqueue the buffer again.
520 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) == -1) { 525 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) == -1) {
521 SetErrorState(base::StringPrintf( 526 SetErrorState(base::StringPrintf(
522 "Failed to enqueue capture buffer errno %d", errno)); 527 "Failed to enqueue capture buffer errno %d", errno));
523 } 528 }
524 } else { 529 } else {
525 SetErrorState(base::StringPrintf( 530 SetErrorState(base::StringPrintf(
526 "Failed to dequeue capture buffer errno %d", errno)); 531 "Failed to dequeue capture buffer errno %d", errno));
527 return; 532 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 611
607 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { 612 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) {
608 DCHECK(!v4l2_thread_.IsRunning() || 613 DCHECK(!v4l2_thread_.IsRunning() ||
609 v4l2_thread_.message_loop() == base::MessageLoop::current()); 614 v4l2_thread_.message_loop() == base::MessageLoop::current());
610 DVLOG(1) << reason; 615 DVLOG(1) << reason;
611 state_ = kError; 616 state_ = kError;
612 client_->OnError(); 617 client_->OnError();
613 } 618 }
614 619
615 } // namespace media 620 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/android/video_capture_device_android.cc ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698