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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "media/base/buffers.h" | 14 #include "media/base/buffers.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
17 | 17 |
18 class SkBitmap; | 18 class SkBitmap; |
19 | 19 |
20 #if defined(OS_MACOSX) | |
21 #include <CoreVideo/CoreVideo.h> | |
Robert Sesek
2014/08/07 18:00:15
nit: blank line between system C headers and proje
jfroy
2014/08/07 18:08:20
Acknowledged.
| |
22 #include "base/mac/scoped_cftyperef.h" | |
23 #endif | |
24 | |
20 namespace gpu { | 25 namespace gpu { |
21 struct MailboxHolder; | 26 struct MailboxHolder; |
22 } // namespace gpu | 27 } // namespace gpu |
23 | 28 |
24 namespace media { | 29 namespace media { |
25 | 30 |
26 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { | 31 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { |
27 public: | 32 public: |
28 enum { | 33 enum { |
29 kFrameSizeAlignment = 16, | 34 kFrameSizeAlignment = 16, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 static scoped_refptr<VideoFrame> WrapExternalDmabufs( | 146 static scoped_refptr<VideoFrame> WrapExternalDmabufs( |
142 Format format, | 147 Format format, |
143 const gfx::Size& coded_size, | 148 const gfx::Size& coded_size, |
144 const gfx::Rect& visible_rect, | 149 const gfx::Rect& visible_rect, |
145 const gfx::Size& natural_size, | 150 const gfx::Size& natural_size, |
146 const std::vector<int> dmabuf_fds, | 151 const std::vector<int> dmabuf_fds, |
147 base::TimeDelta timestamp, | 152 base::TimeDelta timestamp, |
148 const base::Closure& no_longer_needed_cb); | 153 const base::Closure& no_longer_needed_cb); |
149 #endif | 154 #endif |
150 | 155 |
156 #if defined(OS_MACOSX) | |
157 // Wraps a provided CVPixelBuffer with a VideoFrame. The pixel buffer is | |
158 // retained for the lifetime of the VideoFrame and released upon destruction. | |
159 // The image data is only accessible via the pixel buffer, which could be | |
160 // backed by an IOSurface from another process. All the attributes of the | |
161 // VideoFrame are derived from the pixel buffer, with the exception of the | |
162 // timestamp. If information is missing or is incompatible (for example, a | |
163 // pixel format that has no VideoFrame match), NULL is returned. | |
164 // http://crbug.com/401308 | |
165 static scoped_refptr<VideoFrame> WrapCVPixelBuffer( | |
166 CVPixelBufferRef cv_pixel_buffer, | |
167 base::TimeDelta timestamp); | |
168 #endif | |
169 | |
151 // Wraps external YUV data of the given parameters with a VideoFrame. | 170 // Wraps external YUV data of the given parameters with a VideoFrame. |
152 // The returned VideoFrame does not own the data passed in. When the frame | 171 // The returned VideoFrame does not own the data passed in. When the frame |
153 // is destroyed |no_longer_needed_cb.Run()| will be called. | 172 // is destroyed |no_longer_needed_cb.Run()| will be called. |
154 // TODO(sheu): merge this into WrapExternalSharedMemory(). | 173 // TODO(sheu): merge this into WrapExternalSharedMemory(). |
155 // http://crbug.com/270217 | 174 // http://crbug.com/270217 |
156 static scoped_refptr<VideoFrame> WrapExternalYuvData( | 175 static scoped_refptr<VideoFrame> WrapExternalYuvData( |
157 Format format, | 176 Format format, |
158 const gfx::Size& coded_size, | 177 const gfx::Size& coded_size, |
159 const gfx::Rect& visible_rect, | 178 const gfx::Rect& visible_rect, |
160 const gfx::Size& natural_size, | 179 const gfx::Size& natural_size, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 const gpu::MailboxHolder* mailbox_holder() const; | 263 const gpu::MailboxHolder* mailbox_holder() const; |
245 | 264 |
246 // Returns the shared-memory handle, if present | 265 // Returns the shared-memory handle, if present |
247 base::SharedMemoryHandle shared_memory_handle() const; | 266 base::SharedMemoryHandle shared_memory_handle() const; |
248 | 267 |
249 #if defined(OS_POSIX) | 268 #if defined(OS_POSIX) |
250 // Returns backing dmabuf file descriptor for given |plane|, if present. | 269 // Returns backing dmabuf file descriptor for given |plane|, if present. |
251 int dmabuf_fd(size_t plane) const; | 270 int dmabuf_fd(size_t plane) const; |
252 #endif | 271 #endif |
253 | 272 |
273 #if defined(OS_MACOSX) | |
274 // Returns the backing CVPixelBuffer, if present. | |
275 CVPixelBufferRef cv_pixel_buffer() const; | |
276 #endif | |
277 | |
254 // Returns true if this VideoFrame represents the end of the stream. | 278 // Returns true if this VideoFrame represents the end of the stream. |
255 bool end_of_stream() const { return end_of_stream_; } | 279 bool end_of_stream() const { return end_of_stream_; } |
256 | 280 |
257 base::TimeDelta timestamp() const { | 281 base::TimeDelta timestamp() const { |
258 return timestamp_; | 282 return timestamp_; |
259 } | 283 } |
260 void set_timestamp(const base::TimeDelta& timestamp) { | 284 void set_timestamp(const base::TimeDelta& timestamp) { |
261 timestamp_ = timestamp; | 285 timestamp_ = timestamp; |
262 } | 286 } |
263 | 287 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 | 357 |
334 // Shared memory handle, if this frame was allocated from shared memory. | 358 // Shared memory handle, if this frame was allocated from shared memory. |
335 base::SharedMemoryHandle shared_memory_handle_; | 359 base::SharedMemoryHandle shared_memory_handle_; |
336 | 360 |
337 #if defined(OS_POSIX) | 361 #if defined(OS_POSIX) |
338 // Dmabufs for each plane, if this frame is wrapping memory | 362 // Dmabufs for each plane, if this frame is wrapping memory |
339 // acquired via dmabuf. | 363 // acquired via dmabuf. |
340 base::ScopedFD dmabuf_fds_[kMaxPlanes]; | 364 base::ScopedFD dmabuf_fds_[kMaxPlanes]; |
341 #endif | 365 #endif |
342 | 366 |
367 #if defined(OS_MACOSX) | |
368 // CVPixelBuffer, if this frame is wrapping one. | |
369 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; | |
370 #endif | |
371 | |
343 base::Closure no_longer_needed_cb_; | 372 base::Closure no_longer_needed_cb_; |
344 | 373 |
345 base::TimeDelta timestamp_; | 374 base::TimeDelta timestamp_; |
346 | 375 |
347 base::Lock release_sync_point_lock_; | 376 base::Lock release_sync_point_lock_; |
348 uint32 release_sync_point_; | 377 uint32 release_sync_point_; |
349 | 378 |
350 const bool end_of_stream_; | 379 const bool end_of_stream_; |
351 | 380 |
352 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 381 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
353 }; | 382 }; |
354 | 383 |
355 } // namespace media | 384 } // namespace media |
356 | 385 |
357 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 386 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |