OLD | NEW |
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 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ |
6 #define MEDIA_BASE_VIDEO_FRAME_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/md5.h" | 9 #include "base/md5.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 kAPlane = 3, | 34 kAPlane = 3, |
35 }; | 35 }; |
36 | 36 |
37 // Surface formats roughly based on FOURCC labels, see: | 37 // Surface formats roughly based on FOURCC labels, see: |
38 // http://www.fourcc.org/rgb.php | 38 // http://www.fourcc.org/rgb.php |
39 // http://www.fourcc.org/yuv.php | 39 // http://www.fourcc.org/yuv.php |
40 enum Format { | 40 enum Format { |
41 UNKNOWN = 0, // Unknown format value. | 41 UNKNOWN = 0, // Unknown format value. |
42 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples | 42 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples |
43 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples | 43 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples |
44 EMPTY = 9, // An empty frame. | |
45 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. | 44 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. |
46 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. | 45 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. |
47 #if defined(GOOGLE_TV) | 46 #if defined(GOOGLE_TV) |
48 HOLE = 13, // Hole frame. | 47 HOLE = 13, // Hole frame. |
49 #endif | 48 #endif |
50 YV12A = 14, // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples. | 49 YV12A = 14, // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples. |
51 }; | 50 }; |
52 | 51 |
53 // Returns the name of a Format as a string. | 52 // Returns the name of a Format as a string. |
54 static std::string FormatToString(Format format); | 53 static std::string FormatToString(Format format); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const gfx::Size& natural_size, | 161 const gfx::Size& natural_size, |
163 int32 y_stride, | 162 int32 y_stride, |
164 int32 u_stride, | 163 int32 u_stride, |
165 int32 v_stride, | 164 int32 v_stride, |
166 uint8* y_data, | 165 uint8* y_data, |
167 uint8* u_data, | 166 uint8* u_data, |
168 uint8* v_data, | 167 uint8* v_data, |
169 base::TimeDelta timestamp, | 168 base::TimeDelta timestamp, |
170 const base::Closure& no_longer_needed_cb); | 169 const base::Closure& no_longer_needed_cb); |
171 | 170 |
172 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, | 171 // Creates a frame which indicates end-of-stream. |
173 // and timestamp are all 0. | 172 static scoped_refptr<VideoFrame> CreateEOSFrame(); |
174 static scoped_refptr<VideoFrame> CreateEmptyFrame(); | |
175 | 173 |
176 // Allocates YV12 frame based on |size|, and sets its data to the YUV(y,u,v). | 174 // Allocates YV12 frame based on |size|, and sets its data to the YUV(y,u,v). |
177 static scoped_refptr<VideoFrame> CreateColorFrame( | 175 static scoped_refptr<VideoFrame> CreateColorFrame( |
178 const gfx::Size& size, | 176 const gfx::Size& size, |
179 uint8 y, uint8 u, uint8 v, | 177 uint8 y, uint8 u, uint8 v, |
180 base::TimeDelta timestamp); | 178 base::TimeDelta timestamp); |
181 | 179 |
182 // Allocates YV12 frame based on |size|, and sets its data to the YUV | 180 // Allocates YV12 frame based on |size|, and sets its data to the YUV |
183 // equivalent of RGB(0,0,0). | 181 // equivalent of RGB(0,0,0). |
184 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size); | 182 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // mailbox, the caller must wait for the included sync point. | 216 // mailbox, the caller must wait for the included sync point. |
219 const scoped_refptr<MailboxHolder>& texture_mailbox() const; | 217 const scoped_refptr<MailboxHolder>& texture_mailbox() const; |
220 | 218 |
221 // Returns the texture target. Only valid for NATIVE_TEXTURE frames. | 219 // Returns the texture target. Only valid for NATIVE_TEXTURE frames. |
222 uint32 texture_target() const; | 220 uint32 texture_target() const; |
223 | 221 |
224 // Returns the shared-memory handle, if present | 222 // Returns the shared-memory handle, if present |
225 base::SharedMemoryHandle shared_memory_handle() const; | 223 base::SharedMemoryHandle shared_memory_handle() const; |
226 | 224 |
227 // Returns true if this VideoFrame represents the end of the stream. | 225 // Returns true if this VideoFrame represents the end of the stream. |
228 bool IsEndOfStream() const; | 226 bool end_of_stream() const { return end_of_stream_; } |
229 | 227 |
230 base::TimeDelta GetTimestamp() const { | 228 base::TimeDelta GetTimestamp() const { |
231 return timestamp_; | 229 return timestamp_; |
232 } | 230 } |
233 void SetTimestamp(const base::TimeDelta& timestamp) { | 231 void SetTimestamp(const base::TimeDelta& timestamp) { |
234 timestamp_ = timestamp; | 232 timestamp_ = timestamp; |
235 } | 233 } |
236 | 234 |
237 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 235 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
238 // context. Calls MD5Update with the context and the contents of the frame. | 236 // context. Calls MD5Update with the context and the contents of the frame. |
239 void HashFrameForTesting(base::MD5Context* context); | 237 void HashFrameForTesting(base::MD5Context* context); |
240 | 238 |
241 private: | 239 private: |
242 friend class base::RefCountedThreadSafe<VideoFrame>; | 240 friend class base::RefCountedThreadSafe<VideoFrame>; |
243 // Clients must use the static CreateFrame() method to create a new frame. | 241 // Clients must use the static CreateFrame() method to create a new frame. |
244 VideoFrame(Format format, | 242 VideoFrame(Format format, |
245 const gfx::Size& coded_size, | 243 const gfx::Size& coded_size, |
246 const gfx::Rect& visible_rect, | 244 const gfx::Rect& visible_rect, |
247 const gfx::Size& natural_size, | 245 const gfx::Size& natural_size, |
248 base::TimeDelta timestamp); | 246 base::TimeDelta timestamp, |
| 247 bool end_of_stream); |
249 virtual ~VideoFrame(); | 248 virtual ~VideoFrame(); |
250 | 249 |
251 void AllocateYUV(); | 250 void AllocateYUV(); |
252 | 251 |
253 // Used to DCHECK() plane parameters. | 252 // Used to DCHECK() plane parameters. |
254 bool IsValidPlane(size_t plane) const; | 253 bool IsValidPlane(size_t plane) const; |
255 | 254 |
256 // Frame format. | 255 // Frame format. |
257 Format format_; | 256 Format format_; |
258 | 257 |
(...skipping 20 matching lines...) Expand all Loading... |
279 uint32 texture_target_; | 278 uint32 texture_target_; |
280 ReadPixelsCB read_pixels_cb_; | 279 ReadPixelsCB read_pixels_cb_; |
281 | 280 |
282 // Shared memory handle, if this frame was allocated from shared memory. | 281 // Shared memory handle, if this frame was allocated from shared memory. |
283 base::SharedMemoryHandle shared_memory_handle_; | 282 base::SharedMemoryHandle shared_memory_handle_; |
284 | 283 |
285 base::Closure no_longer_needed_cb_; | 284 base::Closure no_longer_needed_cb_; |
286 | 285 |
287 base::TimeDelta timestamp_; | 286 base::TimeDelta timestamp_; |
288 | 287 |
| 288 const bool end_of_stream_; |
| 289 |
289 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 290 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
290 }; | 291 }; |
291 | 292 |
292 } // namespace media | 293 } // namespace media |
293 | 294 |
294 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 295 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |