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

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

Issue 1685713003: Remove V4L2CaptureDelegate{Single,Multi}Plane, VCD::Client::OnIncomingCapturedYuvData() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perkj@ comments and reverted change to WeakPtr Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/capture/video/linux/v4l2_capture_delegate_single_plane.h"
6
7 #include <sys/mman.h>
8
9 namespace media {
10
11 scoped_refptr<V4L2CaptureDelegate::BufferTracker>
12 V4L2CaptureDelegateSinglePlane::CreateBufferTracker() const {
13 return make_scoped_refptr(new BufferTrackerSPlane());
14 }
15
16 bool V4L2CaptureDelegateSinglePlane::FillV4L2Format(
17 v4l2_format* format,
18 uint32_t width,
19 uint32_t height,
20 uint32_t pixelformat_fourcc) const {
21 format->fmt.pix.width = width;
22 format->fmt.pix.height = height;
23 format->fmt.pix.pixelformat = pixelformat_fourcc;
24 return true;
25 }
26
27 void V4L2CaptureDelegateSinglePlane::FinishFillingV4L2Buffer(
28 v4l2_buffer* buffer) const {
29 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
30 }
31
32 void V4L2CaptureDelegateSinglePlane::SetPayloadSize(
33 const scoped_refptr<BufferTracker>& buffer_tracker,
34 const v4l2_buffer& buffer) const {
35 buffer_tracker->SetPlanePayloadSize(0, buffer.bytesused);
36 }
37
38 void V4L2CaptureDelegateSinglePlane::SendBuffer(
39 const scoped_refptr<BufferTracker>& buffer_tracker,
40 const v4l2_format& format) const {
41 client()->OnIncomingCapturedData(
42 buffer_tracker->GetPlaneStart(0), buffer_tracker->GetPlanePayloadSize(0),
43 capture_format(), rotation(), base::TimeTicks::Now());
44 }
45
46 bool V4L2CaptureDelegateSinglePlane::BufferTrackerSPlane::Init(
47 int fd,
48 const v4l2_buffer& buffer) {
49 // Some devices require mmap() to be called with both READ and WRITE.
50 // See http://crbug.com/178582.
51 void* const start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
52 MAP_SHARED, fd, buffer.m.offset);
53 if (start == MAP_FAILED) {
54 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
55 return false;
56 }
57 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.length);
58 return true;
59 }
60
61 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698