summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc9
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h3
-rw-r--r--content/common/gpu/gpu_messages.h7
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.cc13
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.h11
-rw-r--r--content/renderer/gpu/gpu_video_decode_accelerator_host.cc7
-rw-r--r--content/renderer/gpu/gpu_video_decode_accelerator_host.h4
-rw-r--r--content/renderer/pepper_platform_video_decoder_impl.cc5
-rw-r--r--ppapi/c/dev/ppb_video_decoder_dev.h32
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc17
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h14
-rw-r--r--ppapi/examples/gles2/gles2.cc12
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc5
-rw-r--r--ppapi/proxy/resource_creation_proxy.h5
-rw-r--r--ppapi/tests/arch_dependent_sizes_32.h2
-rw-r--r--ppapi/tests/arch_dependent_sizes_64.h2
-rw-r--r--ppapi/tests/test_video_decoder.cc20
-rw-r--r--ppapi/tests/test_video_decoder.h3
-rw-r--r--ppapi/thunk/ppb_video_decoder_api.h3
-rw-r--r--ppapi/thunk/ppb_video_decoder_thunk.cc19
-rw-r--r--ppapi/thunk/resource_creation_api.h5
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc46
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.h15
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc7
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h5
25 files changed, 119 insertions, 152 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 721b3b0..e1e95bb 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -87,8 +87,8 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
OnDestroyTransferBuffer);
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer,
OnGetTransferBuffer);
- IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateVideoDecoder,
- OnCreateVideoDecoder)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
+ OnCreateVideoDecoder)
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder,
OnDestroyVideoDecoder)
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer,
@@ -547,10 +547,11 @@ void GpuCommandBufferStub::ReportState() {
}
void GpuCommandBufferStub::OnCreateVideoDecoder(
- const std::vector<uint32>& configs) {
+ const std::vector<uint32>& configs,
+ IPC::Message* reply_message) {
video_decoder_.reset(
new GpuVideoDecodeAccelerator(this, route_id_, this));
- video_decoder_->Initialize(configs);
+ video_decoder_->Initialize(configs, reply_message);
}
void GpuCommandBufferStub::OnDestroyVideoDecoder() {
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index dd84f5d..a6e91fb 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -112,7 +112,8 @@ class GpuCommandBufferStub
void OnGetTransferBuffer(int32 id, IPC::Message* reply_message);
void OnResizeOffscreenFrameBuffer(const gfx::Size& size);
- void OnCreateVideoDecoder(const std::vector<uint32>& configs);
+ void OnCreateVideoDecoder(const std::vector<uint32>& configs,
+ IPC::Message* reply_message);
void OnDestroyVideoDecoder();
void OnSwapBuffers();
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 477f0db..1b48b53 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -386,8 +386,8 @@ IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_GetTransferBuffer,
uint32 /* size */)
// Create and initialize a hardware video decoder.
-IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_CreateVideoDecoder,
- std::vector<uint32> /* configs */)
+IPC_SYNC_MESSAGE_ROUTED1_0(GpuCommandBufferMsg_CreateVideoDecoder,
+ std::vector<uint32> /* configs */)
// Release all resources held by the hardware video decoder associated with this
// stub.
@@ -496,9 +496,6 @@ IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers,
int32, /* Number of video frames to generate */
gfx::Size) /* Requested size of buffer */
-// Notify client that decoder has been initialized.
-IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_InitializeDone)
-
// Decoder reports that a picture is ready and buffer does not need to be passed
// back to the decoder.
IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer,
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc
index 855041b..777a13b 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -26,6 +26,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
int32 host_route_id,
GpuCommandBufferStub* stub)
: sender_(sender),
+ init_done_msg_(NULL),
host_route_id_(host_route_id),
stub_(stub),
video_decode_accelerator_(NULL) {
@@ -92,10 +93,15 @@ void GpuVideoDecodeAccelerator::NotifyError(
}
}
-void GpuVideoDecodeAccelerator::Initialize(const std::vector<uint32>& configs) {
+void GpuVideoDecodeAccelerator::Initialize(
+ const std::vector<uint32>& configs,
+ IPC::Message* init_done_msg) {
DCHECK(!video_decode_accelerator_.get());
+ DCHECK(!init_done_msg_);
+ DCHECK(init_done_msg);
#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
DCHECK(stub_ && stub_->scheduler());
+ init_done_msg_ = init_done_msg;
OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this);
omx_decoder->SetEglState(
gfx::GLSurfaceEGL::GetHardwareDisplay(),
@@ -167,8 +173,9 @@ void GpuVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer(
}
void GpuVideoDecodeAccelerator::NotifyInitializeDone() {
- if (!Send(new AcceleratedVideoDecoderHostMsg_InitializeDone(host_route_id_)))
- LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_InitializeDone) failed";
+ if (!Send(init_done_msg_))
+ LOG(ERROR) << "Send(init_done_msg_) failed";
+ init_done_msg_ = NULL;
}
void GpuVideoDecodeAccelerator::NotifyFlushDone() {
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h
index 6c06432..e1d4261 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.h
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.h
@@ -43,8 +43,10 @@ class GpuVideoDecodeAccelerator
// Function to delegate sending to actual sender.
virtual bool Send(IPC::Message* message);
- // Initialize the accelerator with the given configuration.
- void Initialize(const std::vector<uint32>& configs);
+ // Initialize the accelerator with the given configuration and send the
+ // |init_done_msg| when done.
+ void Initialize(const std::vector<uint32>& configs,
+ IPC::Message* init_done_msg);
private:
@@ -63,6 +65,11 @@ class GpuVideoDecodeAccelerator
// Pointer to the IPC message sender.
IPC::Message::Sender* sender_;
+ // Message to Send() when initialization is done. Is only non-NULL during
+ // initialization and is owned by the IPC channel underlying the
+ // GpuCommandBufferStub.
+ IPC::Message* init_done_msg_;
+
// Route ID to communicate with the host.
int32 host_route_id_;
diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc
index 1b083aa..599e3ee 100644
--- a/content/renderer/gpu/gpu_video_decode_accelerator_host.cc
+++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.cc
@@ -43,8 +43,6 @@ bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) {
OnBitstreamBufferProcessed)
IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers,
OnProvidePictureBuffer)
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializeDone,
- OnInitializeDone)
IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady,
OnPictureReady)
IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone,
@@ -143,11 +141,6 @@ void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer(
client_->DismissPictureBuffer(picture_buffer_id);
}
-void GpuVideoDecodeAcceleratorHost::OnInitializeDone() {
- DCHECK(CalledOnValidThread());
- client_->NotifyInitializeDone();
-}
-
void GpuVideoDecodeAcceleratorHost::OnPictureReady(
int32 picture_buffer_id, int32 bitstream_buffer_id) {
DCHECK(CalledOnValidThread());
diff --git a/content/renderer/gpu/gpu_video_decode_accelerator_host.h b/content/renderer/gpu/gpu_video_decode_accelerator_host.h
index 5a913ae..02a8a3e 100644
--- a/content/renderer/gpu/gpu_video_decode_accelerator_host.h
+++ b/content/renderer/gpu/gpu_video_decode_accelerator_host.h
@@ -46,9 +46,7 @@ class GpuVideoDecodeAcceleratorHost
void OnProvidePictureBuffer(
uint32 num_requested_buffers, const gfx::Size& buffer_size);
void OnDismissPictureBuffer(int32 picture_buffer_id);
- void OnInitializeDone();
- void OnPictureReady(int32 picture_buffer_id,
- int32 bitstream_buffer_id);
+ void OnPictureReady(int32 picture_buffer_id, int32 bitstream_buffer_id);
void OnFlushDone();
void OnResetDone();
void OnEndOfStream();
diff --git a/content/renderer/pepper_platform_video_decoder_impl.cc b/content/renderer/pepper_platform_video_decoder_impl.cc
index 29667ff..39733a9 100644
--- a/content/renderer/pepper_platform_video_decoder_impl.cc
+++ b/content/renderer/pepper_platform_video_decoder_impl.cc
@@ -46,7 +46,7 @@ bool PlatformVideoDecoderImpl::Initialize(const std::vector<uint32>& configs) {
// Send IPC message to initialize decoder in GPU process.
decoder_ = channel->CreateVideoDecoder(
command_buffer_route_id_, configs, this);
- return true;
+ return decoder_.get() != NULL;
}
void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) {
@@ -112,8 +112,7 @@ void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) {
}
void PlatformVideoDecoderImpl::NotifyInitializeDone() {
- DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
- client_->NotifyInitializeDone();
+ NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!";
}
void PlatformVideoDecoderImpl::NotifyEndOfBitstreamBuffer(
diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h
index 24cab18..cf188d2 100644
--- a/ppapi/c/dev/ppb_video_decoder_dev.h
+++ b/ppapi/c/dev/ppb_video_decoder_dev.h
@@ -9,15 +9,13 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_var.h"
-#define PPB_VIDEODECODER_DEV_INTERFACE_0_14 "PPB_VideoDecoder(Dev);0.14"
-#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_14
+#define PPB_VIDEODECODER_DEV_INTERFACE_0_15 "PPB_VideoDecoder(Dev);0.15"
+#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_15
// Video decoder interface.
//
// Typical usage:
-// - Use Create() to get a new PPB_VideoDecoder_Dev resource.
-// - Call Initialize() to create the underlying resources in the GPU process and
-// configure the decoder there.
+// - Use Create() to create & configure a new PPB_VideoDecoder_Dev resource.
// - Call Decode() to decode some video data.
// - Receive ProvidePictureBuffers callback
// - Supply the decoder with textures using AssignPictureBuffers.
@@ -32,14 +30,17 @@
// See PPP_VideoDecoder_Dev for the notifications the decoder may send the
// plugin.
struct PPB_VideoDecoder_Dev {
- // Creates a video decoder. Initialize() must be called afterwards to
- // set its configuration.
+ // Creates & initializes a video decoder.
//
// Parameters:
// |instance| pointer to the plugin instance.
+ // |context_3d| a PPB_Context3D_Dev resource in which decoding will happen.
+ // |decoder_config| the configuration to use to initialize the decoder.
//
// The created decoder is returned as PP_Resource. 0 means failure.
- PP_Resource (*Create)(PP_Instance instance);
+ PP_Resource (*Create)(PP_Instance instance,
+ PP_Resource context,
+ const PP_VideoConfigElement* decoder_config);
// Tests whether |resource| is a video decoder created through Create
// function of this interface.
@@ -50,21 +51,6 @@ struct PPB_VideoDecoder_Dev {
// Returns true if is a video decoder, false otherwise.
PP_Bool (*IsVideoDecoder)(PP_Resource resource);
- // Initializes the video decoder with requested configuration.
- //
- // Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
- // |context| the GL context in which decoding will happen. This should be a
- // resource of type PPB_Context3D_Dev.
- // |decoder_config| the configuration to use to initialize the decoder.
- // |callback| called after initialization is complete.
- //
- // Returns an error code from pp_errors.h.
- int32_t (*Initialize)(PP_Resource video_decoder,
- PP_Resource context,
- const PP_VideoConfigElement* decoder_config,
- struct PP_CompletionCallback callback);
-
// Dispatches bitstream buffer to the decoder.
//
// Parameters:
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index 5f8ce40..baf180d 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -22,11 +22,13 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
} // namespace
-VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance) {
+VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance,
+ const Context3D_Dev& context,
+ const PP_VideoConfigElement* config) {
if (!has_interface<PPB_VideoDecoder_Dev>())
return;
PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
- instance.pp_instance()));
+ instance.pp_instance(), context.pp_resource(), config));
}
VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) {
@@ -36,17 +38,6 @@ VideoDecoder_Dev::~VideoDecoder_Dev() {
get_interface<PPB_VideoDecoder_Dev>()->Destroy(pp_resource());
}
-
-int32_t VideoDecoder_Dev::Initialize(const PP_VideoConfigElement* config,
- const Context3D_Dev& context,
- CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return callback.MayForce(PP_ERROR_NOINTERFACE);
- return get_interface<PPB_VideoDecoder_Dev>()->Initialize(
- pp_resource(), context.pp_resource(), config,
- callback.pp_completion_callback());
-}
-
void VideoDecoder_Dev::AssignPictureBuffers(
const std::vector<PP_PictureBuffer_Dev>& buffers) {
if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h
index d1dee6a..d831116 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -23,19 +23,15 @@ class Instance;
// C++ version of the PPB_VideoDecoder_Dev interface.
class VideoDecoder_Dev : public Resource {
public:
- // Constructor for the video decoder. Calls the Create on the
- // PPB_VideoDecoder_Dev interface.
- //
- // Parameters:
- // |instance| is the pointer to the plug-in instance.
- explicit VideoDecoder_Dev(const Instance& instance);
+ // See PPB_VideoDecoder_Dev::Create.
+ explicit VideoDecoder_Dev(const Instance& instance,
+ const Context3D_Dev& context,
+ const PP_VideoConfigElement* config);
+
explicit VideoDecoder_Dev(PP_Resource resource);
virtual ~VideoDecoder_Dev();
// PPB_VideoDecoder_Dev implementation.
- int32_t Initialize(const PP_VideoConfigElement* config,
- const Context3D_Dev& context,
- CompletionCallback callback);
void AssignPictureBuffers(const std::vector<PP_PictureBuffer_Dev>& buffers);
int32_t Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
CompletionCallback callback);
diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc
index e46f02d..e917374 100644
--- a/ppapi/examples/gles2/gles2.cc
+++ b/ppapi/examples/gles2/gles2.cc
@@ -213,16 +213,12 @@ void GLES2DemoInstance::DidChangeView(
}
void GLES2DemoInstance::InitializeDecoder() {
- assert(!video_decoder_);
- video_decoder_ = new pp::VideoDecoder_Dev(*this);
-
PP_VideoConfigElement configs = PP_VIDEOATTR_DICTIONARY_TERMINATOR;
- pp::CompletionCallback cb =
- callback_factory_.NewCallback(&GLES2DemoInstance::DecoderInitDone);
- video_decoder_->Initialize(&configs, *context_, cb);
-}
-void GLES2DemoInstance::DecoderInitDone(int32_t result) {
+ assert(!video_decoder_);
+ video_decoder_ = new pp::VideoDecoder_Dev(*this, *context_, &configs);
+ assert(!video_decoder_->is_null());
+
DecodeNextNALUs();
}
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 4de1127..d517ea6 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -291,7 +291,10 @@ PP_Resource ResourceCreationProxy::CreateURLRequestInfo(PP_Instance instance) {
return PPB_URLRequestInfo_Proxy::CreateProxyResource(instance);
}
-PP_Resource ResourceCreationProxy::CreateVideoDecoder(PP_Instance instance) {
+PP_Resource ResourceCreationProxy::CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) {
NOTIMPLEMENTED();
return 0;
}
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h
index 304d7fb..2eefe62 100644
--- a/ppapi/proxy/resource_creation_proxy.h
+++ b/ppapi/proxy/resource_creation_proxy.h
@@ -109,7 +109,10 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase,
const char* proto) OVERRIDE;
virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE;
- virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) OVERRIDE;
virtual PP_Resource CreateVideoLayer(PP_Instance instance,
PP_VideoLayerMode_Dev mode) OVERRIDE;
virtual PP_Resource CreateWheelInputEvent(
diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h
index 1e9260a..e207bc2 100644
--- a/ppapi/tests/arch_dependent_sizes_32.h
+++ b/ppapi/tests/arch_dependent_sizes_32.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 12);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 36);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 32);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 20);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_32_H_ */
diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h
index 23d9c01..340456d 100644
--- a/ppapi/tests/arch_dependent_sizes_64.h
+++ b/ppapi/tests/arch_dependent_sizes_64.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 72);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 64);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 40);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_64_H_ */
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
index f4f2678..9b9d965 100644
--- a/ppapi/tests/test_video_decoder.cc
+++ b/ppapi/tests/test_video_decoder.cc
@@ -15,30 +15,22 @@ REGISTER_TEST_CASE(VideoDecoder);
bool TestVideoDecoder::Init() {
video_decoder_interface_ = reinterpret_cast<PPB_VideoDecoder_Dev const*>(
pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE));
- var_interface_ = reinterpret_cast<PPB_Var const*>(
- pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
- return video_decoder_interface_ && var_interface_ && InitTestingInterface();
+ return video_decoder_interface_ && InitTestingInterface();
}
void TestVideoDecoder::RunTest() {
- RUN_TEST(CreateAndInitialize);
+ RUN_TEST(CreateFailure);
}
void TestVideoDecoder::QuitMessageLoop() {
testing_interface_->QuitMessageLoop(instance_->pp_instance());
}
-std::string TestVideoDecoder::TestCreateAndInitialize() {
+std::string TestVideoDecoder::TestCreateFailure() {
PP_Resource decoder = video_decoder_interface_->Create(
- instance_->pp_instance());
- if (decoder == 0)
- return "Create: error creating the decoder";
-
- int32_t pp_error = video_decoder_interface_->Initialize(
- decoder, 0, NULL, PP_BlockUntilComplete());
- pp::Module::Get()->core()->ReleaseResource(decoder);
- if (pp_error != PP_ERROR_BADARGUMENT)
- return "Initialize: error detecting null callback";
+ instance_->pp_instance(), 0, NULL);
+ if (decoder != 0)
+ return "Create: error detecting invalid context & configs";
PASS();
}
diff --git a/ppapi/tests/test_video_decoder.h b/ppapi/tests/test_video_decoder.h
index dbef66f..7409b4e 100644
--- a/ppapi/tests/test_video_decoder.h
+++ b/ppapi/tests/test_video_decoder.h
@@ -22,11 +22,10 @@ class TestVideoDecoder : public TestCase {
void QuitMessageLoop();
private:
- std::string TestCreateAndInitialize();
+ std::string TestCreateFailure();
// Used by the tests that access the C API directly.
const PPB_VideoDecoder_Dev* video_decoder_interface_;
- const PPB_Var* var_interface_;
};
#endif // PPAPI_TESTS_TEST_VIDEO_DECODER_H_
diff --git a/ppapi/thunk/ppb_video_decoder_api.h b/ppapi/thunk/ppb_video_decoder_api.h
index 5f8063c..e17d22b 100644
--- a/ppapi/thunk/ppb_video_decoder_api.h
+++ b/ppapi/thunk/ppb_video_decoder_api.h
@@ -14,9 +14,6 @@ class PPB_VideoDecoder_API {
public:
virtual ~PPB_VideoDecoder_API() {}
- virtual int32_t Initialize(PP_Resource context_id,
- const PP_VideoConfigElement* decoder_config,
- PP_CompletionCallback callback) = 0;
virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
PP_CompletionCallback callback) = 0;
virtual void AssignPictureBuffers(uint32_t no_of_buffers,
diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc
index f1b7c44..cb0485c 100644
--- a/ppapi/thunk/ppb_video_decoder_thunk.cc
+++ b/ppapi/thunk/ppb_video_decoder_thunk.cc
@@ -16,11 +16,13 @@ namespace {
typedef EnterResource<PPB_VideoDecoder_API> EnterVideoDecoder;
-PP_Resource Create(PP_Instance instance) {
+PP_Resource Create(PP_Instance instance,
+ PP_Resource context_3d,
+ const PP_VideoConfigElement* config) {
EnterFunction<ResourceCreationAPI> enter(instance, true);
if (enter.failed())
return 0;
- return enter.functions()->CreateVideoDecoder(instance);
+ return enter.functions()->CreateVideoDecoder(instance, context_3d, config);
}
PP_Bool IsVideoDecoder(PP_Resource resource) {
@@ -28,18 +30,6 @@ PP_Bool IsVideoDecoder(PP_Resource resource) {
return PP_FromBool(enter.succeeded());
}
-int32_t Initialize(PP_Resource video_decoder,
- PP_Resource context_id,
- const PP_VideoConfigElement* decoder_config,
- PP_CompletionCallback callback) {
- EnterVideoDecoder enter(video_decoder, true);
- if (enter.failed())
- return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
- int32_t result =
- enter.object()->Initialize(context_id, decoder_config, callback);
- return MayForceCallback(callback, result);
-}
-
int32_t Decode(PP_Resource video_decoder,
const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
PP_CompletionCallback callback) {
@@ -90,7 +80,6 @@ void Destroy(PP_Resource video_decoder) {
const PPB_VideoDecoder_Dev g_ppb_videodecoder_thunk = {
&Create,
&IsVideoDecoder,
- &Initialize,
&Decode,
&AssignPictureBuffers,
&ReusePictureBuffer,
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 4e6124e..8d6c01b 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -109,7 +109,10 @@ class ResourceCreationAPI {
const char* proto) = 0;
virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0;
virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) = 0;
- virtual PP_Resource CreateVideoDecoder(PP_Instance instance) = 0;
+ virtual PP_Resource CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) = 0;
virtual PP_Resource CreateVideoLayer(PP_Instance instance,
PP_VideoLayerMode_Dev mode) = 0;
virtual PP_Resource CreateWheelInputEvent(
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 4874998..562fe3e 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -51,36 +51,42 @@ PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() {
return this;
}
-int32_t PPB_VideoDecoder_Impl::Initialize(
- PP_Resource context_id,
- const PP_VideoConfigElement* decoder_config,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+// static
+PP_Resource PPB_VideoDecoder_Impl::Create(PluginInstance* instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) {
+ scoped_refptr<PPB_VideoDecoder_Impl> decoder(
+ new PPB_VideoDecoder_Impl(instance));
+ if (decoder->Init(context3d_id, config))
+ return decoder->GetReference();
+ return 0;
+}
- if (!instance())
- return PP_ERROR_FAILED;
+bool PPB_VideoDecoder_Impl::Init(PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) {
+ if (!instance() || !context3d_id || !config)
+ return false;
- EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true);
+ EnterResourceNoLock<PPB_Context3D_API> enter(context3d_id, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
+ return false;
PPB_Context3D_Impl* context3d =
static_cast<PPB_Context3D_Impl*>(enter.object());
- context3d_id_ = context_id;
+ context3d_id_ = context3d_id;
ResourceTracker::Get()->AddRefResource(context3d_id_);
int command_buffer_route_id =
context3d->platform_context()->GetCommandBufferRouteId();
if (command_buffer_route_id == 0)
- return PP_ERROR_FAILED;
+ return false;
platform_video_decoder_ = instance()->delegate()->CreateVideoDecoder(
this, command_buffer_route_id);
gles2_impl_ = context3d->gles2_impl();
if (!platform_video_decoder_)
- return PP_ERROR_FAILED;
+ return false;
std::vector<uint32> copied;
// TODO(fischman,vrk): this is completely broken in that it fails to account
@@ -91,18 +97,13 @@ int32_t PPB_VideoDecoder_Impl::Initialize(
// VideoAttributeKey have identical enum values. There is no compiler
// assert to guarantee this. We either need to add such asserts or
// merge PP_VideoAttributeDictionary and VideoAttributeKey.
- for (const PP_VideoConfigElement* current = decoder_config;
+ for (const PP_VideoConfigElement* current = config;
*current != PP_VIDEOATTR_DICTIONARY_TERMINATOR; ++current) {
copied.push_back(static_cast<uint32>(*current));
}
FlushCommandBuffer();
- if (platform_video_decoder_->Initialize(copied)) {
- initialization_callback_ = callback;
- return PP_OK_COMPLETIONPENDING;
- } else {
- return PP_ERROR_FAILED;
- }
+ return platform_video_decoder_->Initialize(copied);
}
int32_t PPB_VideoDecoder_Impl::Decode(
@@ -276,10 +277,7 @@ void PPB_VideoDecoder_Impl::NotifyFlushDone() {
}
void PPB_VideoDecoder_Impl::NotifyInitializeDone() {
- if (initialization_callback_.func == NULL)
- return;
-
- PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK);
+ NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!";
}
void PPB_VideoDecoder_Impl::FlushCommandBuffer() {
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
index b6193e7..2347c4b 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
@@ -38,16 +38,17 @@ class PPB_VideoDecoder_Impl : public Resource,
public ::ppapi::thunk::PPB_VideoDecoder_API,
public media::VideoDecodeAccelerator::Client {
public:
- explicit PPB_VideoDecoder_Impl(PluginInstance* instance);
virtual ~PPB_VideoDecoder_Impl();
+ // See PPB_VideoDecoder_Dev::Create. Returns 0 on failure to create &
+ // initialize.
+ static PP_Resource Create(PluginInstance* instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config);
// ResourceObjectBase overrides.
virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
// PPB_VideoDecoder_API implementation.
- virtual int32_t Initialize(PP_Resource context_id,
- const PP_VideoConfigElement* dec_config,
- PP_CompletionCallback callback) OVERRIDE;
virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
PP_CompletionCallback callback) OVERRIDE;
virtual void AssignPictureBuffers(
@@ -75,6 +76,11 @@ class PPB_VideoDecoder_Impl : public Resource,
// done.
typedef std::map<int32, PP_CompletionCallback> CallbackById;
+ explicit PPB_VideoDecoder_Impl(PluginInstance* instance);
+
+ // Initialize the underlying decoder and return success status.
+ bool Init(PP_Resource context_id, const PP_VideoConfigElement* dec_config);
+
// Tell command buffer to process all commands it has received so far.
void FlushCommandBuffer();
@@ -89,7 +95,6 @@ class PPB_VideoDecoder_Impl : public Resource,
// for reference counting to keep it alive for the lifetime of |*this|.
PP_Resource context3d_id_;
- PP_CompletionCallback initialization_callback_;
PP_CompletionCallback flush_callback_;
PP_CompletionCallback reset_callback_;
CallbackById bitstream_buffer_callbacks_;
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 61b3d72..e68d167 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -283,8 +283,11 @@ PP_Resource ResourceCreationImpl::CreateURLRequestInfo(PP_Instance instance) {
return ReturnResource(new PPB_URLRequestInfo_Impl(instance_));
}
-PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) {
- return ReturnResource(new PPB_VideoDecoder_Impl(instance_));
+PP_Resource ResourceCreationImpl::CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) {
+ return PPB_VideoDecoder_Impl::Create(instance_, context3d_id, config);
}
PP_Resource ResourceCreationImpl::CreateVideoLayer(PP_Instance instance,
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 5a8e734..3342896 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -100,7 +100,10 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
const char* proto) OVERRIDE;
virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE;
- virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateVideoDecoder(
+ PP_Instance instance,
+ PP_Resource context3d_id,
+ const PP_VideoConfigElement* config) OVERRIDE;
virtual PP_Resource CreateVideoLayer(PP_Instance instance,
PP_VideoLayerMode_Dev mode) OVERRIDE;
virtual PP_Resource CreateWheelInputEvent(