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

Side by Side Diff: media/base/video_frame.h

Issue 2395913003: Cleanup of passing GpuMemoryBuffer backed video frames (Closed)
Patch Set: Rebase Created 4 years, 2 months 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
« no previous file with comments | « content/renderer/media/webrtc/webrtc_video_frame_adapter.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/md5.h" 17 #include "base/md5.h"
18 #include "base/memory/shared_memory.h" 18 #include "base/memory/shared_memory.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "gpu/command_buffer/common/mailbox_holder.h" 21 #include "gpu/command_buffer/common/mailbox_holder.h"
22 #include "media/base/video_frame_metadata.h" 22 #include "media/base/video_frame_metadata.h"
23 #include "media/base/video_types.h" 23 #include "media/base/video_types.h"
24 #include "ui/gfx/color_space.h" 24 #include "ui/gfx/color_space.h"
25 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/geometry/size.h" 26 #include "ui/gfx/geometry/size.h"
27 #include "ui/gfx/gpu_memory_buffer.h"
28 27
29 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
30 #include <CoreVideo/CVPixelBuffer.h> 29 #include <CoreVideo/CVPixelBuffer.h>
31 #include "base/mac/scoped_cftyperef.h" 30 #include "base/mac/scoped_cftyperef.h"
32 #endif 31 #endif
33 32
34 namespace media { 33 namespace media {
35 34
36 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 35 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
37 public: 36 public:
(...skipping 23 matching lines...) Expand all
61 STORAGE_UNKNOWN = 0, 60 STORAGE_UNKNOWN = 0,
62 STORAGE_OPAQUE = 1, // We don't know how VideoFrame's pixels are stored. 61 STORAGE_OPAQUE = 1, // We don't know how VideoFrame's pixels are stored.
63 STORAGE_UNOWNED_MEMORY = 2, // External, non owned data pointers. 62 STORAGE_UNOWNED_MEMORY = 2, // External, non owned data pointers.
64 STORAGE_OWNED_MEMORY = 3, // VideoFrame has allocated its own data buffer. 63 STORAGE_OWNED_MEMORY = 3, // VideoFrame has allocated its own data buffer.
65 STORAGE_SHMEM = 4, // Pixels are backed by Shared Memory. 64 STORAGE_SHMEM = 4, // Pixels are backed by Shared Memory.
66 #if defined(OS_LINUX) 65 #if defined(OS_LINUX)
67 // TODO(mcasas): Consider turning this type into STORAGE_NATIVE or another 66 // TODO(mcasas): Consider turning this type into STORAGE_NATIVE or another
68 // meaningful name and handle it appropriately in all cases. 67 // meaningful name and handle it appropriately in all cases.
69 STORAGE_DMABUFS = 5, // Each plane is stored into a DmaBuf. 68 STORAGE_DMABUFS = 5, // Each plane is stored into a DmaBuf.
70 #endif 69 #endif
71 STORAGE_GPU_MEMORY_BUFFERS = 6, 70 STORAGE_MOJO_SHARED_BUFFER = 6,
72 STORAGE_MOJO_SHARED_BUFFER = 7,
73 STORAGE_LAST = STORAGE_MOJO_SHARED_BUFFER, 71 STORAGE_LAST = STORAGE_MOJO_SHARED_BUFFER,
74 }; 72 };
75 73
76 // CB to be called on the mailbox backing this frame when the frame is 74 // CB to be called on the mailbox backing this frame when the frame is
77 // destroyed. 75 // destroyed.
78 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB; 76 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB;
79 77
80 // Interface representing client operations on a SyncToken, i.e. insert one in 78 // Interface representing client operations on a SyncToken, i.e. insert one in
81 // the GPU Command Buffer and wait for it. 79 // the GPU Command Buffer and wait for it.
82 class SyncTokenClient { 80 class SyncTokenClient {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const gfx::Rect& visible_rect, 162 const gfx::Rect& visible_rect,
165 const gfx::Size& natural_size, 163 const gfx::Size& natural_size,
166 int32_t y_stride, 164 int32_t y_stride,
167 int32_t u_stride, 165 int32_t u_stride,
168 int32_t v_stride, 166 int32_t v_stride,
169 uint8_t* y_data, 167 uint8_t* y_data,
170 uint8_t* u_data, 168 uint8_t* u_data,
171 uint8_t* v_data, 169 uint8_t* v_data,
172 base::TimeDelta timestamp); 170 base::TimeDelta timestamp);
173 171
174 // Wraps external YUV data with the given parameters with a VideoFrame.
175 // The returned VideoFrame does not own the GpuMemoryBuffers passed in.
176 static scoped_refptr<VideoFrame> WrapExternalYuvGpuMemoryBuffers(
177 VideoPixelFormat format,
178 const gfx::Size& coded_size,
179 const gfx::Rect& visible_rect,
180 const gfx::Size& natural_size,
181 int32_t y_stride,
182 int32_t u_stride,
183 int32_t v_stride,
184 uint8_t* y_data,
185 uint8_t* u_data,
186 uint8_t* v_data,
187 const gfx::GpuMemoryBufferHandle& y_handle,
188 const gfx::GpuMemoryBufferHandle& u_handle,
189 const gfx::GpuMemoryBufferHandle& v_handle,
190 base::TimeDelta timestamp);
191
192 // Wraps external YUVA data of the given parameters with a VideoFrame. 172 // Wraps external YUVA data of the given parameters with a VideoFrame.
193 // The returned VideoFrame does not own the data passed in. 173 // The returned VideoFrame does not own the data passed in.
194 static scoped_refptr<VideoFrame> WrapExternalYuvaData( 174 static scoped_refptr<VideoFrame> WrapExternalYuvaData(
195 VideoPixelFormat format, 175 VideoPixelFormat format,
196 const gfx::Size& coded_size, 176 const gfx::Size& coded_size,
197 const gfx::Rect& visible_rect, 177 const gfx::Rect& visible_rect,
198 const gfx::Size& natural_size, 178 const gfx::Size& natural_size,
199 int32_t y_stride, 179 int32_t y_stride,
200 int32_t u_stride, 180 int32_t u_stride,
201 int32_t v_stride, 181 int32_t v_stride,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the 329 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the
350 // mailbox, the caller must wait for the included sync point. 330 // mailbox, the caller must wait for the included sync point.
351 const gpu::MailboxHolder& mailbox_holder(size_t texture_index) const; 331 const gpu::MailboxHolder& mailbox_holder(size_t texture_index) const;
352 332
353 // Returns the shared-memory handle, if present 333 // Returns the shared-memory handle, if present
354 base::SharedMemoryHandle shared_memory_handle() const; 334 base::SharedMemoryHandle shared_memory_handle() const;
355 335
356 // Returns the offset into the shared memory where the frame data begins. 336 // Returns the offset into the shared memory where the frame data begins.
357 size_t shared_memory_offset() const; 337 size_t shared_memory_offset() const;
358 338
359 // Returns the vector of GpuMemoryBuffer handles, if present.
360 const std::vector<gfx::GpuMemoryBufferHandle>& gpu_memory_buffer_handles()
361 const;
362
363 #if defined(OS_LINUX) 339 #if defined(OS_LINUX)
364 // Returns backing DmaBuf file descriptor for given |plane|, if present, or 340 // Returns backing DmaBuf file descriptor for given |plane|, if present, or
365 // -1 if not. 341 // -1 if not.
366 // TODO(mcasas): Rename to DmabufFd() to comply with Style Guide. 342 // TODO(mcasas): Rename to DmabufFd() to comply with Style Guide.
367 int dmabuf_fd(size_t plane) const; 343 int dmabuf_fd(size_t plane) const;
368 344
369 // Duplicates internally the |fds_in|, overwriting the current ones. Returns 345 // Duplicates internally the |fds_in|, overwriting the current ones. Returns
370 // false if something goes wrong, and leaves all internal fds closed. 346 // false if something goes wrong, and leaves all internal fds closed.
371 bool DuplicateFileDescriptors(const std::vector<int>& fds_in); 347 bool DuplicateFileDescriptors(const std::vector<int>& fds_in);
372 #endif 348 #endif
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 512
537 // Native texture mailboxes, if this is a IsTexture() frame. 513 // Native texture mailboxes, if this is a IsTexture() frame.
538 gpu::MailboxHolder mailbox_holders_[kMaxPlanes]; 514 gpu::MailboxHolder mailbox_holders_[kMaxPlanes];
539 ReleaseMailboxCB mailbox_holders_release_cb_; 515 ReleaseMailboxCB mailbox_holders_release_cb_;
540 516
541 // Shared memory handle and associated offset inside it, if this frame is 517 // Shared memory handle and associated offset inside it, if this frame is
542 // a STORAGE_SHMEM one. 518 // a STORAGE_SHMEM one.
543 base::SharedMemoryHandle shared_memory_handle_; 519 base::SharedMemoryHandle shared_memory_handle_;
544 size_t shared_memory_offset_; 520 size_t shared_memory_offset_;
545 521
546 // GpuMemoryBuffer handles attached to the video_frame.
547 std::vector<gfx::GpuMemoryBufferHandle> gpu_memory_buffer_handles_;
548
549 #if defined(OS_LINUX) 522 #if defined(OS_LINUX)
550 // Dmabufs for each plane. If set, this frame has DmaBuf backing in some way. 523 // Dmabufs for each plane. If set, this frame has DmaBuf backing in some way.
551 base::ScopedFD dmabuf_fds_[kMaxPlanes]; 524 base::ScopedFD dmabuf_fds_[kMaxPlanes];
552 #endif 525 #endif
553 526
554 #if defined(OS_MACOSX) 527 #if defined(OS_MACOSX)
555 // CVPixelBuffer, if this frame is wrapping one. 528 // CVPixelBuffer, if this frame is wrapping one.
556 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; 529 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_;
557 #endif 530 #endif
558 531
(...skipping 10 matching lines...) Expand all
569 const int unique_id_; 542 const int unique_id_;
570 543
571 gfx::ColorSpace color_space_; 544 gfx::ColorSpace color_space_;
572 545
573 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 546 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
574 }; 547 };
575 548
576 } // namespace media 549 } // namespace media
577 550
578 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 551 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/webrtc_video_frame_adapter.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698