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

Unified Diff: media/base/video_frame_pool.cc

Issue 2643733002: Allow to use {FFmpeg/Vpx}VideoDecoder from a UtilityProcess (Closed)
Patch Set: Rebase Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_frame_pool.h ('k') | media/base/video_frame_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « media/base/video_frame_pool.h ('k') | media/base/video_frame_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698