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

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

Issue 446163003: Extend media::VideoFrame to wrap CVPixelBuffer on OS X and iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « no previous file | media/base/video_frame.cc » ('j') | media/base/video_frame.cc » ('J')
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 <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 "base/mac/scoped_cftyperef.h"
22
23 // From CoreVideo headers
Robert Sesek 2014/08/07 16:12:57 Why can't you just include CoreVideo.h here?
jfroy 2014/08/07 16:22:14 I thought the general guideline in chromium code w
Robert Sesek 2014/08/07 16:34:42 No, don't forward-declare system types unless you
jfroy 2014/08/07 16:52:46 Acknowledged.
24 typedef struct __CVBuffer *CVBufferRef;
25 typedef CVBufferRef CVImageBufferRef;
26 typedef CVImageBufferRef CVPixelBufferRef;
27 #endif
28
20 namespace gpu { 29 namespace gpu {
21 struct MailboxHolder; 30 struct MailboxHolder;
22 } // namespace gpu 31 } // namespace gpu
23 32
24 namespace media { 33 namespace media {
25 34
26 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 35 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
27 public: 36 public:
28 enum { 37 enum {
29 kFrameSizeAlignment = 16, 38 kFrameSizeAlignment = 16,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 static scoped_refptr<VideoFrame> WrapExternalDmabufs( 150 static scoped_refptr<VideoFrame> WrapExternalDmabufs(
142 Format format, 151 Format format,
143 const gfx::Size& coded_size, 152 const gfx::Size& coded_size,
144 const gfx::Rect& visible_rect, 153 const gfx::Rect& visible_rect,
145 const gfx::Size& natural_size, 154 const gfx::Size& natural_size,
146 const std::vector<int> dmabuf_fds, 155 const std::vector<int> dmabuf_fds,
147 base::TimeDelta timestamp, 156 base::TimeDelta timestamp,
148 const base::Closure& no_longer_needed_cb); 157 const base::Closure& no_longer_needed_cb);
149 #endif 158 #endif
150 159
160 #if defined(OS_MACOSX)
161 // Wraps provided CVPixelBuffer with a VideoFrame. The pixel buffer is
162 // retained for the lifetime of the VideoFrame and released upon destruction.
163 // The image data is only accessible via the pixel buffer, which could be
164 // backed by an IOSurface from another process. All the attributes of the
165 // VideoFrame are derived from pixel buffer, with the exception of the
166 // timestamp. If information is missing or is incompatible (for example, a
167 // pixel format that has no VideoFrame match), null is returned.
168 // http://crbug.com/401308
169 static scoped_refptr<VideoFrame> WrapCVPixelBuffer(
170 CVPixelBufferRef cv_pixel_buffer,
171 base::TimeDelta timestamp);
172 #endif
173
151 // Wraps external YUV data of the given parameters with a VideoFrame. 174 // 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 175 // The returned VideoFrame does not own the data passed in. When the frame
153 // is destroyed |no_longer_needed_cb.Run()| will be called. 176 // is destroyed |no_longer_needed_cb.Run()| will be called.
154 // TODO(sheu): merge this into WrapExternalSharedMemory(). 177 // TODO(sheu): merge this into WrapExternalSharedMemory().
155 // http://crbug.com/270217 178 // http://crbug.com/270217
156 static scoped_refptr<VideoFrame> WrapExternalYuvData( 179 static scoped_refptr<VideoFrame> WrapExternalYuvData(
157 Format format, 180 Format format,
158 const gfx::Size& coded_size, 181 const gfx::Size& coded_size,
159 const gfx::Rect& visible_rect, 182 const gfx::Rect& visible_rect,
160 const gfx::Size& natural_size, 183 const gfx::Size& natural_size,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const gpu::MailboxHolder* mailbox_holder() const; 267 const gpu::MailboxHolder* mailbox_holder() const;
245 268
246 // Returns the shared-memory handle, if present 269 // Returns the shared-memory handle, if present
247 base::SharedMemoryHandle shared_memory_handle() const; 270 base::SharedMemoryHandle shared_memory_handle() const;
248 271
249 #if defined(OS_POSIX) 272 #if defined(OS_POSIX)
250 // Returns backing dmabuf file descriptor for given |plane|, if present. 273 // Returns backing dmabuf file descriptor for given |plane|, if present.
251 int dmabuf_fd(size_t plane) const; 274 int dmabuf_fd(size_t plane) const;
252 #endif 275 #endif
253 276
277 #if defined(OS_MACOSX)
278 // Returns the backing CVPixelBuffer, if present.
279 CVPixelBufferRef cv_pixel_buffer() const;
280 #endif
281
254 // Returns true if this VideoFrame represents the end of the stream. 282 // Returns true if this VideoFrame represents the end of the stream.
255 bool end_of_stream() const { return end_of_stream_; } 283 bool end_of_stream() const { return end_of_stream_; }
256 284
257 base::TimeDelta timestamp() const { 285 base::TimeDelta timestamp() const {
258 return timestamp_; 286 return timestamp_;
259 } 287 }
260 void set_timestamp(const base::TimeDelta& timestamp) { 288 void set_timestamp(const base::TimeDelta& timestamp) {
261 timestamp_ = timestamp; 289 timestamp_ = timestamp;
262 } 290 }
263 291
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 361
334 // Shared memory handle, if this frame was allocated from shared memory. 362 // Shared memory handle, if this frame was allocated from shared memory.
335 base::SharedMemoryHandle shared_memory_handle_; 363 base::SharedMemoryHandle shared_memory_handle_;
336 364
337 #if defined(OS_POSIX) 365 #if defined(OS_POSIX)
338 // Dmabufs for each plane, if this frame is wrapping memory 366 // Dmabufs for each plane, if this frame is wrapping memory
339 // acquired via dmabuf. 367 // acquired via dmabuf.
340 base::ScopedFD dmabuf_fds_[kMaxPlanes]; 368 base::ScopedFD dmabuf_fds_[kMaxPlanes];
341 #endif 369 #endif
342 370
371 #if defined(OS_MACOSX)
372 // CVPixelBuffer, if this frame is wrapping one.
373 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_;
374 #endif
375
343 base::Closure no_longer_needed_cb_; 376 base::Closure no_longer_needed_cb_;
344 377
345 base::TimeDelta timestamp_; 378 base::TimeDelta timestamp_;
346 379
347 base::Lock release_sync_point_lock_; 380 base::Lock release_sync_point_lock_;
348 uint32 release_sync_point_; 381 uint32 release_sync_point_;
349 382
350 const bool end_of_stream_; 383 const bool end_of_stream_;
351 384
352 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 385 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
353 }; 386 };
354 387
355 } // namespace media 388 } // namespace media
356 389
357 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 390 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/video_frame.cc » ('j') | media/base/video_frame.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698