diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.cc | 46 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.h | 15 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.h | 5 |
4 files changed, 41 insertions, 32 deletions
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( |