diff options
author | jfroy <jfroy@chromium.org> | 2014-08-26 16:12:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-26 23:13:11 +0000 |
commit | 7eef1763b2118e82ed463e7414066e51690fbe53 (patch) | |
tree | 94955d1f9a379f891fb98d9deaafaf64788fd78e /media/base/video_frame.h | |
parent | d4cb64a052766516bc651d95fbdce06a015aac8a (diff) | |
download | chromium_src-7eef1763b2118e82ed463e7414066e51690fbe53.zip chromium_src-7eef1763b2118e82ed463e7414066e51690fbe53.tar.gz chromium_src-7eef1763b2118e82ed463e7414066e51690fbe53.tar.bz2 |
Extend media::VideoFrame to wrap CVPixelBuffer on OS X and iOS.
This allows better integration of OS X and iOS media frameworks
with chromium code and makes buffer management less problematic,
especially when using CVPixelBufferPools provided by hardware
encoders or decoders.
BUG=401308
R=dalecurtis,hubbe
Review URL: https://codereview.chromium.org/446163003
Cr-Commit-Position: refs/heads/master@{#292023}
Diffstat (limited to 'media/base/video_frame.h')
-rw-r--r-- | media/base/video_frame.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/media/base/video_frame.h b/media/base/video_frame.h index 9ad9a3d..1ea2600 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -15,6 +15,11 @@ #include "ui/gfx/rect.h" #include "ui/gfx/size.h" +#if defined(OS_MACOSX) +#include <CoreVideo/CVPixelBuffer.h> +#include "base/mac/scoped_cftyperef.h" +#endif + class SkBitmap; namespace gpu { @@ -148,6 +153,20 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { const base::Closure& no_longer_needed_cb); #endif +#if defined(OS_MACOSX) + // Wraps a provided CVPixelBuffer with a VideoFrame. The pixel buffer is + // retained for the lifetime of the VideoFrame and released upon destruction. + // The image data is only accessible via the pixel buffer, which could be + // backed by an IOSurface from another process. All the attributes of the + // VideoFrame are derived from the pixel buffer, with the exception of the + // timestamp. If information is missing or is incompatible (for example, a + // pixel format that has no VideoFrame match), NULL is returned. + // http://crbug.com/401308 + static scoped_refptr<VideoFrame> WrapCVPixelBuffer( + CVPixelBufferRef cv_pixel_buffer, + base::TimeDelta timestamp); +#endif + // Wraps external YUV data of the given parameters with a VideoFrame. // The returned VideoFrame does not own the data passed in. When the frame // is destroyed |no_longer_needed_cb.Run()| will be called. @@ -255,6 +274,11 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { int dmabuf_fd(size_t plane) const; #endif +#if defined(OS_MACOSX) + // Returns the backing CVPixelBuffer, if present. + CVPixelBufferRef cv_pixel_buffer() const; +#endif + // Returns true if this VideoFrame represents the end of the stream. bool end_of_stream() const { return end_of_stream_; } @@ -346,6 +370,11 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { base::ScopedFD dmabuf_fds_[kMaxPlanes]; #endif +#if defined(OS_MACOSX) + // CVPixelBuffer, if this frame is wrapping one. + base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; +#endif + base::Closure no_longer_needed_cb_; base::TimeDelta timestamp_; |