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

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

Issue 1016773002: MJPEG acceleration for video capture using VAAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix coded size, shm handle Created 5 years, 9 months 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 #include <poll.h> 9 #include <poll.h>
10 #if defined(OS_OPENBSD) 10 #if defined(OS_OPENBSD)
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 : V4L2_CID_POWER_LINE_FREQUENCY_60HZ; 355 : V4L2_CID_POWER_LINE_FREQUENCY_60HZ;
356 HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &control)); 356 HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &control));
357 } 357 }
358 358
359 capture_format_.frame_size.SetSize(video_fmt.fmt.pix.width, 359 capture_format_.frame_size.SetSize(video_fmt.fmt.pix.width,
360 video_fmt.fmt.pix.height); 360 video_fmt.fmt.pix.height);
361 capture_format_.frame_rate = frame_rate; 361 capture_format_.frame_rate = frame_rate;
362 capture_format_.pixel_format = 362 capture_format_.pixel_format =
363 V4l2FourCcToChromiumPixelFormat(video_fmt.fmt.pix.pixelformat); 363 V4l2FourCcToChromiumPixelFormat(video_fmt.fmt.pix.pixelformat);
364 364
365 if (capture_format_.pixel_format == PIXEL_FORMAT_MJPEG) {
366 // TODO(kcwu) remove this hacky api
367 if (!client_->InitializeJpegDecoder()) {
wuchengli 2015/03/23 06:30:15 How about calling this when |last_captured_pixel_f
kcwu 2015/03/30 18:12:14 Done.
368 SetErrorState("InitializeJpegDecoder failed");
369 return;
370 }
371 }
372
365 if (!AllocateVideoBuffers()) { 373 if (!AllocateVideoBuffers()) {
366 SetErrorState("Allocate buffer failed (Cannot recover from this error)"); 374 SetErrorState("Allocate buffer failed (Cannot recover from this error)");
367 return; 375 return;
368 } 376 }
369 377
370 const v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 378 const v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
371 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_STREAMON, &type)) < 0) { 379 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_STREAMON, &type)) < 0) {
372 SetErrorState("VIDIOC_STREAMON failed"); 380 SetErrorState("VIDIOC_STREAMON failed");
373 return; 381 return;
374 } 382 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 439 }
432 } else { 440 } else {
433 timeout_count_ = 0; 441 timeout_count_ = 0;
434 } 442 }
435 443
436 // Check if the driver has filled a buffer. 444 // Check if the driver has filled a buffer.
437 if (device_pfd.revents & POLLIN) { 445 if (device_pfd.revents & POLLIN) {
438 v4l2_buffer buffer = {}; 446 v4l2_buffer buffer = {};
439 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 447 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
440 buffer.memory = V4L2_MEMORY_MMAP; 448 buffer.memory = V4L2_MEMORY_MMAP;
449 LOG(ERROR) << "DQBUF";
441 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) { 450 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) {
442 SetErrorState("Failed to dequeue capture buffer"); 451 SetErrorState("Failed to dequeue capture buffer");
443 return; 452 return;
444 } 453 }
445 client_->OnIncomingCapturedData( 454 client_->OnIncomingCapturedData(
446 static_cast<uint8*>(buffer_pool_[buffer.index].start), 455 static_cast<uint8*>(buffer_pool_[buffer.index].start),
447 buffer.bytesused, 456 buffer.bytesused,
448 capture_format_, 457 capture_format_,
449 rotation_, 458 rotation_,
450 base::TimeTicks::Now()); 459 base::TimeTicks::Now());
451 460
461 LOG(ERROR) << "QBUF";
452 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) 462 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0)
453 SetErrorState("Failed to enqueue capture buffer"); 463 SetErrorState("Failed to enqueue capture buffer");
454 } 464 }
455 465
456 v4l2_task_runner_->PostTask( 466 v4l2_task_runner_->PostTask(
457 FROM_HERE, 467 FROM_HERE,
458 base::Bind(&VideoCaptureDeviceLinux::V4L2CaptureDelegate::DoCapture, 468 base::Bind(&VideoCaptureDeviceLinux::V4L2CaptureDelegate::DoCapture,
459 this)); 469 this));
460 } 470 }
461 471
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 534 }
525 535
526 void VideoCaptureDeviceLinux::V4L2CaptureDelegate::SetErrorState( 536 void VideoCaptureDeviceLinux::V4L2CaptureDelegate::SetErrorState(
527 const std::string& reason) { 537 const std::string& reason) {
528 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); 538 DCHECK(v4l2_task_runner_->BelongsToCurrentThread());
529 is_capturing_ = false; 539 is_capturing_ = false;
530 client_->OnError(reason); 540 client_->OnError(reason);
531 } 541 }
532 542
533 } // namespace media 543 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698