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

Side by Side Diff: media/video/capture/linux/v4l2_capture_delegate.h

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: SetPayloadSize 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
« no previous file with comments | « no previous file | media/video/capture/linux/v4l2_capture_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_
6 #define MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ 6 #define MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_
7 7
8 #if defined(OS_OPENBSD) 8 #if defined(OS_OPENBSD)
9 #include <sys/videoio.h> 9 #include <sys/videoio.h>
10 #else 10 #else
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 BufferTracker(); 59 BufferTracker();
60 // Abstract method to mmap() given |fd| according to |buffer|, planarity 60 // Abstract method to mmap() given |fd| according to |buffer|, planarity
61 // specific. 61 // specific.
62 virtual bool Init(int fd, const v4l2_buffer& buffer) = 0; 62 virtual bool Init(int fd, const v4l2_buffer& buffer) = 0;
63 63
64 uint8_t* const GetPlaneStart(size_t plane) const { 64 uint8_t* const GetPlaneStart(size_t plane) const {
65 DCHECK_LT(plane, planes_.size()); 65 DCHECK_LT(plane, planes_.size());
66 return planes_[plane].start; 66 return planes_[plane].start;
67 } 67 }
68 68
69 size_t GetPlanePayloadSize(size_t plane) const {
70 DCHECK_LT(plane, planes_.size());
71 return planes_[plane].payload_size;
72 }
73
74 void SetPlanePayloadSize(size_t plane, size_t payload_size) {
75 DCHECK_LT(plane, planes_.size());
wuchengli 2015/05/25 07:51:01 add a DCHECK for |payload_size| <= |length|
kcwu 2015/05/25 07:54:23 Done.
76 planes_[plane].payload_size = payload_size;
77 }
78
69 protected: 79 protected:
70 friend class base::RefCounted<BufferTracker>; 80 friend class base::RefCounted<BufferTracker>;
71 virtual ~BufferTracker(); 81 virtual ~BufferTracker();
72 // Adds a given mmap()ed plane to |planes_|. 82 // Adds a given mmap()ed plane to |planes_|.
73 void AddMmapedPlane(uint8_t* const start, size_t length); 83 void AddMmapedPlane(uint8_t* const start, size_t length);
74 84
75 private: 85 private:
76 struct Plane { 86 struct Plane {
77 uint8_t* start; 87 uint8_t* start;
78 size_t length; 88 size_t length;
89 size_t payload_size;
79 }; 90 };
80 std::vector<Plane> planes_; 91 std::vector<Plane> planes_;
81 }; 92 };
82 93
83 V4L2CaptureDelegate( 94 V4L2CaptureDelegate(
84 const VideoCaptureDevice::Name& device_name, 95 const VideoCaptureDevice::Name& device_name,
85 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, 96 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner,
86 int power_line_frequency); 97 int power_line_frequency);
87 virtual ~V4L2CaptureDelegate(); 98 virtual ~V4L2CaptureDelegate();
88 99
89 // Creates the necessary, planarity-specific, internal tracking schemes, 100 // Creates the necessary, planarity-specific, internal tracking schemes,
90 virtual scoped_refptr<BufferTracker> CreateBufferTracker() const = 0; 101 virtual scoped_refptr<BufferTracker> CreateBufferTracker() const = 0;
91 102
92 // Fill in |format| with the given parameters, in a planarity dependent way. 103 // Fill in |format| with the given parameters, in a planarity dependent way.
93 virtual bool FillV4L2Format(v4l2_format* format, 104 virtual bool FillV4L2Format(v4l2_format* format,
94 uint32_t width, 105 uint32_t width,
95 uint32_t height, 106 uint32_t height,
96 uint32_t pixelformat_fourcc) const = 0; 107 uint32_t pixelformat_fourcc) const = 0;
97 108
98 // Finish filling |buffer| struct with planarity-dependent data. 109 // Finish filling |buffer| struct with planarity-dependent data.
99 virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer) const = 0; 110 virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer) const = 0;
100 111
112 // Fetch the number of bytes occupied by data in |buffer| and set to
113 // |buffer_tracker|.
114 virtual void SetPayloadSize(
115 const scoped_refptr<BufferTracker>& buffer_tracker,
116 const v4l2_buffer& buffer) const = 0;
117
101 // Sends the captured |buffer| to the |client_|, synchronously. 118 // Sends the captured |buffer| to the |client_|, synchronously.
102 virtual void SendBuffer( 119 virtual void SendBuffer(
103 const scoped_refptr<BufferTracker>& buffer_tracker, 120 const scoped_refptr<BufferTracker>& buffer_tracker,
104 const v4l2_format& format) const = 0; 121 const v4l2_format& format) const = 0;
105 122
106 // A few accessors for SendBuffer()'s to access private member variables. 123 // A few accessors for SendBuffer()'s to access private member variables.
107 VideoCaptureFormat capture_format() const { return capture_format_; } 124 VideoCaptureFormat capture_format() const { return capture_format_; }
108 VideoCaptureDevice::Client* client() const { return client_.get(); } 125 VideoCaptureDevice::Client* client() const { return client_.get(); }
109 int rotation() const { return rotation_; } 126 int rotation() const { return rotation_; }
110 127
(...skipping 30 matching lines...) Expand all
141 158
142 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. 159 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270.
143 int rotation_; 160 int rotation_;
144 161
145 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); 162 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate);
146 }; 163 };
147 164
148 } // namespace media 165 } // namespace media
149 166
150 #endif // MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ 167 #endif // MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/linux/v4l2_capture_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698