diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 18:40:29 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 18:40:29 +0000 |
commit | d2f777617b4c8873e6b72dcd3a0fd6809f7e4dbb (patch) | |
tree | 811d79f44b066d8ac7e837d287b2304a81774b6c /ppapi | |
parent | 484372884fa6236934471d00e84b23c26e1a22a7 (diff) | |
download | chromium_src-d2f777617b4c8873e6b72dcd3a0fd6809f7e4dbb.zip chromium_src-d2f777617b4c8873e6b72dcd3a0fd6809f7e4dbb.tar.gz chromium_src-d2f777617b4c8873e6b72dcd3a0fd6809f7e4dbb.tar.bz2 |
Implement AssignGLESBuffers for VideoDecode PPAPI
Fills in implementation for AssignGLESBuffers where it was missing. Also
updates OmxVideoDecodeAccelerator to reflect the changes.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6965010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/dev/pp_video_dev.h | 3 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_video_decoder_dev.h | 7 | ||||
-rw-r--r-- | ppapi/c/dev/ppp_video_decoder_dev.h | 32 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_client_dev.cc | 98 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_client_dev.h | 57 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_dev.cc | 45 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_dev.h | 51 | ||||
-rw-r--r-- | ppapi/ppapi_cpp.gypi | 2 | ||||
-rw-r--r-- | ppapi/tests/test_video_decoder.cc | 2 |
9 files changed, 218 insertions, 79 deletions
diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 4bf1cf3..8833818 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -201,9 +201,6 @@ struct PP_BufferInfo_Dev { // Struct for specifying texture-backed picture data. struct PP_GLESBuffer_Dev { - // Context allocated using PPB_Context3D_Dev. - PP_Resource context; - // Texture ID in the given context where picture is stored. GLuint texture_id; diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 4ec65df..7f59df1 100644 --- a/ppapi/c/dev/ppb_video_decoder_dev.h +++ b/ppapi/c/dev/ppb_video_decoder_dev.h @@ -9,8 +9,8 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_var.h" -#define PPB_VIDEODECODER_DEV_INTERFACE_0_8 "PPB_VideoDecoder(Dev);0.8" -#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_8 +#define PPB_VIDEODECODER_DEV_INTERFACE_0_9 "PPB_VideoDecoder(Dev);0.9" +#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_9 // Video decoder interface. // @@ -139,11 +139,14 @@ struct PPB_VideoDecoder_Dev { // // 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); diff --git a/ppapi/c/dev/ppp_video_decoder_dev.h b/ppapi/c/dev/ppp_video_decoder_dev.h index af5eaaf..e18146d 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -5,9 +5,11 @@ #ifndef PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_resource.h" #include "ppapi/c/dev/pp_video_dev.h" -#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.3" +#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.4" // PPP_VideoDecoder_Dev structure contains the function pointers that the // plugin MUST implement to provide services needed by the video decoder @@ -21,11 +23,13 @@ struct PPP_VideoDecoder_Dev { // Decoding will not proceed until buffers have been provided. // // Parameters: - // |decoder| is pointer to the Pepper Video Decoder instance. + // |instance| the plugin instance to which the callback is responding. + // |decoder| is pointer to the Pepper Video Decoder resource. // |req_num_of_bufs| tells how many buffers are needed by the decoder. // |dimensions| tells the dimensions of the buffer to allocate. // |type| specifies whether the buffer lives in system memory or GL texture. void (*ProvidePictureBuffers)( + PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, struct PP_Size dimensions, @@ -35,9 +39,11 @@ struct PPP_VideoDecoder_Dev { // the plugin. // // Parameters: - // |decoder| is pointer to the Pepper Video Decoder instance. + // |instance| the plugin instance to which the callback is responding. + // |decoder| is pointer to the Pepper Video Decoder resource. // |picture_buffer| points to the picture buffer that is no longer needed. - void (*DismissPictureBuffer)(PP_Resource decoder, + void (*DismissPictureBuffer)(PP_Instance instance, + PP_Resource decoder, int32_t picture_buffer_id); // Callback function for decoder to deliver decoded pictures ready to be @@ -45,9 +51,11 @@ struct PPP_VideoDecoder_Dev { // decoder through ReusePictureBuffer function in PPB Video Decoder API. // // Parameters: - // |decoder| is pointer to the Pepper Video Decoder instance. + // |instance| the plugin instance to which the callback is responding. + // |decoder| is pointer to the Pepper Video Decoder resource. // |picture| is the picture that is ready. - void (*PictureReady)(PP_Resource decoder, + void (*PictureReady)(PP_Instance instance, + PP_Resource decoder, struct PP_Picture_Dev picture); // Callback function to tell the plugin that decoder has decoded end of stream @@ -55,8 +63,9 @@ struct PPP_VideoDecoder_Dev { // stream. // // Parameters: - // |decoder| is pointer to the Pepper Video Decoder instance. - void (*EndOfStream)(PP_Resource decoder); + // |instance| the plugin instance to which the callback is responding. + // |decoder| is pointer to the Pepper Video Decoder resource. + void (*EndOfStream)(PP_Instance instance, PP_Resource decoder); // Error handler callback for decoder to deliver information about detected // errors to the plugin. @@ -64,9 +73,12 @@ struct PPP_VideoDecoder_Dev { // TODO(vmr): Fill out error result codes and corresponding actions. // // Parameters: - // |decoder| is pointer to the Pepper Video Decoder instance. + // |instance| the plugin instance to which the callback is responding. + // |decoder| is pointer to the Pepper Video Decoder resource. // |error| error is the enumeration specifying the error. - void (*NotifyError)(PP_Resource decoder, enum PP_VideoDecodeError_Dev error); + void (*NotifyError)(PP_Instance instance, + PP_Resource decoder, + enum PP_VideoDecodeError_Dev error); }; #endif /* PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ */ diff --git a/ppapi/cpp/dev/video_decoder_client_dev.cc b/ppapi/cpp/dev/video_decoder_client_dev.cc new file mode 100644 index 0000000..aa00c6f --- /dev/null +++ b/ppapi/cpp/dev/video_decoder_client_dev.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/dev/video_decoder_client_dev.h" + +#include "ppapi/c/dev/ppp_video_decoder_dev.h" +#include "ppapi/cpp/dev/video_decoder_dev.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; + +// Callback to provide buffers for the decoded output pictures. +void ProvidePictureBuffers(PP_Instance instance, + PP_Resource decoder_id, + uint32_t req_num_of_bufs, + struct PP_Size dimensions, + enum PP_PictureBufferType_Dev type) { + void* object = pp::Instance::GetPerInstanceObject( + instance, kPPPVideoDecoderInterface); + if (!object) + return; + static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( + VideoDecoder_Dev(decoder_id), req_num_of_bufs, dimensions, type); +} + +void DismissPictureBuffer(PP_Instance instance, + PP_Resource decoder_id, + int32_t picture_buffer_id) { + void* object = pp::Instance::GetPerInstanceObject( + instance, kPPPVideoDecoderInterface); + if (!object) + return; + static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( + VideoDecoder_Dev(decoder_id), picture_buffer_id); +} + +void PictureReady(PP_Instance instance, + PP_Resource decoder_id, + PP_Picture_Dev picture) { + void* object = pp::Instance::GetPerInstanceObject( + instance, kPPPVideoDecoderInterface); + if (!object) + return; + static_cast<VideoDecoderClient_Dev*>(object)->PictureReady( + VideoDecoder_Dev(decoder_id), picture); +} + +void EndOfStream(PP_Instance instance, PP_Resource decoder_id) { + void* object = pp::Instance::GetPerInstanceObject( + instance, kPPPVideoDecoderInterface); + if (!object) + return; + static_cast<VideoDecoderClient_Dev*>(object)->EndOfStream( + VideoDecoder_Dev(decoder_id)); +} + +void NotifyError(PP_Instance instance, + PP_Resource decoder_id, + PP_VideoDecodeError_Dev error) { + void* object = pp::Instance::GetPerInstanceObject( + instance, kPPPVideoDecoderInterface); + if (!object) + return; + static_cast<VideoDecoderClient_Dev*>(object)->NotifyError( + VideoDecoder_Dev(decoder_id), error); +} + +static PPP_VideoDecoder_Dev videodecoder_interface = { + &ProvidePictureBuffers, + &DismissPictureBuffer, + &PictureReady, + &EndOfStream, + &NotifyError, +}; + +} // namespace + +VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance* instance) + : associated_instance_(instance) { + pp::Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, + &videodecoder_interface); + associated_instance_->AddPerInstanceObject( + kPPPVideoDecoderInterface, this); +} + +VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { + associated_instance_->RemovePerInstanceObject( + kPPPVideoDecoderInterface, this); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/video_decoder_client_dev.h b/ppapi/cpp/dev/video_decoder_client_dev.h new file mode 100644 index 0000000..776d54b --- /dev/null +++ b/ppapi/cpp/dev/video_decoder_client_dev.h @@ -0,0 +1,57 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ +#define PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ + +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/dev/pp_video_dev.h" + +namespace pp { + +class Instance; +class VideoDecoder_Dev; + +// This class provides a C++ interface for callbacks related to video decoding. +// It is the C++ counterpart to PPP_VideoDecoder_Dev. +// You would normally use multiple inheritance to derive from this class in your +// instance. +class VideoDecoderClient_Dev { + public: + VideoDecoderClient_Dev(Instance* instance); + virtual ~VideoDecoderClient_Dev(); + + // Callback to provide buffers for the decoded output pictures. + virtual void ProvidePictureBuffers( + VideoDecoder_Dev decoder, + uint32_t req_num_of_bufs, + struct PP_Size dimensions, + enum PP_PictureBufferType_Dev type) = 0; + + // Callback for decoder to delivered unneeded picture buffers back to the + // plugin. + virtual void DismissPictureBuffer( + VideoDecoder_Dev decoder, + int32_t picture_buffer_id) = 0; + + // Callback to deliver decoded pictures ready to be displayed. + virtual void PictureReady( + VideoDecoder_Dev decoder, + const PP_Picture_Dev& picture) = 0; + + // Callback to notify that decoder has decoded end of stream marker and has + // outputted all displayable pictures. + virtual void EndOfStream(VideoDecoder_Dev decoder) = 0; + + // Callback to notify about decoding errors. + virtual void NotifyError( + VideoDecoder_Dev decoder, PP_VideoDecodeError_Dev error) = 0; + + private: + Instance* associated_instance_; +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_VIDEO_DECODER_CLIENT_DEV_H_ diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index b1ebcfb..c8d6ff4 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -8,6 +8,7 @@ #include "ppapi/c/dev/ppp_video_decoder_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/common.h" +#include "ppapi/cpp/dev/context_3d_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -22,37 +23,41 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() { } // namespace -VideoDecoder::VideoDecoder(const Instance* instance, Client* client) - : client_(client) { +VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance) { if (!has_interface<PPB_VideoDecoder_Dev>()) return; PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create( - instance->pp_instance())); + instance.pp_instance())); } -VideoDecoder::~VideoDecoder() {} +VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) { +} + +VideoDecoder_Dev::~VideoDecoder_Dev() {} -int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config, - CompletionCallback callback) { +int32_t VideoDecoder_Dev::Initialize(const PP_VideoConfigElement* config, + const Context3D_Dev& context, + CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) return PP_ERROR_NOINTERFACE; return get_interface<PPB_VideoDecoder_Dev>()->Initialize( - pp_resource(), config, callback.pp_completion_callback()); + pp_resource(), context.pp_resource(), config, + callback.pp_completion_callback()); } -bool VideoDecoder::GetConfigs(Instance* instance, - const PP_VideoConfigElement* prototype_config, - PP_VideoConfigElement* matching_configs, - uint32_t matching_configs_size, - uint32_t* num_of_matching_configs) { +bool VideoDecoder_Dev::GetConfigs(Instance* instance, + const PP_VideoConfigElement* prototype_config, + PP_VideoConfigElement* matching_configs, + uint32_t matching_configs_size, + uint32_t* num_of_matching_configs) { if (!has_interface<PPB_VideoDecoder_Dev>()) return false; return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->GetConfigs( - instance->pp_instance(), prototype_config, matching_configs, - matching_configs_size, num_of_matching_configs)); + instance->pp_instance(), prototype_config, matching_configs, + matching_configs_size, num_of_matching_configs)); } -void VideoDecoder::AssignGLESBuffers( +void VideoDecoder_Dev::AssignGLESBuffers( const std::vector<PP_GLESBuffer_Dev>& buffers) { if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; @@ -60,7 +65,7 @@ void VideoDecoder::AssignGLESBuffers( pp_resource(), buffers.size(), &buffers[0]); } -void VideoDecoder::AssignSysmemBuffers( +void VideoDecoder_Dev::AssignSysmemBuffers( const std::vector<PP_SysmemBuffer_Dev>& buffers) { if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; @@ -68,7 +73,7 @@ void VideoDecoder::AssignSysmemBuffers( pp_resource(), buffers.size(), &buffers[0]); } -int32_t VideoDecoder::Decode( +int32_t VideoDecoder_Dev::Decode( const PP_VideoBitstreamBuffer_Dev& bitstream_buffer, CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) @@ -79,14 +84,14 @@ int32_t VideoDecoder::Decode( pp_resource(), &bitstream_buffer, callback.pp_completion_callback()); } -void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { +void VideoDecoder_Dev::ReusePictureBuffer(int32_t picture_buffer_id) { if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer( pp_resource(), picture_buffer_id); } -int32_t VideoDecoder::Flush(CompletionCallback callback) { +int32_t VideoDecoder_Dev::Flush(CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) return PP_ERROR_NOINTERFACE; if (!pp_resource()) @@ -95,7 +100,7 @@ int32_t VideoDecoder::Flush(CompletionCallback callback) { pp_resource(), callback.pp_completion_callback()); } -int32_t VideoDecoder::Abort(CompletionCallback callback) { +int32_t VideoDecoder_Dev::Abort(CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) return PP_ERROR_NOINTERFACE; if (!pp_resource()) diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h index e6558b1..326604f 100644 --- a/ppapi/cpp/dev/video_decoder_dev.h +++ b/ppapi/cpp/dev/video_decoder_dev.h @@ -14,59 +14,33 @@ namespace pp { +class Context3D_Dev; class Instance; // C++ wrapper for the Pepper Video Decoder interface. For more detailed -// documentation refer to PPB_VideoDecoder_Dev and PPP_VideoDecoder_Dev -// interfaces. +// documentation refer to the C interfaces. // // C++ version of the PPB_VideoDecoder_Dev interface. -class VideoDecoder : public Resource { +class VideoDecoder_Dev : public Resource { public: - // C++ version of PPP_VideoDecoder_Dev interface. - class Client { - public: - virtual ~Client(); - - // Callback to provide buffers for the decoded output pictures. - virtual void ProvidePictureBuffers( - uint32_t req_num_of_bufs, - struct PP_Size dimensions, - enum PP_PictureBufferType_Dev type); - - // Callback for decoder to delivered unneeded picture buffers back to the - // plugin. - virtual void DismissPictureBuffer(int32_t picture_buffer_id) = 0; - - // Callback to deliver decoded pictures ready to be displayed. - virtual void PictureReady(const PP_Picture_Dev& picture) = 0; - - // Callback to notify that decoder has decoded end of stream marker and has - // outputted all displayable pictures. - virtual void EndOfStream() = 0; - - // Callback to notify about decoding errors. - virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0; - }; - // Constructor for the video decoder. Calls the Create on the // PPB_VideoDecoder_Dev interface. // // Parameters: // |instance| is the pointer to the plug-in instance. - // |callback| will be called when decoder is initialized. - // |client| is the pointer to the client object. Ownership of the object is - // not transferred and it must outlive the lifetime of this class. - VideoDecoder(const Instance* instance, Client* client); - ~VideoDecoder(); + explicit VideoDecoder_Dev(const Instance& instance); + explicit VideoDecoder_Dev(PP_Resource resource); + virtual ~VideoDecoder_Dev(); // Initializates the video decoder with a requested configuration. // Calls Init() on PPB_VideoDecoder_Dev interface. // // Parameters: // |config| is the configuration on which the decoder should be initialized. + // |context| GL context in which video decoder decodes frames. // |callback| will be called when decoder is initialized. int32_t Initialize(const PP_VideoConfigElement* config, + const Context3D_Dev& context, CompletionCallback callback); // GetConfigs returns supported configurations that are subsets of given @@ -98,15 +72,6 @@ class VideoDecoder : public Resource { // Dispatches abortion request to the decoder to abort decoding as soon as // possible. |callback| will be called as soon as abortion has been finished. int32_t Abort(CompletionCallback callback); - - private: - // Pointer to the plugin's video decoder support interface for providing the - // buffers for video decoding. - Client* client_; - - // Suppress compiler-generated copy constructors. - VideoDecoder(const VideoDecoder&); - void operator=(const VideoDecoder&); }; } // namespace pp diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi index 74dc1f6..9933d7c 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -201,6 +201,8 @@ 'cpp/dev/surface_3d_dev.h', 'cpp/dev/url_util_dev.cc', 'cpp/dev/url_util_dev.h', + 'cpp/dev/video_decoder_client_dev.cc', + 'cpp/dev/video_decoder_client_dev.h', 'cpp/dev/video_decoder_dev.cc', 'cpp/dev/video_decoder_dev.h', 'cpp/dev/widget_client_dev.cc', diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc index 82f99c7..f4f2678 100644 --- a/ppapi/tests/test_video_decoder.cc +++ b/ppapi/tests/test_video_decoder.cc @@ -35,7 +35,7 @@ std::string TestVideoDecoder::TestCreateAndInitialize() { return "Create: error creating the decoder"; int32_t pp_error = video_decoder_interface_->Initialize( - decoder, NULL, PP_BlockUntilComplete()); + decoder, 0, NULL, PP_BlockUntilComplete()); pp::Module::Get()->core()->ReleaseResource(decoder); if (pp_error != PP_ERROR_BADARGUMENT) return "Initialize: error detecting null callback"; |