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..e6f98f53bab05f2d97c16c173861f12e3e14e3f0 100644 |
--- a/media/base/video_frame_pool.cc |
+++ b/media/base/video_frame_pool.cc |
@@ -23,7 +23,8 @@ class VideoFramePool::PoolImpl |
const gfx::Size& coded_size, |
const gfx::Rect& visible_rect, |
const gfx::Size& natural_size, |
- base::TimeDelta timestamp); |
+ base::TimeDelta timestamp, |
+ VideoFramePoolDelegate* delegate); |
// 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 +60,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, |
+ VideoFramePoolDelegate* delegate) { |
base::AutoLock auto_lock(lock_); |
DCHECK(!is_shutdown_); |
@@ -80,8 +82,14 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame( |
} |
if (!frame.get()) { |
- frame = VideoFrame::CreateZeroInitializedFrame( |
- format, coded_size, visible_rect, natural_size, timestamp); |
+ if (delegate) { |
+ frame = delegate->CreateZeroInitializedFrame( |
+ format, coded_size, visible_rect, natural_size, timestamp); |
+ } else { |
sandersd (OOO until July 31)
2016/12/15 00:38:01
These conditions can be removed by creating a defa
|
+ frame = VideoFrame::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 +97,14 @@ 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; |
+ if (delegate) { |
+ wrapped_frame = delegate->WrapVideoFrame(frame); |
+ } else { |
+ wrapped_frame = VideoFrame::WrapVideoFrame( |
+ frame, frame->format(), frame->visible_rect(), frame->natural_size()); |
+ } |
+ |
wrapped_frame->AddDestructionObserver( |
base::Bind(&VideoFramePool::PoolImpl::FrameReleased, this, frame)); |
return wrapped_frame; |
@@ -111,8 +125,7 @@ void VideoFramePool::PoolImpl::FrameReleased( |
frames_.push_back(frame); |
} |
-VideoFramePool::VideoFramePool() : pool_(new PoolImpl()) { |
-} |
+VideoFramePool::VideoFramePool() : pool_(new PoolImpl()), delegate_(nullptr) {} |
VideoFramePool::~VideoFramePool() { |
pool_->Shutdown(); |
@@ -125,7 +138,12 @@ 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, delegate_.get()); |
+} |
+ |
+void VideoFramePool::SetDelegate( |
+ std::unique_ptr<VideoFramePoolDelegate> delegate) { |
+ delegate_ = std::move(delegate); |
} |
size_t VideoFramePool::GetPoolSizeForTesting() const { |