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

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

Issue 1147693002: Send bytes_used of v4l2 captured frame when video capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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_single_plane.h" 5 #include "media/video/capture/linux/v4l2_capture_delegate_single_plane.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 13 matching lines...) Expand all
24 return true; 24 return true;
25 } 25 }
26 26
27 void V4L2CaptureDelegateSinglePlane::FinishFillingV4L2Buffer( 27 void V4L2CaptureDelegateSinglePlane::FinishFillingV4L2Buffer(
28 v4l2_buffer* buffer) const { 28 v4l2_buffer* buffer) const {
29 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 29 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
30 } 30 }
31 31
32 void V4L2CaptureDelegateSinglePlane::SendBuffer( 32 void V4L2CaptureDelegateSinglePlane::SendBuffer(
33 const scoped_refptr<BufferTracker>& buffer_tracker, 33 const scoped_refptr<BufferTracker>& buffer_tracker,
34 const v4l2_format& format) const { 34 const v4l2_format& format,
35 const size_t data_length = format.fmt.pix.sizeimage; 35 size_t bytes_used) const {
36 DCHECK_GE(data_length, capture_format().ImageAllocationSize());
37 client()->OnIncomingCapturedData( 36 client()->OnIncomingCapturedData(
38 buffer_tracker->GetPlaneStart(0), 37 buffer_tracker->GetPlaneStart(0),
39 data_length, 38 bytes_used,
40 capture_format(), 39 capture_format(),
41 rotation(), 40 rotation(),
42 base::TimeTicks::Now()); 41 base::TimeTicks::Now());
43 } 42 }
44 43
45 bool V4L2CaptureDelegateSinglePlane::BufferTrackerSPlane::Init( 44 bool V4L2CaptureDelegateSinglePlane::BufferTrackerSPlane::Init(
46 int fd, 45 int fd,
47 const v4l2_buffer& buffer) { 46 const v4l2_buffer& buffer) {
48 // Some devices require mmap() to be called with both READ and WRITE. 47 // Some devices require mmap() to be called with both READ and WRITE.
49 // See http://crbug.com/178582. 48 // See http://crbug.com/178582.
50 void* const start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, 49 void* const start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
51 MAP_SHARED, fd, buffer.m.offset); 50 MAP_SHARED, fd, buffer.m.offset);
52 if (start == MAP_FAILED) { 51 if (start == MAP_FAILED) {
53 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 52 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
54 return false; 53 return false;
55 } 54 }
56 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.length); 55 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.length);
57 return true; 56 return true;
58 } 57 }
59 58
60 } // namespace media 59 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698