| Index: media/base/video_frame_pool.cc
|
| diff --git a/media/base/video_frame_pool.cc b/media/base/video_frame_pool.cc
|
| index e117251187436bd4cd271830b607f9f857e15757..ba6aa64bab923b3aacdd2d5ad3894405f7048bf4 100644
|
| --- a/media/base/video_frame_pool.cc
|
| +++ b/media/base/video_frame_pool.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/synchronization/lock.h"
|
| +#include "media/video/default_video_frame_provider.h"
|
|
|
| namespace media {
|
|
|
| @@ -19,11 +20,13 @@ class VideoFramePool::PoolImpl
|
| PoolImpl();
|
|
|
| // See VideoFramePool::CreateFrame() for usage.
|
| - scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format,
|
| - const gfx::Size& coded_size,
|
| - const gfx::Rect& visible_rect,
|
| - const gfx::Size& natural_size,
|
| - base::TimeDelta timestamp);
|
| + scoped_refptr<VideoFrame> CreateFrame(
|
| + VideoPixelFormat format,
|
| + const gfx::Size& coded_size,
|
| + const gfx::Rect& visible_rect,
|
| + const gfx::Size& natural_size,
|
| + base::TimeDelta timestamp,
|
| + VideoFrameProvider* video_frame_provider);
|
|
|
| // Shuts down the frame pool and releases all frames in |frames_|.
|
| // Once this is called frames will no longer be inserted back into
|
| @@ -59,7 +62,8 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame(
|
| const gfx::Size& coded_size,
|
| const gfx::Rect& visible_rect,
|
| const gfx::Size& natural_size,
|
| - base::TimeDelta timestamp) {
|
| + base::TimeDelta timestamp,
|
| + VideoFrameProvider* video_frame_provider) {
|
| base::AutoLock auto_lock(lock_);
|
| DCHECK(!is_shutdown_);
|
|
|
| @@ -80,8 +84,9 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame(
|
| }
|
|
|
| if (!frame.get()) {
|
| - frame = VideoFrame::CreateZeroInitializedFrame(
|
| + frame = video_frame_provider->CreateZeroInitializedFrame(
|
| format, coded_size, visible_rect, natural_size, timestamp);
|
| +
|
| // This can happen if the arguments are not valid.
|
| if (!frame) {
|
| LOG(ERROR) << "Failed to create a video frame";
|
| @@ -89,8 +94,8 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame(
|
| }
|
| }
|
|
|
| - scoped_refptr<VideoFrame> wrapped_frame = VideoFrame::WrapVideoFrame(
|
| - frame, frame->format(), frame->visible_rect(), frame->natural_size());
|
| + scoped_refptr<VideoFrame> wrapped_frame =
|
| + video_frame_provider->WrapVideoFrame(frame);
|
| wrapped_frame->AddDestructionObserver(
|
| base::Bind(&VideoFramePool::PoolImpl::FrameReleased, this, frame));
|
| return wrapped_frame;
|
| @@ -111,8 +116,14 @@ void VideoFramePool::PoolImpl::FrameReleased(
|
| frames_.push_back(frame);
|
| }
|
|
|
| -VideoFramePool::VideoFramePool() : pool_(new PoolImpl()) {
|
| -}
|
| +VideoFramePool::VideoFramePool()
|
| + : video_frame_provider_(new DefaultVideoFrameProvider()),
|
| + pool_(new PoolImpl()) {}
|
| +
|
| +VideoFramePool::VideoFramePool(
|
| + std::unique_ptr<VideoFrameProvider> video_frame_provider)
|
| + : video_frame_provider_(std::move(video_frame_provider)),
|
| + pool_(new PoolImpl()) {}
|
|
|
| VideoFramePool::~VideoFramePool() {
|
| pool_->Shutdown();
|
| @@ -125,7 +136,7 @@ scoped_refptr<VideoFrame> VideoFramePool::CreateFrame(
|
| const gfx::Size& natural_size,
|
| base::TimeDelta timestamp) {
|
| return pool_->CreateFrame(format, coded_size, visible_rect, natural_size,
|
| - timestamp);
|
| + timestamp, video_frame_provider_.get());
|
| }
|
|
|
| size_t VideoFramePool::GetPoolSizeForTesting() const {
|
|
|