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" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // frame is destroyed, |no_longer_needed_cb.Run()| will be called. | 132 // frame is destroyed, |no_longer_needed_cb.Run()| will be called. |
133 // Returns NULL on failure. | 133 // Returns NULL on failure. |
134 static scoped_refptr<VideoFrame> WrapExternalPackedMemory( | 134 static scoped_refptr<VideoFrame> WrapExternalPackedMemory( |
135 Format format, | 135 Format format, |
136 const gfx::Size& coded_size, | 136 const gfx::Size& coded_size, |
137 const gfx::Rect& visible_rect, | 137 const gfx::Rect& visible_rect, |
138 const gfx::Size& natural_size, | 138 const gfx::Size& natural_size, |
139 uint8* data, | 139 uint8* data, |
140 size_t data_size, | 140 size_t data_size, |
141 base::SharedMemoryHandle handle, | 141 base::SharedMemoryHandle handle, |
| 142 size_t shared_memory_offset, |
142 base::TimeDelta timestamp, | 143 base::TimeDelta timestamp, |
143 const base::Closure& no_longer_needed_cb); | 144 const base::Closure& no_longer_needed_cb); |
144 | 145 |
145 #if defined(OS_POSIX) | 146 #if defined(OS_POSIX) |
146 // Wraps provided dmabufs | 147 // Wraps provided dmabufs |
147 // (https://www.kernel.org/doc/Documentation/dma-buf-sharing.txt) with a | 148 // (https://www.kernel.org/doc/Documentation/dma-buf-sharing.txt) with a |
148 // VideoFrame. The dmabuf fds are dup()ed on creation, so that the VideoFrame | 149 // VideoFrame. The dmabuf fds are dup()ed on creation, so that the VideoFrame |
149 // retains a reference to them, and are automatically close()d on destruction, | 150 // retains a reference to them, and are automatically close()d on destruction, |
150 // dropping the reference. The caller may safely close() its reference after | 151 // dropping the reference. The caller may safely close() its reference after |
151 // calling WrapExternalDmabufs(). | 152 // calling WrapExternalDmabufs(). |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 uint8* visible_data(size_t plane); | 294 uint8* visible_data(size_t plane); |
294 | 295 |
295 // Returns the mailbox holder of the native texture wrapped by this frame. | 296 // Returns the mailbox holder of the native texture wrapped by this frame. |
296 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the | 297 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the |
297 // mailbox, the caller must wait for the included sync point. | 298 // mailbox, the caller must wait for the included sync point. |
298 const gpu::MailboxHolder* mailbox_holder() const; | 299 const gpu::MailboxHolder* mailbox_holder() const; |
299 | 300 |
300 // Returns the shared-memory handle, if present | 301 // Returns the shared-memory handle, if present |
301 base::SharedMemoryHandle shared_memory_handle() const; | 302 base::SharedMemoryHandle shared_memory_handle() const; |
302 | 303 |
| 304 // Returns the offset into the shared memory where the frame data begins. |
| 305 size_t shared_memory_offset() const; |
| 306 |
303 bool allow_overlay() const { return allow_overlay_; } | 307 bool allow_overlay() const { return allow_overlay_; } |
304 | 308 |
305 #if defined(OS_POSIX) | 309 #if defined(OS_POSIX) |
306 // Returns backing dmabuf file descriptor for given |plane|, if present. | 310 // Returns backing dmabuf file descriptor for given |plane|, if present. |
307 int dmabuf_fd(size_t plane) const; | 311 int dmabuf_fd(size_t plane) const; |
308 #endif | 312 #endif |
309 | 313 |
310 #if defined(OS_MACOSX) | 314 #if defined(OS_MACOSX) |
311 // Returns the backing CVPixelBuffer, if present. | 315 // Returns the backing CVPixelBuffer, if present. |
312 CVPixelBufferRef cv_pixel_buffer() const; | 316 CVPixelBufferRef cv_pixel_buffer() const; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 uint8* data_[kMaxPlanes]; | 390 uint8* data_[kMaxPlanes]; |
387 | 391 |
388 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. | 392 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. |
389 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_; | 393 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_; |
390 ReleaseMailboxCB mailbox_holder_release_cb_; | 394 ReleaseMailboxCB mailbox_holder_release_cb_; |
391 ReadPixelsCB read_pixels_cb_; | 395 ReadPixelsCB read_pixels_cb_; |
392 | 396 |
393 // Shared memory handle, if this frame was allocated from shared memory. | 397 // Shared memory handle, if this frame was allocated from shared memory. |
394 base::SharedMemoryHandle shared_memory_handle_; | 398 base::SharedMemoryHandle shared_memory_handle_; |
395 | 399 |
| 400 // Offset in shared memory buffer. |
| 401 size_t shared_memory_offset_; |
| 402 |
396 #if defined(OS_POSIX) | 403 #if defined(OS_POSIX) |
397 // Dmabufs for each plane, if this frame is wrapping memory | 404 // Dmabufs for each plane, if this frame is wrapping memory |
398 // acquired via dmabuf. | 405 // acquired via dmabuf. |
399 base::ScopedFD dmabuf_fds_[kMaxPlanes]; | 406 base::ScopedFD dmabuf_fds_[kMaxPlanes]; |
400 #endif | 407 #endif |
401 | 408 |
402 #if defined(OS_MACOSX) | 409 #if defined(OS_MACOSX) |
403 // CVPixelBuffer, if this frame is wrapping one. | 410 // CVPixelBuffer, if this frame is wrapping one. |
404 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; | 411 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; |
405 #endif | 412 #endif |
406 | 413 |
407 base::Closure no_longer_needed_cb_; | 414 base::Closure no_longer_needed_cb_; |
408 | 415 |
409 base::TimeDelta timestamp_; | 416 base::TimeDelta timestamp_; |
410 | 417 |
411 base::Lock release_sync_point_lock_; | 418 base::Lock release_sync_point_lock_; |
412 uint32 release_sync_point_; | 419 uint32 release_sync_point_; |
413 | 420 |
414 const bool end_of_stream_; | 421 const bool end_of_stream_; |
415 | 422 |
416 bool allow_overlay_; | 423 bool allow_overlay_; |
417 | 424 |
418 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 425 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
419 }; | 426 }; |
420 | 427 |
421 } // namespace media | 428 } // namespace media |
422 | 429 |
423 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 430 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |