summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 05:58:50 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 05:58:50 +0000
commit51a518e0c82679f770d2413a254924a4eb64892c (patch)
tree465f5ce50b51a280a0f538e6bb1615bf3cf88cc1 /content
parentd8d7e6fb15310ab21200a51d70e0d01f05e782be (diff)
downloadchromium_src-51a518e0c82679f770d2413a254924a4eb64892c.zip
chromium_src-51a518e0c82679f770d2413a254924a4eb64892c.tar.gz
chromium_src-51a518e0c82679f770d2413a254924a4eb64892c.tar.bz2
Pass Client pointer in Initialize() for VDA/VEA
Wait until Initialize() is called on a Video{Decode,Encode}Accelerator to pass in its Client pointer. This is done to better separate the construction and initialization of the VDA/VEA, so its Client does not have to guarantee its own lifetime until it it is ready to call Initialize() (since the VDA/VEA expects is Client to be valid until itself is Destroy()ed). BUG=325984 TEST=local build, run on CrOS snow, build on desktop Linux Review URL: https://codereview.chromium.org/170843004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc7
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.h7
-rw-r--r--content/common/gpu/client/gpu_channel_host.cc10
-rw-r--r--content/common/gpu/client/gpu_channel_host.h6
-rw-r--r--content/common/gpu/client/gpu_video_decode_accelerator_host.cc11
-rw-r--r--content/common/gpu/client/gpu_video_decode_accelerator_host.h8
-rw-r--r--content/common/gpu/client/gpu_video_encode_accelerator_host.cc13
-rw-r--r--content/common/gpu/client/gpu_video_encode_accelerator_host.h16
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.cc12
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.h4
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator_unittest.cc3
-rw-r--r--content/common/gpu/media/android_video_encode_accelerator.cc43
-rw-r--r--content/common/gpu/media/android_video_encode_accelerator.h8
-rw-r--r--content/common/gpu/media/dxva_video_decode_accelerator.cc8
-rw-r--r--content/common/gpu/media/dxva_video_decode_accelerator.h4
-rw-r--r--content/common/gpu/media/exynos_video_encode_accelerator.cc19
-rw-r--r--content/common/gpu/media/exynos_video_encode_accelerator.h8
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.cc10
-rw-r--r--content/common/gpu/media/gpu_video_encode_accelerator.cc6
-rw-r--r--content/common/gpu/media/v4l2_video_decode_accelerator.cc14
-rw-r--r--content/common/gpu/media/v4l2_video_decode_accelerator.h6
-rw-r--r--content/common/gpu/media/vaapi_video_decode_accelerator.cc15
-rw-r--r--content/common/gpu/media/vaapi_video_decode_accelerator.h6
-rw-r--r--content/common/gpu/media/video_decode_accelerator_unittest.cc6
-rw-r--r--content/common/gpu/media/video_encode_accelerator_unittest.cc5
-rw-r--r--content/public/renderer/video_encode_accelerator.cc5
-rw-r--r--content/public/renderer/video_encode_accelerator.h2
-rw-r--r--content/renderer/media/pepper_platform_video_decoder.cc20
-rw-r--r--content/renderer/media/pepper_platform_video_decoder.h7
-rw-r--r--content/renderer/media/renderer_gpu_video_accelerator_factories.cc10
-rw-r--r--content/renderer/media/renderer_gpu_video_accelerator_factories.h7
-rw-r--r--content/renderer/media/rtc_video_decoder.cc4
-rw-r--r--content/renderer/media/rtc_video_decoder_unittest.cc9
-rw-r--r--content/renderer/media/rtc_video_encoder.cc9
-rw-r--r--content/renderer/pepper/ppb_video_decoder_impl.cc6
35 files changed, 161 insertions, 173 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 631eea9..40f0b1f 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -529,9 +529,7 @@ bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) {
}
scoped_ptr<media::VideoDecodeAccelerator>
-CommandBufferProxyImpl::CreateVideoDecoder(
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client) {
+CommandBufferProxyImpl::CreateVideoDecoder(media::VideoCodecProfile profile) {
int decoder_route_id;
scoped_ptr<media::VideoDecodeAccelerator> vda;
if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile,
@@ -546,8 +544,7 @@ CommandBufferProxyImpl::CreateVideoDecoder(
}
GpuVideoDecodeAcceleratorHost* decoder_host =
- new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client,
- this);
+ new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, this);
vda.reset(decoder_host);
return vda.Pass();
}
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h
index f581688..0c9b28c 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.h
+++ b/content/common/gpu/client/command_buffer_proxy_impl.h
@@ -67,11 +67,10 @@ class CommandBufferProxyImpl
// returns it as an owned pointer to a media::VideoDecodeAccelerator. Returns
// NULL on failure to create the GpuVideoDecodeAcceleratorHost.
// Note that the GpuVideoDecodeAccelerator may still fail to be created in
- // the GPU process, even if this returns non-NULL. In this case the client is
- // notified of an error later.
+ // the GPU process, even if this returns non-NULL. In this case the VDA client
+ // is notified of an error later, after Initialize().
scoped_ptr<media::VideoDecodeAccelerator> CreateVideoDecoder(
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client);
+ media::VideoCodecProfile profile);
// IPC::Listener implementation:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc
index debcfc8..78130b4 100644
--- a/content/common/gpu/client/gpu_channel_host.cc
+++ b/content/common/gpu/client/gpu_channel_host.cc
@@ -180,17 +180,15 @@ CommandBufferProxyImpl* GpuChannelHost::CreateOffscreenCommandBuffer(
scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder(
int command_buffer_route_id,
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client) {
+ media::VideoCodecProfile profile) {
AutoLock lock(context_lock_);
ProxyMap::iterator it = proxies_.find(command_buffer_route_id);
DCHECK(it != proxies_.end());
CommandBufferProxyImpl* proxy = it->second;
- return proxy->CreateVideoDecoder(profile, client).Pass();
+ return proxy->CreateVideoDecoder(profile).Pass();
}
-scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder(
- media::VideoEncodeAccelerator::Client* client) {
+scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder() {
TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder");
scoped_ptr<media::VideoEncodeAccelerator> vea;
@@ -200,7 +198,7 @@ scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder(
if (route_id == MSG_ROUTING_NONE)
return vea.Pass();
- vea.reset(new GpuVideoEncodeAcceleratorHost(client, this, route_id));
+ vea.reset(new GpuVideoEncodeAcceleratorHost(this, route_id));
return vea.Pass();
}
diff --git a/content/common/gpu/client/gpu_channel_host.h b/content/common/gpu/client/gpu_channel_host.h
index 2d98980..cba8de4 100644
--- a/content/common/gpu/client/gpu_channel_host.h
+++ b/content/common/gpu/client/gpu_channel_host.h
@@ -125,12 +125,10 @@ class GpuChannelHost : public IPC::Sender,
// Creates a video decoder in the GPU process.
scoped_ptr<media::VideoDecodeAccelerator> CreateVideoDecoder(
int command_buffer_route_id,
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client);
+ media::VideoCodecProfile profile);
// Creates a video encoder in the GPU process.
- scoped_ptr<media::VideoEncodeAccelerator> CreateVideoEncoder(
- media::VideoEncodeAccelerator::Client* client);
+ scoped_ptr<media::VideoEncodeAccelerator> CreateVideoEncoder();
// Destroy a command buffer created by this channel.
void DestroyCommandBuffer(CommandBufferProxyImpl* command_buffer);
diff --git a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
index 403d296..1146258 100644
--- a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
+++ b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc
@@ -23,14 +23,12 @@ namespace content {
GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
GpuChannelHost* channel,
int32 decoder_route_id,
- VideoDecodeAccelerator::Client* client,
CommandBufferProxyImpl* impl)
: channel_(channel),
decoder_route_id_(decoder_route_id),
- client_(client),
+ client_(NULL),
impl_(impl) {
DCHECK(channel_);
- DCHECK(client_);
channel_->AddRoute(decoder_route_id, base::AsWeakPtr(this));
impl_->AddDeletionObserver(this);
}
@@ -72,9 +70,9 @@ bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) {
return handled;
}
-bool GpuVideoDecodeAcceleratorHost::Initialize(
- media::VideoCodecProfile profile) {
- NOTREACHED();
+bool GpuVideoDecodeAcceleratorHost::Initialize(media::VideoCodecProfile profile,
+ Client* client) {
+ client_ = client;
return true;
}
@@ -149,7 +147,6 @@ void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() {
GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() {
DCHECK(CalledOnValidThread());
- DCHECK(!client_) << "destructor called without Destroy being called!";
if (channel_)
channel_->RemoveRoute(decoder_route_id_);
diff --git a/content/common/gpu/client/gpu_video_decode_accelerator_host.h b/content/common/gpu/client/gpu_video_decode_accelerator_host.h
index 704584d..552813e 100644
--- a/content/common/gpu/client/gpu_video_decode_accelerator_host.h
+++ b/content/common/gpu/client/gpu_video_decode_accelerator_host.h
@@ -28,7 +28,6 @@ class GpuVideoDecodeAcceleratorHost
// |channel| is used to send IPC messages to GPU process.
GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel,
int32 decoder_route_id,
- media::VideoDecodeAccelerator::Client* client,
CommandBufferProxyImpl* impl);
// IPC::Listener implementation.
@@ -36,7 +35,8 @@ class GpuVideoDecodeAcceleratorHost
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// media::VideoDecodeAccelerator implementation.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
@@ -70,8 +70,8 @@ class GpuVideoDecodeAcceleratorHost
// Route ID for the associated decoder in the GPU process.
int32 decoder_route_id_;
- // Reference to the client that will receive callbacks from the decoder.
- media::VideoDecodeAccelerator::Client* client_;
+ // The client that will receive callbacks from the decoder.
+ Client* client_;
// Unowned reference to the CommandBufferProxyImpl that created us.
CommandBufferProxyImpl* impl_;
diff --git a/content/common/gpu/client/gpu_video_encode_accelerator_host.cc b/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
index edfb7b6..14d330e 100644
--- a/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
+++ b/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
@@ -14,11 +14,9 @@
namespace content {
GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost(
- media::VideoEncodeAccelerator::Client* client,
const scoped_refptr<GpuChannelHost>& gpu_channel_host,
int32 route_id)
- : client_(client),
- client_ptr_factory_(client_),
+ : client_(NULL),
channel_(gpu_channel_host),
route_id_(route_id),
next_frame_id_(0) {
@@ -73,7 +71,10 @@ void GpuVideoEncodeAcceleratorHost::Initialize(
media::VideoFrame::Format input_format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) {
+ uint32 initial_bitrate,
+ Client* client) {
+ client_ = client;
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client_));
Send(new AcceleratedVideoEncoderMsg_Initialize(route_id_,
input_format,
input_visible_size,
@@ -152,7 +153,7 @@ void GpuVideoEncodeAcceleratorHost::NotifyError(Error error) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(&media::VideoEncodeAccelerator::Client::NotifyError,
- client_ptr_factory_.GetWeakPtr(),
+ client_ptr_factory_->GetWeakPtr(),
error));
}
@@ -210,7 +211,7 @@ void GpuVideoEncodeAcceleratorHost::OnNotifyError(Error error) {
DVLOG(2) << "OnNotifyError(): error=" << error;
if (!client_)
return;
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
// Client::NotifyError() may Destroy() |this|, so calling it needs to be the
// last thing done on this stack!
diff --git a/content/common/gpu/client/gpu_video_encode_accelerator_host.h b/content/common/gpu/client/gpu_video_encode_accelerator_host.h
index 860955d..bedf7fb 100644
--- a/content/common/gpu/client/gpu_video_encode_accelerator_host.h
+++ b/content/common/gpu/client/gpu_video_encode_accelerator_host.h
@@ -36,10 +36,9 @@ class GpuVideoEncodeAcceleratorHost
public media::VideoEncodeAccelerator,
public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> {
public:
- // |client| is assumed to outlive this object. Since the GpuChannelHost does
- // _not_ own this object, a reference to |gpu_channel_host| is taken.
+ // Since the GpuChannelHost does _not_ own this object, a reference to
+ // |gpu_channel_host| is taken.
GpuVideoEncodeAcceleratorHost(
- media::VideoEncodeAccelerator::Client* client,
const scoped_refptr<GpuChannelHost>& gpu_channel_host,
int32 route_id);
virtual ~GpuVideoEncodeAcceleratorHost();
@@ -56,7 +55,8 @@ class GpuVideoEncodeAcceleratorHost
virtual void Initialize(media::VideoFrame::Format format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) OVERRIDE;
+ uint32 initial_bitrate,
+ Client* client) OVERRIDE;
virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
bool force_keyframe) OVERRIDE;
virtual void UseOutputBitstreamBuffer(
@@ -84,12 +84,12 @@ class GpuVideoEncodeAcceleratorHost
void Send(IPC::Message* message);
- // Weak pointer for client callbacks on the
- // media::VideoEncodeAccelerator::Client interface.
- media::VideoEncodeAccelerator::Client* client_;
+ // Pointer for client callbacks on the media::VideoEncodeAccelerator::Client
+ // interface.
+ Client* client_;
// |client_ptr_factory_| is used for callbacks that need to be done through
// a PostTask() to avoid re-entrancy on the client.
- base::WeakPtrFactory<VideoEncodeAccelerator::Client> client_ptr_factory_;
+ scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
// IPC channel and route ID.
scoped_refptr<GpuChannelHost> channel_;
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc
index d08cb1f..9999130 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.cc
+++ b/content/common/gpu/media/android_video_decode_accelerator.cc
@@ -65,27 +65,27 @@ static inline const base::TimeDelta NoWaitTimeOut() {
}
AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
- media::VideoDecodeAccelerator::Client* client,
const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
const base::Callback<bool(void)>& make_context_current)
- : client_(client),
+ : client_(NULL),
make_context_current_(make_context_current),
codec_(media::kCodecH264),
state_(NO_ERROR),
surface_texture_id_(0),
picturebuffers_requested_(false),
- gl_decoder_(decoder) {
-}
+ gl_decoder_(decoder) {}
AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
DCHECK(thread_checker_.CalledOnValidThread());
}
-bool AndroidVideoDecodeAccelerator::Initialize(
- media::VideoCodecProfile profile) {
+bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
+ Client* client) {
DCHECK(!media_codec_);
DCHECK(thread_checker_.CalledOnValidThread());
+ client_ = client;
+
if (!media::MediaCodecBridge::IsAvailable())
return false;
diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator.h
index b2270a2..35f7ae0 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.h
+++ b/content/common/gpu/media/android_video_decode_accelerator.h
@@ -34,12 +34,12 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator
public:
// Does not take ownership of |client| which must outlive |*this|.
AndroidVideoDecodeAccelerator(
- media::VideoDecodeAccelerator::Client* client,
const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
const base::Callback<bool(void)>& make_context_current);
// media::VideoDecodeAccelerator implementation.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
diff --git a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
index 4e25e68..1ee5f8f 100644
--- a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
+++ b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
@@ -66,8 +66,7 @@ class AndroidVideoDecodeAcceleratorTest : public testing::Test {
scoped_ptr<MockVideoDecodeAcceleratorClient> client(
new MockVideoDecodeAcceleratorClient());
accelerator_.reset(new AndroidVideoDecodeAccelerator(
- client.get(), decoder->AsWeakPtr(),
- base::Bind(&MockMakeContextCurrent)));
+ decoder->AsWeakPtr(), base::Bind(&MockMakeContextCurrent)));
}
bool Configure(media::VideoCodec codec) {
diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc
index 05f18b6..9e0aefc 100644
--- a/content/common/gpu/media/android_video_encode_accelerator.cc
+++ b/content/common/gpu/media/android_video_encode_accelerator.cc
@@ -33,16 +33,16 @@ enum {
// Helper macros for dealing with failure. If |result| evaluates false, emit
// |log| to DLOG(ERROR), register |error| with the client, and return.
-#define RETURN_ON_FAILURE(result, log, error) \
- do { \
- if (!(result)) { \
- DLOG(ERROR) << log; \
- if (client_ptr_factory_.GetWeakPtr()) { \
- client_ptr_factory_.GetWeakPtr()->NotifyError(error); \
- client_ptr_factory_.InvalidateWeakPtrs(); \
- } \
- return; \
- } \
+#define RETURN_ON_FAILURE(result, log, error) \
+ do { \
+ if (!(result)) { \
+ DLOG(ERROR) << log; \
+ if (client_ptr_factory_->GetWeakPtr()) { \
+ client_ptr_factory_->GetWeakPtr()->NotifyError(error); \
+ client_ptr_factory_.reset(); \
+ } \
+ return; \
+ } \
} while (0)
// Because MediaCodec is thread-hostile (must be poked on a single thread) and
@@ -67,10 +67,8 @@ static inline const base::TimeDelta NoWaitTimeOut() {
return base::TimeDelta::FromMicroseconds(0);
}
-AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client)
- : client_ptr_factory_(client),
- num_buffers_at_codec_(0),
+AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator()
+ : num_buffers_at_codec_(0),
num_output_buffers_(-1),
output_buffers_capacity_(0),
last_set_bitrate_(0) {}
@@ -118,7 +116,8 @@ void AndroidVideoEncodeAccelerator::Initialize(
VideoFrame::Format format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) {
+ uint32 initial_bitrate,
+ Client* client) {
DVLOG(3) << __PRETTY_FUNCTION__ << " format: " << format
<< ", input_visible_size: " << input_visible_size.ToString()
<< ", output_profile: " << output_profile
@@ -126,6 +125,8 @@ void AndroidVideoEncodeAccelerator::Initialize(
DCHECK(!media_codec_);
DCHECK(thread_checker_.CalledOnValidThread());
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
+
RETURN_ON_FAILURE(media::MediaCodecBridge::IsAvailable() &&
media::MediaCodecBridge::SupportsSetParameters() &&
format == VideoFrame::I420 &&
@@ -161,14 +162,14 @@ void AndroidVideoEncodeAccelerator::Initialize(
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&VideoEncodeAccelerator::Client::NotifyInitializeDone,
- client_ptr_factory_.GetWeakPtr()));
+ client_ptr_factory_->GetWeakPtr()));
num_output_buffers_ = media_codec_->GetOutputBuffersCount();
output_buffers_capacity_ = media_codec_->GetOutputBuffersCapacity();
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&VideoEncodeAccelerator::Client::RequireBitstreamBuffers,
- client_ptr_factory_.GetWeakPtr(),
+ client_ptr_factory_->GetWeakPtr(),
num_output_buffers_,
input_visible_size,
output_buffers_capacity_));
@@ -246,7 +247,7 @@ void AndroidVideoEncodeAccelerator::RequestEncodingParametersChange(
void AndroidVideoEncodeAccelerator::Destroy() {
DVLOG(3) << __PRETTY_FUNCTION__;
DCHECK(thread_checker_.CalledOnValidThread());
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
if (media_codec_) {
if (io_timer_.IsRunning())
io_timer_.Stop();
@@ -263,7 +264,7 @@ void AndroidVideoEncodeAccelerator::DoIOTask() {
}
void AndroidVideoEncodeAccelerator::QueueInput() {
- if (!client_ptr_factory_.GetWeakPtr() || pending_frames_.empty())
+ if (!client_ptr_factory_->GetWeakPtr() || pending_frames_.empty())
return;
int input_buf_index = 0;
@@ -347,7 +348,7 @@ bool AndroidVideoEncodeAccelerator::DoOutputBuffersSuffice() {
}
void AndroidVideoEncodeAccelerator::DequeueOutput() {
- if (!client_ptr_factory_.GetWeakPtr() ||
+ if (!client_ptr_factory_->GetWeakPtr() ||
available_bitstream_buffers_.empty() || num_buffers_at_codec_ == 0) {
return;
}
@@ -405,7 +406,7 @@ void AndroidVideoEncodeAccelerator::DequeueOutput() {
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
- client_ptr_factory_.GetWeakPtr(),
+ client_ptr_factory_->GetWeakPtr(),
bitstream_buffer.id(),
size,
key_frame));
diff --git a/content/common/gpu/media/android_video_encode_accelerator.h b/content/common/gpu/media/android_video_encode_accelerator.h
index e519a27..76cc84f 100644
--- a/content/common/gpu/media/android_video_encode_accelerator.h
+++ b/content/common/gpu/media/android_video_encode_accelerator.h
@@ -31,8 +31,7 @@ namespace content {
class CONTENT_EXPORT AndroidVideoEncodeAccelerator
: public media::VideoEncodeAccelerator {
public:
- explicit AndroidVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client);
+ AndroidVideoEncodeAccelerator();
virtual ~AndroidVideoEncodeAccelerator();
static std::vector<media::VideoEncodeAccelerator::SupportedProfile>
@@ -42,7 +41,8 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
virtual void Initialize(media::VideoFrame::Format format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) OVERRIDE;
+ uint32 initial_bitrate,
+ Client* client) OVERRIDE;
virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
bool force_keyframe) OVERRIDE;
virtual void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer)
@@ -77,7 +77,7 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
// VideoDecodeAccelerator::Client callbacks go here. Invalidated once any
// error triggers.
- base::WeakPtrFactory<Client> client_ptr_factory_;
+ scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
scoped_ptr<media::VideoCodecBridge> media_codec_;
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.cc b/content/common/gpu/media/dxva_video_decode_accelerator.cc
index 3803030..4e3c673 100644
--- a/content/common/gpu/media/dxva_video_decode_accelerator.cc
+++ b/content/common/gpu/media/dxva_video_decode_accelerator.cc
@@ -413,9 +413,8 @@ bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() {
}
DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator(
- media::VideoDecodeAccelerator::Client* client,
const base::Callback<bool(void)>& make_context_current)
- : client_(client),
+ : client_(NULL),
dev_manager_reset_token_(0),
egl_config_(NULL),
state_(kUninitialized),
@@ -430,9 +429,12 @@ DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() {
client_ = NULL;
}
-bool DXVAVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) {
+bool DXVAVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
+ Client* client) {
DCHECK(CalledOnValidThread());
+ client_ = client;
+
// Not all versions of Windows 7 and later include Media Foundation DLLs.
// Instead of crashing while delay loading the DLL when calling MFStartup()
// below, probe whether we can successfully load the DLL now.
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.h b/content/common/gpu/media/dxva_video_decode_accelerator.h
index 870b12e..7b92277 100644
--- a/content/common/gpu/media/dxva_video_decode_accelerator.h
+++ b/content/common/gpu/media/dxva_video_decode_accelerator.h
@@ -43,12 +43,12 @@ class CONTENT_EXPORT DXVAVideoDecodeAccelerator
// Does not take ownership of |client| which must outlive |*this|.
explicit DXVAVideoDecodeAccelerator(
- media::VideoDecodeAccelerator::Client* client,
const base::Callback<bool(void)>& make_context_current);
virtual ~DXVAVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
diff --git a/content/common/gpu/media/exynos_video_encode_accelerator.cc b/content/common/gpu/media/exynos_video_encode_accelerator.cc
index e5c3a73..c8658f0 100644
--- a/content/common/gpu/media/exynos_video_encode_accelerator.cc
+++ b/content/common/gpu/media/exynos_video_encode_accelerator.cc
@@ -82,13 +82,10 @@ ExynosVideoEncodeAccelerator::MfcInputRecord::MfcInputRecord()
ExynosVideoEncodeAccelerator::MfcOutputRecord::MfcOutputRecord()
: at_device(false), address(NULL), length(0) {}
-ExynosVideoEncodeAccelerator::ExynosVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client)
+ExynosVideoEncodeAccelerator::ExynosVideoEncodeAccelerator()
: child_message_loop_proxy_(base::MessageLoopProxy::current()),
weak_this_ptr_factory_(this),
weak_this_(weak_this_ptr_factory_.GetWeakPtr()),
- client_ptr_factory_(client),
- client_(client_ptr_factory_.GetWeakPtr()),
encoder_thread_("ExynosEncoderThread"),
encoder_state_(kUninitialized),
output_buffer_byte_size_(0),
@@ -106,9 +103,7 @@ ExynosVideoEncodeAccelerator::ExynosVideoEncodeAccelerator(
mfc_output_streamon_(false),
mfc_output_buffer_queued_count_(0),
device_poll_thread_("ExynosEncoderDevicePollThread"),
- device_poll_interrupt_fd_(-1) {
- DCHECK(client_);
-}
+ device_poll_interrupt_fd_(-1) {}
ExynosVideoEncodeAccelerator::~ExynosVideoEncodeAccelerator() {
DCHECK(!encoder_thread_.IsRunning());
@@ -136,12 +131,16 @@ void ExynosVideoEncodeAccelerator::Initialize(
media::VideoFrame::Format input_format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) {
+ uint32 initial_bitrate,
+ Client* client) {
DVLOG(3) << "Initialize(): input_format=" << input_format
<< ", input_visible_size=" << input_visible_size.ToString()
<< ", output_profile=" << output_profile
<< ", initial_bitrate=" << initial_bitrate;
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
+ client_ = client_ptr_factory_->GetWeakPtr();
+
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
DCHECK_EQ(encoder_state_, kUninitialized);
@@ -345,7 +344,7 @@ void ExynosVideoEncodeAccelerator::Destroy() {
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
// We're destroying; cancel all callbacks.
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
// If the encoder thread is running, destroy using posted task.
if (encoder_thread_.IsRunning()) {
@@ -1108,7 +1107,7 @@ void ExynosVideoEncodeAccelerator::NotifyError(Error error) {
if (client_) {
client_->NotifyError(error);
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
}
}
diff --git a/content/common/gpu/media/exynos_video_encode_accelerator.h b/content/common/gpu/media/exynos_video_encode_accelerator.h
index 3a9bbb4..3da09d3 100644
--- a/content/common/gpu/media/exynos_video_encode_accelerator.h
+++ b/content/common/gpu/media/exynos_video_encode_accelerator.h
@@ -36,15 +36,15 @@ namespace content {
class CONTENT_EXPORT ExynosVideoEncodeAccelerator
: public media::VideoEncodeAccelerator {
public:
- explicit ExynosVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client);
+ ExynosVideoEncodeAccelerator();
virtual ~ExynosVideoEncodeAccelerator();
// media::VideoEncodeAccelerator implementation.
virtual void Initialize(media::VideoFrame::Format format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate) OVERRIDE;
+ uint32 initial_bitrate,
+ Client* client) OVERRIDE;
virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
bool force_keyframe) OVERRIDE;
virtual void UseOutputBitstreamBuffer(
@@ -203,7 +203,7 @@ class CONTENT_EXPORT ExynosVideoEncodeAccelerator
// To expose client callbacks from VideoEncodeAccelerator.
// NOTE: all calls to these objects *MUST* be executed on
// child_message_loop_proxy_.
- base::WeakPtrFactory<Client> client_ptr_factory_;
+ scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
base::WeakPtr<Client> client_;
//
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc
index bd1dc5f..9ec8139 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -270,8 +270,8 @@ void GpuVideoDecodeAccelerator::Initialize(
return;
}
DVLOG(0) << "Initializing DXVA HW decoder for windows.";
- video_decode_accelerator_.reset(new DXVAVideoDecodeAccelerator(
- this, make_context_current_));
+ video_decode_accelerator_.reset(
+ new DXVAVideoDecodeAccelerator(make_context_current_));
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
scoped_ptr<V4L2Device> device = V4L2Device::Create();
if (!device.get()) {
@@ -280,7 +280,6 @@ void GpuVideoDecodeAccelerator::Initialize(
}
video_decode_accelerator_.reset(
new V4L2VideoDecodeAccelerator(gfx::GLSurfaceEGL::GetHardwareDisplay(),
- this,
weak_factory_for_io_.GetWeakPtr(),
make_context_current_,
device.Pass(),
@@ -295,10 +294,9 @@ void GpuVideoDecodeAccelerator::Initialize(
gfx::GLContextGLX* glx_context =
static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator(
- glx_context->display(), this, make_context_current_));
+ glx_context->display(), make_context_current_));
#elif defined(OS_ANDROID)
video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
- this,
stub_->decoder()->AsWeakPtr(),
make_context_current_));
#else
@@ -312,7 +310,7 @@ void GpuVideoDecodeAccelerator::Initialize(
stub_->channel()->AddFilter(filter_.get());
}
- if (!video_decode_accelerator_->Initialize(profile))
+ if (!video_decode_accelerator_->Initialize(profile, this))
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
}
diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.cc b/content/common/gpu/media/gpu_video_encode_accelerator.cc
index 6ff9544..9227847 100644
--- a/content/common/gpu/media/gpu_video_encode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_encode_accelerator.cc
@@ -101,9 +101,9 @@ GpuVideoEncodeAccelerator::GetSupportedProfiles() {
void GpuVideoEncodeAccelerator::CreateEncoder() {
DCHECK(!encoder_);
#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
- encoder_.reset(new ExynosVideoEncodeAccelerator(this));
+ encoder_.reset(new ExynosVideoEncodeAccelerator());
#elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
- encoder_.reset(new AndroidVideoEncodeAccelerator(this));
+ encoder_.reset(new AndroidVideoEncodeAccelerator());
#endif
}
@@ -137,7 +137,7 @@ void GpuVideoEncodeAccelerator::OnInitialize(
return;
}
encoder_->Initialize(
- input_format, input_visible_size, output_profile, initial_bitrate);
+ input_format, input_visible_size, output_profile, initial_bitrate, this);
input_format_ = input_format;
input_visible_size_ = input_visible_size;
}
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
index 992e6af..68baaa8 100644
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
@@ -154,7 +154,6 @@ V4L2VideoDecodeAccelerator::PictureRecord::~PictureRecord() {}
V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator(
EGLDisplay egl_display,
- Client* client,
const base::WeakPtr<Client>& io_client,
const base::Callback<bool(void)>& make_context_current,
scoped_ptr<V4L2Device> device,
@@ -162,8 +161,6 @@ V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator(
: child_message_loop_proxy_(base::MessageLoopProxy::current()),
io_message_loop_proxy_(io_message_loop_proxy),
weak_this_(base::AsWeakPtr(this)),
- client_ptr_factory_(client),
- client_(client_ptr_factory_.GetWeakPtr()),
io_client_(io_client),
decoder_thread_("V4L2DecoderThread"),
decoder_state_(kUninitialized),
@@ -202,12 +199,15 @@ V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() {
DCHECK(output_buffer_map_.empty());
}
-bool V4L2VideoDecodeAccelerator::Initialize(
- media::VideoCodecProfile profile) {
+bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
+ Client* client) {
DVLOG(3) << "Initialize()";
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
DCHECK_EQ(decoder_state_, kUninitialized);
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
+ client_ = client_ptr_factory_->GetWeakPtr();
+
switch (profile) {
case media::H264PROFILE_BASELINE:
DVLOG(2) << "Initialize(): profile H264PROFILE_BASELINE";
@@ -427,7 +427,7 @@ void V4L2VideoDecodeAccelerator::Destroy() {
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
// We're destroying; cancel all callbacks.
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
// If the decoder thread is running, destroy using posted task.
if (decoder_thread_.IsRunning()) {
@@ -1587,7 +1587,7 @@ void V4L2VideoDecodeAccelerator::NotifyError(Error error) {
if (client_) {
client_->NotifyError(error);
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
}
}
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.h b/content/common/gpu/media/v4l2_video_decode_accelerator.h
index 83e1c8a..0c6a493 100644
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.h
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.h
@@ -77,7 +77,6 @@ class CONTENT_EXPORT V4L2VideoDecodeAccelerator
public:
V4L2VideoDecodeAccelerator(
EGLDisplay egl_display,
- Client* client,
const base::WeakPtr<Client>& io_client_,
const base::Callback<bool(void)>& make_context_current,
scoped_ptr<V4L2Device> device,
@@ -86,7 +85,8 @@ class CONTENT_EXPORT V4L2VideoDecodeAccelerator
// media::VideoDecodeAccelerator implementation.
// Note: Initialize() and Destroy() are synchronous.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
@@ -311,7 +311,7 @@ class CONTENT_EXPORT V4L2VideoDecodeAccelerator
// To expose client callbacks from VideoDecodeAccelerator.
// NOTE: all calls to these objects *MUST* be executed on
// child_message_loop_proxy_.
- base::WeakPtrFactory<Client> client_ptr_factory_;
+ scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
base::WeakPtr<Client> client_;
// Callbacks to |io_client_| must be executed on |io_message_loop_proxy_|.
base::WeakPtr<Client> io_client_;
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/content/common/gpu/media/vaapi_video_decode_accelerator.cc
index 73471d6..79860d5b 100644
--- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc
+++ b/content/common/gpu/media/vaapi_video_decode_accelerator.cc
@@ -57,7 +57,7 @@ void VaapiVideoDecodeAccelerator::NotifyError(Error error) {
DVLOG(1) << "Notifying of error " << error;
if (client_) {
client_->NotifyError(error);
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
}
}
@@ -237,7 +237,6 @@ VaapiVideoDecodeAccelerator::TFPPicture*
VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
Display* x_display,
- Client* client,
const base::Callback<bool(void)>& make_context_current)
: x_display_(x_display),
make_context_current_(make_context_current),
@@ -248,15 +247,12 @@ VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator(
weak_this_(base::AsWeakPtr(this)),
va_surface_release_cb_(media::BindToCurrentLoop(base::Bind(
&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_))),
- client_ptr_factory_(client),
- client_(client_ptr_factory_.GetWeakPtr()),
decoder_thread_("VaapiDecoderThread"),
num_frames_at_client_(0),
num_stream_bufs_at_decoder_(0),
finish_flush_pending_(false),
awaiting_va_surfaces_recycle_(false),
requested_num_pics_(0) {
- DCHECK(client);
}
VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() {
@@ -292,10 +288,13 @@ bool VaapiVideoDecodeAccelerator::InitializeFBConfig() {
return true;
}
-bool VaapiVideoDecodeAccelerator::Initialize(
- media::VideoCodecProfile profile) {
+bool VaapiVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
+ Client* client) {
DCHECK_EQ(message_loop_, base::MessageLoop::current());
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
+ client_ = client_ptr_factory_->GetWeakPtr();
+
base::AutoLock auto_lock(lock_);
DCHECK_EQ(state_, kUninitialized);
DVLOG(2) << "Initializing VAVDA, profile: " << profile;
@@ -904,7 +903,7 @@ void VaapiVideoDecodeAccelerator::Cleanup() {
base::AutoLock auto_lock(lock_);
state_ = kDestroying;
- client_ptr_factory_.InvalidateWeakPtrs();
+ client_ptr_factory_.reset();
{
base::AutoUnlock auto_unlock(lock_);
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.h b/content/common/gpu/media/vaapi_video_decode_accelerator.h
index f765ea7..291eb6b 100644
--- a/content/common/gpu/media/vaapi_video_decode_accelerator.h
+++ b/content/common/gpu/media/vaapi_video_decode_accelerator.h
@@ -46,12 +46,12 @@ class CONTENT_EXPORT VaapiVideoDecodeAccelerator
public:
VaapiVideoDecodeAccelerator(
Display* x_display,
- Client* client,
const base::Callback<bool(void)>& make_context_current);
virtual ~VaapiVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
@@ -239,7 +239,7 @@ private:
// To expose client callbacks from VideoDecodeAccelerator.
// NOTE: all calls to these objects *MUST* be executed on message_loop_.
- base::WeakPtrFactory<Client> client_ptr_factory_;
+ scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
base::WeakPtr<Client> client_;
scoped_ptr<VaapiWrapper> vaapi_wrapper_;
diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc
index 28832c7..8397020 100644
--- a/content/common/gpu/media/video_decode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc
@@ -555,7 +555,7 @@ void GLRenderingVDAClient::CreateAndStartDecoder() {
}
#if defined(OS_WIN)
decoder_.reset(
- new DXVAVideoDecodeAccelerator(client, base::Bind(&DoNothingReturnTrue)));
+ new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
#elif defined(OS_CHROMEOS)
#if defined(ARCH_CPU_ARMEL)
@@ -566,7 +566,6 @@ void GLRenderingVDAClient::CreateAndStartDecoder() {
}
decoder_.reset(new V4L2VideoDecodeAccelerator(
static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
- client,
weak_client,
base::Bind(&DoNothingReturnTrue),
device.Pass(),
@@ -576,7 +575,6 @@ void GLRenderingVDAClient::CreateAndStartDecoder() {
<< "Hardware video decode does not work with OSMesa";
decoder_.reset(new VaapiVideoDecodeAccelerator(
static_cast<Display*>(rendering_helper_->GetGLDisplay()),
- client,
base::Bind(&DoNothingReturnTrue)));
#endif // ARCH_CPU_ARMEL
#endif // OS_WIN
@@ -585,7 +583,7 @@ void GLRenderingVDAClient::CreateAndStartDecoder() {
if (decoder_deleted())
return;
- CHECK(decoder_->Initialize(profile_));
+ CHECK(decoder_->Initialize(profile_, client));
}
void GLRenderingVDAClient::ProvidePictureBuffers(
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc
index 701eae8..2fa5217 100644
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -391,7 +391,7 @@ void VEAClient::CreateEncoder() {
DCHECK(thread_checker_.CalledOnValidThread());
CHECK(!has_encoder());
- encoder_.reset(new ExynosVideoEncodeAccelerator(this));
+ encoder_.reset(new ExynosVideoEncodeAccelerator());
SetState(CS_ENCODER_SET);
DVLOG(1) << "Profile: " << test_stream_.requested_profile
@@ -399,7 +399,8 @@ void VEAClient::CreateEncoder() {
encoder_->Initialize(kInputFormat,
test_stream_.size,
test_stream_.requested_profile,
- test_stream_.requested_bitrate);
+ test_stream_.requested_bitrate,
+ this);
}
void VEAClient::DestroyEncoder() {
diff --git a/content/public/renderer/video_encode_accelerator.cc b/content/public/renderer/video_encode_accelerator.cc
index 3ed1875..3f564f0 100644
--- a/content/public/renderer/video_encode_accelerator.cc
+++ b/content/public/renderer/video_encode_accelerator.cc
@@ -8,14 +8,13 @@
namespace content {
-scoped_ptr<media::VideoEncodeAccelerator>
-CreateVideoEncodeAccelerator(media::VideoEncodeAccelerator::Client* client) {
+scoped_ptr<media::VideoEncodeAccelerator> CreateVideoEncodeAccelerator() {
scoped_ptr<media::VideoEncodeAccelerator> vea;
scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories =
RenderThreadImpl::current()->GetGpuFactories();
if (gpu_factories.get())
- vea = gpu_factories->CreateVideoEncodeAccelerator(client).Pass();
+ vea = gpu_factories->CreateVideoEncodeAccelerator().Pass();
return vea.Pass();
}
diff --git a/content/public/renderer/video_encode_accelerator.h b/content/public/renderer/video_encode_accelerator.h
index 4231cff..0b95935 100644
--- a/content/public/renderer/video_encode_accelerator.h
+++ b/content/public/renderer/video_encode_accelerator.h
@@ -13,7 +13,7 @@ namespace content {
// Generate an instance of media::VideoEncodeAccelerator.
CONTENT_EXPORT scoped_ptr<media::VideoEncodeAccelerator>
-CreateVideoEncodeAccelerator(media::VideoEncodeAccelerator::Client* client);
+ CreateVideoEncodeAccelerator();
} // namespace content
diff --git a/content/renderer/media/pepper_platform_video_decoder.cc b/content/renderer/media/pepper_platform_video_decoder.cc
index 89fdbb4..37a19d3 100644
--- a/content/renderer/media/pepper_platform_video_decoder.cc
+++ b/content/renderer/media/pepper_platform_video_decoder.cc
@@ -14,17 +14,16 @@ using media::BitstreamBuffer;
namespace content {
-PlatformVideoDecoder::PlatformVideoDecoder(
- VideoDecodeAccelerator::Client* client,
- int32 command_buffer_route_id)
- : client_(client),
- command_buffer_route_id_(command_buffer_route_id) {
- DCHECK(client);
-}
+PlatformVideoDecoder::PlatformVideoDecoder(int32 command_buffer_route_id)
+ : command_buffer_route_id_(command_buffer_route_id) {}
PlatformVideoDecoder::~PlatformVideoDecoder() {}
-bool PlatformVideoDecoder::Initialize(media::VideoCodecProfile profile) {
+bool PlatformVideoDecoder::Initialize(
+ media::VideoCodecProfile profile,
+ media::VideoDecodeAccelerator::Client* client) {
+ client_ = client;
+
// TODO(vrk): Support multiple decoders.
if (decoder_)
return true;
@@ -41,9 +40,8 @@ bool PlatformVideoDecoder::Initialize(media::VideoCodecProfile profile) {
return false;
// Send IPC message to initialize decoder in GPU process.
- decoder_ =
- channel->CreateVideoDecoder(command_buffer_route_id_, profile, this);
- return decoder_.get() != NULL;
+ decoder_ = channel->CreateVideoDecoder(command_buffer_route_id_, profile);
+ return (decoder_ && decoder_->Initialize(profile, this));
}
void PlatformVideoDecoder::Decode(const BitstreamBuffer& bitstream_buffer) {
diff --git a/content/renderer/media/pepper_platform_video_decoder.h b/content/renderer/media/pepper_platform_video_decoder.h
index 83b6487..f0f2433 100644
--- a/content/renderer/media/pepper_platform_video_decoder.h
+++ b/content/renderer/media/pepper_platform_video_decoder.h
@@ -17,12 +17,13 @@ namespace content {
class PlatformVideoDecoder : public media::VideoDecodeAccelerator,
public media::VideoDecodeAccelerator::Client {
public:
- PlatformVideoDecoder(media::VideoDecodeAccelerator::Client* client,
- int32 command_buffer_route_id);
+ explicit PlatformVideoDecoder(int32 command_buffer_route_id);
virtual ~PlatformVideoDecoder();
// PlatformVideoDecoder (a.k.a. VideoDecodeAccelerator) implementation.
- virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual bool Initialize(media::VideoCodecProfile profile,
+ media::VideoDecodeAccelerator::Client* client)
+ OVERRIDE;
virtual void Decode(
const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
virtual void AssignPictureBuffers(
diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
index 4ecd421..6f50d92 100644
--- a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
+++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
@@ -44,25 +44,23 @@ RendererGpuVideoAcceleratorFactories::GetContext3d() {
scoped_ptr<media::VideoDecodeAccelerator>
RendererGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator(
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client) {
+ media::VideoCodecProfile profile) {
DCHECK(task_runner_->BelongsToCurrentThread());
WebGraphicsContext3DCommandBufferImpl* context = GetContext3d();
if (context && context->GetCommandBufferProxy()) {
return gpu_channel_host_->CreateVideoDecoder(
- context->GetCommandBufferProxy()->GetRouteID(), profile, client);
+ context->GetCommandBufferProxy()->GetRouteID(), profile);
}
return scoped_ptr<media::VideoDecodeAccelerator>();
}
scoped_ptr<media::VideoEncodeAccelerator>
-RendererGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client) {
+RendererGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
DCHECK(task_runner_->BelongsToCurrentThread());
- return gpu_channel_host_->CreateVideoEncoder(client);
+ return gpu_channel_host_->CreateVideoEncoder();
}
uint32 RendererGpuVideoAcceleratorFactories::CreateTextures(
diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.h b/content/renderer/media/renderer_gpu_video_accelerator_factories.h
index da6b091..f557734 100644
--- a/content/renderer/media/renderer_gpu_video_accelerator_factories.h
+++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.h
@@ -45,12 +45,9 @@ class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories
// media::GpuVideoAcceleratorFactories implementation.
virtual scoped_ptr<media::VideoDecodeAccelerator>
- CreateVideoDecodeAccelerator(
- media::VideoCodecProfile profile,
- media::VideoDecodeAccelerator::Client* client) OVERRIDE;
+ CreateVideoDecodeAccelerator(media::VideoCodecProfile profile) OVERRIDE;
virtual scoped_ptr<media::VideoEncodeAccelerator>
- CreateVideoEncodeAccelerator(
- media::VideoEncodeAccelerator::Client* client) OVERRIDE;
+ CreateVideoEncodeAccelerator() OVERRIDE;
// Creates textures and produces them into mailboxes. Returns a sync point to
// wait on before using the mailboxes, or 0 on failure.
virtual uint32 CreateTextures(int32 count,
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index ce1f24c..0e9086f 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -672,7 +672,9 @@ void RTCVideoDecoder::ReusePictureBuffer(
void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile,
base::WaitableEvent* waiter) {
DCHECK(vda_task_runner_->BelongsToCurrentThread());
- vda_ = factories_->CreateVideoDecodeAccelerator(profile, this);
+ vda_ = factories_->CreateVideoDecodeAccelerator(profile);
+ if (vda_ && !vda_->Initialize(profile, this))
+ vda_.release()->Destroy();
waiter->Signal();
}
diff --git a/content/renderer/media/rtc_video_decoder_unittest.cc b/content/renderer/media/rtc_video_decoder_unittest.cc
index 240391d..ff16f85 100644
--- a/content/renderer/media/rtc_video_decoder_unittest.cc
+++ b/content/renderer/media/rtc_video_decoder_unittest.cc
@@ -37,15 +37,18 @@ class RTCVideoDecoderTest : public ::testing::Test,
mock_vda_ = new media::MockVideoDecodeAccelerator;
EXPECT_CALL(*mock_gpu_factories_, GetTaskRunner())
.WillRepeatedly(Return(vda_task_runner_));
- EXPECT_CALL(*mock_gpu_factories_, DoCreateVideoDecodeAccelerator(_, _))
+ EXPECT_CALL(*mock_gpu_factories_, DoCreateVideoDecodeAccelerator(_))
.WillRepeatedly(
Return(static_cast<media::VideoDecodeAccelerator*>(NULL)));
EXPECT_CALL(*mock_gpu_factories_,
- DoCreateVideoDecodeAccelerator(media::VP8PROFILE_MAIN, _))
+ DoCreateVideoDecodeAccelerator(media::VP8PROFILE_MAIN))
.WillRepeatedly(Return(mock_vda_));
EXPECT_CALL(*mock_gpu_factories_, CreateSharedMemory(_))
.WillRepeatedly(Return(static_cast<base::SharedMemory*>(NULL)));
- EXPECT_CALL(*mock_vda_, Destroy());
+ EXPECT_CALL(*mock_vda_, Initialize(_, _))
+ .Times(1)
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_vda_, Destroy()).Times(1);
rtc_decoder_ =
RTCVideoDecoder::Create(webrtc::kVideoCodecVP8, mock_gpu_factories_);
}
diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc
index 890ff7b..f6faea5 100644
--- a/content/renderer/media/rtc_video_encoder.cc
+++ b/content/renderer/media/rtc_video_encoder.cc
@@ -181,14 +181,17 @@ void RTCVideoEncoder::Impl::CreateAndInitializeVEA(
return;
}
- video_encoder_ = gpu_factories_->CreateVideoEncodeAccelerator(this).Pass();
+ video_encoder_ = gpu_factories_->CreateVideoEncodeAccelerator().Pass();
if (!video_encoder_) {
NOTIFY_ERROR(media::VideoEncodeAccelerator::kPlatformFailureError);
return;
}
input_visible_size_ = input_visible_size;
- video_encoder_->Initialize(
- media::VideoFrame::I420, input_visible_size_, profile, bitrate * 1000);
+ video_encoder_->Initialize(media::VideoFrame::I420,
+ input_visible_size_,
+ profile,
+ bitrate * 1000,
+ this);
}
void RTCVideoEncoder::Impl::Enqueue(const webrtc::I420VideoFrame* input_frame,
diff --git a/content/renderer/pepper/ppb_video_decoder_impl.cc b/content/renderer/pepper/ppb_video_decoder_impl.cc
index 336892c..0216a91 100644
--- a/content/renderer/pepper/ppb_video_decoder_impl.cc
+++ b/content/renderer/pepper/ppb_video_decoder_impl.cc
@@ -140,13 +140,13 @@ bool PPB_VideoDecoder_Impl::Init(
if (command_buffer_route_id == 0)
return false;
- platform_video_decoder_.reset(new PlatformVideoDecoder(
- this, command_buffer_route_id));
+ platform_video_decoder_.reset(
+ new PlatformVideoDecoder(command_buffer_route_id));
if (!platform_video_decoder_)
return false;
FlushCommandBuffer();
- return platform_video_decoder_->Initialize(PPToMediaProfile(profile));
+ return platform_video_decoder_->Initialize(PPToMediaProfile(profile), this);
}
int32_t PPB_VideoDecoder_Impl::Decode(