Index: media/video/gpu_memory_buffer_video_frame_pool.h |
diff --git a/media/video/gpu_memory_buffer_video_frame_pool.h b/media/video/gpu_memory_buffer_video_frame_pool.h |
index ed4b3617e53cd39b0cf78d7f7dd7e6b9d16ddd47..901bb138c149b7162fc328439af39325ceecb892 100644 |
--- a/media/video/gpu_memory_buffer_video_frame_pool.h |
+++ b/media/video/gpu_memory_buffer_video_frame_pool.h |
@@ -7,7 +7,6 @@ |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
-#include "base/task_runner.h" |
#include "media/base/video_frame.h" |
namespace base { |
@@ -17,8 +16,37 @@ class SingleThreadTaskRunner; |
namespace media { |
class GpuVideoAcceleratorFactories; |
-// Interface to a pool of GpuMemoryBuffers/textures/images that can be used to |
-// transform software VideoFrames to VideoFrames backed by native textures. |
+// A VideoFrameFuture allows to access GpuMemoryBuffer memory. When finishing |
+// to use the instance, it will be released as a VideoFrame instance. |
+// EXAMPLE: |
+// |
+// std::unique_ptr<VideoFrameFuture> video_frame_future = |
+// video_frame_pool_->CreateFrame(PIXEL_FORMAT_I420, coded_size, |
+// visible_rect, natural_size, timestamp); |
+// |
+// // Decode into or encode from |video_frame_future->data(plane)| |
+// |
+// // Release as a VideoFrame backed by native textures. |
+// scoped_refptr<VideoFrame> video_frame = video_frame_future->Release(); |
+// |
+// After released, all the VideoFrameFuture instance can do is destruction. |
+class MEDIA_EXPORT VideoFrameFuture { |
+ public: |
+ virtual ~VideoFrameFuture() {} |
+ virtual scoped_refptr<VideoFrame> Release() = 0; |
+ virtual uint8_t* data(size_t plane) const = 0; |
+ virtual int stride(size_t plane) const = 0; |
+ virtual const gfx::Size& coded_size() const = 0; |
+ |
+ protected: |
+ VideoFrameFuture() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(VideoFrameFuture); |
+}; |
+ |
+// Interface to a pool of GpuMemoryBuffers/textures/images which produces |
+// VideoFrames backed by native textures. |
// The resources used by the VideoFrame created by the pool will be |
// automatically put back into the pool once the frame is destroyed. |
// The pool recycles resources to a void unnecessarily allocating and |
@@ -26,27 +54,26 @@ class GpuVideoAcceleratorFactories; |
// in a round trip to the browser/GPU process. |
class MEDIA_EXPORT GpuMemoryBufferVideoFramePool { |
public: |
- GpuMemoryBufferVideoFramePool(); |
GpuMemoryBufferVideoFramePool( |
const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
- const scoped_refptr<base::TaskRunner>& worker_task_runner, |
GpuVideoAcceleratorFactories* gpu_factories); |
virtual ~GpuMemoryBufferVideoFramePool(); |
- // Callback used by MaybeCreateHardwareFrame to deliver a new VideoFrame |
- // after it has been copied to GpuMemoryBuffers. |
- typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> FrameReadyCB; |
- |
- // Calls |cb| on |media_worker_pool| with a new VideoFrame containing only |
- // mailboxes to native resources. |cb| will be destroyed on |
- // |media_worker_pool|. |
- // The content of the new object is copied from the software-allocated |
- // |video_frame|. |
- // If it's not possible to create a new hardware VideoFrame, |video_frame| |
- // itself will passed to |cb|. |
- virtual void MaybeCreateHardwareFrame( |
- const scoped_refptr<VideoFrame>& video_frame, |
- const FrameReadyCB& frame_ready_cb); |
+ // Create VideoFrameFuture backed by native textures. |
+ std::unique_ptr<VideoFrameFuture> CreateFrame(VideoPixelFormat format, |
+ const gfx::Size& coded_size, |
+ const gfx::Rect& visible_rect, |
+ const gfx::Size& natural_size, |
+ base::TimeDelta timestamp); |
+ |
+ // The number of output planes to be copied in each iteration. |
+ static size_t PlanesPerCopy(VideoPixelFormat format, size_t plane); |
+ |
+ protected: |
+ friend class GpuMemoryBufferVideoFramePoolTest; |
+ |
+ // Returns the number of frames in the pool for testing purposes. |
+ size_t GetPoolSizeForTesting() const; |
private: |
class PoolImpl; |