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

Side by Side Diff: media/video/capture/video_capture_device.h

Issue 48113011: Remove media::VideoFrame from media::VideoCaptureDevice::Client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 4969ee91 Initial. Created 7 years, 1 month 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 // VideoCaptureDevice is the abstract base class for realizing video capture 5 // VideoCaptureDevice is the abstract base class for realizing video capture
6 // device support in Chromium. It provides the interface for OS dependent 6 // device support in Chromium. It provides the interface for OS dependent
7 // implementations. 7 // implementations.
8 // The class is created and functions are invoked on a thread owned by 8 // The class is created and functions are invoked on a thread owned by
9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS
10 // specific implementation. 10 // specific implementation.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 : public NON_EXPORTED_BASE(std::list<Name>) { 113 : public NON_EXPORTED_BASE(std::list<Name>) {
114 public: 114 public:
115 // Returns NULL if no entry was found by that ID. 115 // Returns NULL if no entry was found by that ID.
116 Name* FindById(const std::string& id); 116 Name* FindById(const std::string& id);
117 117
118 // Allow generated copy constructor and assignment. 118 // Allow generated copy constructor and assignment.
119 }; 119 };
120 120
121 class MEDIA_EXPORT Client { 121 class MEDIA_EXPORT Client {
122 public: 122 public:
123 // Memory buffer returned by Client::ReserveOutputBuffer().
124 class Buffer {
125 public:
126 Buffer(void* data, size_t size) : data_(data), size_(size) {}
ncarter (slow) 2013/10/29 18:42:17 Do you expect Buffer to be created directly? If th
sheu 2013/11/05 20:02:10 Done.
127 virtual ~Buffer() {}
128
129 void* data() const { return data_; }
130 size_t size() const { return size_; }
131
132 private:
133 void* const data_;
134 const size_t size_;
135 };
136
123 virtual ~Client() {} 137 virtual ~Client() {}
124 138
125 // Reserve an output buffer into which a video frame can be captured 139 // Reserve an output buffer into which contents can be captured directly.
126 // directly. If all buffers are currently busy, returns NULL. 140 // The returned Buffer will always be allocated with a memory size suitable
141 // for holding a packed video frame of |format| format, of |dimensions|
142 // dimensions. It is permissible for |dimensions| to be zero; in which
143 // case the returned Buffer does not guarantee memory backing, but functions
144 // as a reservation for external input for the purposes of buffer
145 // throttling.
127 // 146 //
128 // The returned VideoFrames will always be allocated with a YV12 format and 147 // The output buffer stays reserved for use until the Buffer object is
129 // have dimensions matching |size|. It is the VideoCaptureDevice's 148 // destroyed, or it is passed back to the Client's
130 // responsibility to obey whatever stride and memory layout are indicated on 149 // OnIncomingCaptured*Buffer() function.
131 // the returned VideoFrame object. 150 virtual scoped_ptr<Buffer> ReserveOutputBuffer(
132 // 151 media::VideoFrame::Format format,
133 // The output buffer stays reserved for use by the calling 152 const gfx::Size& dimensions) = 0;
134 // VideoCaptureDevice until either the last reference to the VideoFrame is
135 // released, or until the buffer is passed back to the Client's
136 // OnIncomingCapturedFrame() method.
137 virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer(
138 const gfx::Size& size) = 0;
139 153
140 // Captured a new video frame as a raw buffer. The size, color format, and 154 // Captured a new video frame as a raw buffer. The size, color format, and
141 // layout are taken from the parameters specified by an earlier call to 155 // layout are taken from the parameters specified by an earlier call to
142 // OnFrameInfo(). |data| must be packed, with no padding between rows and/or 156 // OnFrameInfo(). |data| must be packed, with no padding between rows and/or
143 // color planes. 157 // color planes.
144 // 158 //
145 // This method will try to reserve an output buffer and copy from |data| 159 // This method will try to reserve an output buffer and copy from |data|
146 // into the output buffer. If no output buffer is available, the frame will 160 // into the output buffer. If no output buffer is available, the frame will
147 // be silently dropped. 161 // be silently dropped.
148 virtual void OnIncomingCapturedFrame(const uint8* data, 162 virtual void OnIncomingCapturedFrame(const uint8* data,
149 int length, 163 int length,
150 base::Time timestamp, 164 base::Time timestamp,
151 int rotation, // Clockwise. 165 int rotation, // Clockwise.
152 bool flip_vert, 166 bool flip_vert,
153 bool flip_horiz) = 0; 167 bool flip_horiz) = 0;
154 168
155 // Captured a new video frame, held in a VideoFrame container. 169 // Captured a new video frame, in a raw buffer backed by |buffer|.
ncarter (slow) 2013/10/29 18:42:17 "in a raw buffer backed by |buffer|" -> "held in |
sheu 2013/11/05 20:02:10 Done.
156 // 170 //
157 // If |frame| was created via the ReserveOutputBuffer() mechanism, then the 171 // As the frame is backed by a reservation returned by
158 // frame delivery is guaranteed (it will not be silently dropped), and 172 // ReserveOutputBuffer(), delivery is guaranteed and will require no
159 // delivery will require no additional copies in the browser process. For 173 // additional copies in the browser process. The caller gives up ownership
160 // such frames, the VideoCaptureDevice's reservation on the output buffer 174 // of |buffer| and should not retained any cached pointers to its underlying
161 // ends immediately. The VideoCaptureDevice may not read or write the 175 // memory. |dimensions| indicates the frame width and height of the buffer
162 // underlying memory afterwards, and it should release its references to 176 // contents; this is assumed to be of |format| format and tightly packed.
163 // |frame| as soon as possible, to allow buffer reuse. 177 virtual void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer,
164 // 178 media::VideoFrame::Format format,
165 // If |frame| was NOT created via ReserveOutputBuffer(), then this method 179 const gfx::Size& dimensions,
166 // will try to reserve an output buffer and copy from |frame| into the 180 base::Time timestamp) = 0;
167 // output buffer. If no output buffer is available, the frame will be
168 // silently dropped. |frame| must be allocated as RGB32, YV12 or I420, and
169 // the size must match that specified by an earlier call to OnFrameInfo().
170 virtual void OnIncomingCapturedVideoFrame(
171 const scoped_refptr<media::VideoFrame>& frame,
172 base::Time timestamp) = 0;
173 181
174 // An error has occurred that cannot be handled and VideoCaptureDevice must 182 // An error has occurred that cannot be handled and VideoCaptureDevice must
175 // be StopAndDeAllocate()-ed. 183 // be StopAndDeAllocate()-ed.
176 virtual void OnError() = 0; 184 virtual void OnError() = 0;
177 185
178 // Called when VideoCaptureDevice::AllocateAndStart() has been called to 186 // Called when VideoCaptureDevice::AllocateAndStart() has been called to
179 // inform of the resulting frame size. 187 // inform of the resulting frame size.
180 virtual void OnFrameInfo(const VideoCaptureCapability& info) = 0; 188 virtual void OnFrameInfo(const VideoCaptureCapability& info) = 0;
181 189
182 // Called when the native resolution of VideoCaptureDevice has been changed 190 // Called when the native resolution of VideoCaptureDevice has been changed
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // If deallocation is done asynchronously, then the device implementation must 224 // If deallocation is done asynchronously, then the device implementation must
217 // ensure that a subsequent AllocateAndStart() operation targeting the same ID 225 // ensure that a subsequent AllocateAndStart() operation targeting the same ID
218 // would be sequenced through the same task runner, so that deallocation 226 // would be sequenced through the same task runner, so that deallocation
219 // happens first. 227 // happens first.
220 virtual void StopAndDeAllocate() = 0; 228 virtual void StopAndDeAllocate() = 0;
221 }; 229 };
222 230
223 } // namespace media 231 } // namespace media
224 232
225 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 233 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698