| 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_multi_plane.h" | 5 #include "media/video/capture/linux/v4l2_capture_delegate_multi_plane.h" |
| 6 | 6 |
| 7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 V4L2CaptureDelegateMultiPlane::V4L2CaptureDelegateMultiPlane( | 11 V4L2CaptureDelegateMultiPlane::V4L2CaptureDelegateMultiPlane( |
| 12 const VideoCaptureDevice::Name& device_name, | 12 const VideoCaptureDevice::Name& device_name, |
| 13 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, | 13 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
| 14 int power_line_frequency) | 14 int power_line_frequency) |
| 15 : V4L2CaptureDelegate(device_name, | 15 : V4L2CaptureDelegate(device_name, |
| 16 v4l2_task_runner, | 16 v4l2_task_runner, |
| 17 V4L2_MEMORY_MMAP, |
| 17 power_line_frequency) { | 18 power_line_frequency) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 V4L2CaptureDelegateMultiPlane::~V4L2CaptureDelegateMultiPlane() { | 21 V4L2CaptureDelegateMultiPlane::~V4L2CaptureDelegateMultiPlane() { |
| 21 } | 22 } |
| 22 | 23 |
| 23 scoped_refptr<V4L2CaptureDelegate::BufferTracker> | 24 scoped_refptr<V4L2CaptureDelegate::BufferTracker> |
| 24 V4L2CaptureDelegateMultiPlane::CreateBufferTracker() const { | 25 V4L2CaptureDelegateMultiPlane::CreateBufferTracker() const { |
| 25 return make_scoped_refptr(new BufferTrackerMPlane()); | 26 return make_scoped_refptr(new BufferTrackerMPlane()); |
| 26 } | 27 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 if (num_v4l2_planes == 0u) | 40 if (num_v4l2_planes == 0u) |
| 40 return false; | 41 return false; |
| 41 DCHECK_LE(num_v4l2_planes, static_cast<size_t>(VIDEO_MAX_PLANES)); | 42 DCHECK_LE(num_v4l2_planes, static_cast<size_t>(VIDEO_MAX_PLANES)); |
| 42 format->fmt.pix_mp.num_planes = num_v4l2_planes; | 43 format->fmt.pix_mp.num_planes = num_v4l2_planes; |
| 43 | 44 |
| 44 v4l2_planes_.resize(num_v4l2_planes); | 45 v4l2_planes_.resize(num_v4l2_planes); |
| 45 return true; | 46 return true; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void V4L2CaptureDelegateMultiPlane::FinishFillingV4L2Buffer( | 49 void V4L2CaptureDelegateMultiPlane::FinishFillingV4L2Buffer( |
| 49 v4l2_buffer* buffer) const { | 50 v4l2_buffer* buffer, |
| 51 bool /* for_enqueue */) const { |
| 50 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 52 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 51 buffer->length = v4l2_planes_.size(); | 53 buffer->length = v4l2_planes_.size(); |
| 52 | 54 |
| 53 static const struct v4l2_plane empty_plane = {}; | 55 static const struct v4l2_plane empty_plane = {}; |
| 54 std::fill(v4l2_planes_.begin(), v4l2_planes_.end(), empty_plane); | 56 std::fill(v4l2_planes_.begin(), v4l2_planes_.end(), empty_plane); |
| 55 buffer->m.planes = v4l2_planes_.data(); | 57 buffer->m.planes = v4l2_planes_.data(); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void V4L2CaptureDelegateMultiPlane::SetPayloadSize( | 60 void V4L2CaptureDelegateMultiPlane::SetPayloadSize( |
| 59 const scoped_refptr<BufferTracker>& buffer_tracker, | 61 const scoped_refptr<BufferTracker>& buffer_tracker, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return false; | 99 return false; |
| 98 } | 100 } |
| 99 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.m.planes[p].length); | 101 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.m.planes[p].length); |
| 100 DVLOG(3) << "Mmap()ed plane #" << p << " of " << buffer.m.planes[p].length | 102 DVLOG(3) << "Mmap()ed plane #" << p << " of " << buffer.m.planes[p].length |
| 101 << "B"; | 103 << "B"; |
| 102 } | 104 } |
| 103 return true; | 105 return true; |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace media | 108 } // namespace media |
| OLD | NEW |