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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const gfx::Size& natural_size, | 130 const gfx::Size& natural_size, |
131 base::TimeDelta timestamp, | 131 base::TimeDelta timestamp, |
132 const ReadPixelsCB& read_pixels_cb, | 132 const ReadPixelsCB& read_pixels_cb, |
133 const base::Closure& no_longer_needed_cb); | 133 const base::Closure& no_longer_needed_cb); |
134 | 134 |
135 // Read pixels from the native texture backing |*this| and write | 135 // Read pixels from the native texture backing |*this| and write |
136 // them to |pixels| as BGRA. |pixels| must point to a buffer at | 136 // them to |pixels| as BGRA. |pixels| must point to a buffer at |
137 // least as large as 4*visible_rect().width()*visible_rect().height(). | 137 // least as large as 4*visible_rect().width()*visible_rect().height(). |
138 void ReadPixelsFromNativeTexture(const SkBitmap& pixels); | 138 void ReadPixelsFromNativeTexture(const SkBitmap& pixels); |
139 | 139 |
| 140 // Wraps image data in a buffer backed by a base::SharedMemoryHandle with a |
| 141 // VideoFrame. The image data resides in |data| and is assumed to be packed |
| 142 // tightly in a buffer of logical dimensions |coded_size| with the appropriate |
| 143 // bit depth and plane count as given by |format|. When the frame is |
| 144 // destroyed |no_longer_needed_cb.Run()| will be called. |
| 145 static scoped_refptr<VideoFrame> WrapExternalSharedMemory( |
| 146 Format format, |
| 147 const gfx::Size& coded_size, |
| 148 const gfx::Rect& visible_rect, |
| 149 const gfx::Size& natural_size, |
| 150 uint8* data, |
| 151 base::SharedMemoryHandle handle, |
| 152 base::TimeDelta timestamp, |
| 153 const base::Closure& no_longer_needed_cb); |
| 154 |
140 // Wraps external YUV data of the given parameters with a VideoFrame. | 155 // Wraps external YUV data of the given parameters with a VideoFrame. |
141 // The returned VideoFrame does not own the data passed in. When the frame | 156 // The returned VideoFrame does not own the data passed in. When the frame |
142 // is destroyed |no_longer_needed_cb.Run()| will be called. | 157 // is destroyed |no_longer_needed_cb.Run()| will be called. |
143 static scoped_refptr<VideoFrame> WrapExternalYuvData( | 158 static scoped_refptr<VideoFrame> WrapExternalYuvData( |
144 Format format, | 159 Format format, |
145 const gfx::Size& coded_size, | 160 const gfx::Size& coded_size, |
146 const gfx::Rect& visible_rect, | 161 const gfx::Rect& visible_rect, |
147 const gfx::Size& natural_size, | 162 const gfx::Size& natural_size, |
148 int32 y_stride, | 163 int32 y_stride, |
149 int32 u_stride, | 164 int32 u_stride, |
150 int32 v_stride, | 165 int32 v_stride, |
151 uint8* y_data, | 166 uint8* y_data, |
152 uint8* u_data, | 167 uint8* u_data, |
153 uint8* v_data, | 168 uint8* v_data, |
154 base::TimeDelta timestamp, | 169 base::TimeDelta timestamp, |
155 base::SharedMemoryHandle shm_handle, // may be NULLHandle() | |
156 const base::Closure& no_longer_needed_cb); | 170 const base::Closure& no_longer_needed_cb); |
157 | 171 |
158 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, | 172 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, |
159 // and timestamp are all 0. | 173 // and timestamp are all 0. |
160 static scoped_refptr<VideoFrame> CreateEmptyFrame(); | 174 static scoped_refptr<VideoFrame> CreateEmptyFrame(); |
161 | 175 |
162 // Allocates YV12 frame based on |size|, and sets its data to the YUV(y,u,v). | 176 // Allocates YV12 frame based on |size|, and sets its data to the YUV(y,u,v). |
163 static scoped_refptr<VideoFrame> CreateColorFrame( | 177 static scoped_refptr<VideoFrame> CreateColorFrame( |
164 const gfx::Size& size, | 178 const gfx::Size& size, |
165 uint8 y, uint8 u, uint8 v, | 179 uint8 y, uint8 u, uint8 v, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 base::Closure no_longer_needed_cb_; | 283 base::Closure no_longer_needed_cb_; |
270 | 284 |
271 base::TimeDelta timestamp_; | 285 base::TimeDelta timestamp_; |
272 | 286 |
273 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 287 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
274 }; | 288 }; |
275 | 289 |
276 } // namespace media | 290 } // namespace media |
277 | 291 |
278 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 292 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |