diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 18:55:06 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 18:55:06 +0000 |
commit | e0b3ea152c9450288319cd65329a8f664cac9107 (patch) | |
tree | 6472d42e6d5d847ea3bb8a42ee0d536d3673f998 /ppapi | |
parent | d2f777617b4c8873e6b72dcd3a0fd6809f7e4dbb (diff) | |
download | chromium_src-e0b3ea152c9450288319cd65329a8f664cac9107.zip chromium_src-e0b3ea152c9450288319cd65329a8f664cac9107.tar.gz chromium_src-e0b3ea152c9450288319cd65329a8f664cac9107.tar.bz2 |
Revert 88698 - 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
TBR=vrk@google.com
Review URL: http://codereview.chromium.org/7044115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88702 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, 79 insertions, 218 deletions
diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 8833818..4bf1cf3 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -201,6 +201,9 @@ 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 7f59df1..4ec65df 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_9 "PPB_VideoDecoder(Dev);0.9" -#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_9 +#define PPB_VIDEODECODER_DEV_INTERFACE_0_8 "PPB_VideoDecoder(Dev);0.8" +#define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_8 // Video decoder interface. // @@ -139,14 +139,11 @@ 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 e18146d..af5eaaf 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -5,11 +5,9 @@ #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.4" +#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.3" // PPP_VideoDecoder_Dev structure contains the function pointers that the // plugin MUST implement to provide services needed by the video decoder @@ -23,13 +21,11 @@ struct PPP_VideoDecoder_Dev { // Decoding will not proceed until buffers have been provided. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |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, @@ -39,11 +35,9 @@ struct PPP_VideoDecoder_Dev { // the plugin. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |picture_buffer| points to the picture buffer that is no longer needed. - void (*DismissPictureBuffer)(PP_Instance instance, - PP_Resource decoder, + void (*DismissPictureBuffer)(PP_Resource decoder, int32_t picture_buffer_id); // Callback function for decoder to deliver decoded pictures ready to be @@ -51,11 +45,9 @@ struct PPP_VideoDecoder_Dev { // decoder through ReusePictureBuffer function in PPB Video Decoder API. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |picture| is the picture that is ready. - void (*PictureReady)(PP_Instance instance, - PP_Resource decoder, + void (*PictureReady)(PP_Resource decoder, struct PP_Picture_Dev picture); // Callback function to tell the plugin that decoder has decoded end of stream @@ -63,9 +55,8 @@ struct PPP_VideoDecoder_Dev { // stream. // // Parameters: - // |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); + // |decoder| is pointer to the Pepper Video Decoder instance. + void (*EndOfStream)(PP_Resource decoder); // Error handler callback for decoder to deliver information about detected // errors to the plugin. @@ -73,12 +64,9 @@ struct PPP_VideoDecoder_Dev { // TODO(vmr): Fill out error result codes and corresponding actions. // // Parameters: - // |instance| the plugin instance to which the callback is responding. - // |decoder| is pointer to the Pepper Video Decoder resource. + // |decoder| is pointer to the Pepper Video Decoder instance. // |error| error is the enumeration specifying the error. - void (*NotifyError)(PP_Instance instance, - PP_Resource decoder, - enum PP_VideoDecodeError_Dev error); + void (*NotifyError)(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 deleted file mode 100644 index aa00c6f..0000000 --- a/ppapi/cpp/dev/video_decoder_client_dev.cc +++ /dev/null @@ -1,98 +0,0 @@ -// 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 deleted file mode 100644 index 776d54b..0000000 --- a/ppapi/cpp/dev/video_decoder_client_dev.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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 c8d6ff4..b1ebcfb 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -8,7 +8,6 @@ #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" @@ -23,41 +22,37 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() { } // namespace -VideoDecoder_Dev::VideoDecoder_Dev(const Instance& instance) { +VideoDecoder::VideoDecoder(const Instance* instance, Client* client) + : client_(client) { if (!has_interface<PPB_VideoDecoder_Dev>()) return; PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create( - instance.pp_instance())); + instance->pp_instance())); } -VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) { -} - -VideoDecoder_Dev::~VideoDecoder_Dev() {} +VideoDecoder::~VideoDecoder() {} -int32_t VideoDecoder_Dev::Initialize(const PP_VideoConfigElement* config, - const Context3D_Dev& context, - CompletionCallback callback) { +int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config, + CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) return PP_ERROR_NOINTERFACE; return get_interface<PPB_VideoDecoder_Dev>()->Initialize( - pp_resource(), context.pp_resource(), config, - callback.pp_completion_callback()); + pp_resource(), config, callback.pp_completion_callback()); } -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) { +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) { 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_Dev::AssignGLESBuffers( +void VideoDecoder::AssignGLESBuffers( const std::vector<PP_GLESBuffer_Dev>& buffers) { if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; @@ -65,7 +60,7 @@ void VideoDecoder_Dev::AssignGLESBuffers( pp_resource(), buffers.size(), &buffers[0]); } -void VideoDecoder_Dev::AssignSysmemBuffers( +void VideoDecoder::AssignSysmemBuffers( const std::vector<PP_SysmemBuffer_Dev>& buffers) { if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) return; @@ -73,7 +68,7 @@ void VideoDecoder_Dev::AssignSysmemBuffers( pp_resource(), buffers.size(), &buffers[0]); } -int32_t VideoDecoder_Dev::Decode( +int32_t VideoDecoder::Decode( const PP_VideoBitstreamBuffer_Dev& bitstream_buffer, CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) @@ -84,14 +79,14 @@ int32_t VideoDecoder_Dev::Decode( pp_resource(), &bitstream_buffer, callback.pp_completion_callback()); } -void VideoDecoder_Dev::ReusePictureBuffer(int32_t picture_buffer_id) { +void VideoDecoder::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_Dev::Flush(CompletionCallback callback) { +int32_t VideoDecoder::Flush(CompletionCallback callback) { if (!has_interface<PPB_VideoDecoder_Dev>()) return PP_ERROR_NOINTERFACE; if (!pp_resource()) @@ -100,7 +95,7 @@ int32_t VideoDecoder_Dev::Flush(CompletionCallback callback) { pp_resource(), callback.pp_completion_callback()); } -int32_t VideoDecoder_Dev::Abort(CompletionCallback callback) { +int32_t VideoDecoder::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 326604f..e6558b1 100644 --- a/ppapi/cpp/dev/video_decoder_dev.h +++ b/ppapi/cpp/dev/video_decoder_dev.h @@ -14,33 +14,59 @@ namespace pp { -class Context3D_Dev; class Instance; // C++ wrapper for the Pepper Video Decoder interface. For more detailed -// documentation refer to the C interfaces. +// documentation refer to PPB_VideoDecoder_Dev and PPP_VideoDecoder_Dev +// interfaces. // // C++ version of the PPB_VideoDecoder_Dev interface. -class VideoDecoder_Dev : public Resource { +class VideoDecoder : 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. - explicit VideoDecoder_Dev(const Instance& instance); - explicit VideoDecoder_Dev(PP_Resource resource); - virtual ~VideoDecoder_Dev(); + // |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(); // 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 @@ -72,6 +98,15 @@ class VideoDecoder_Dev : 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 9933d7c..74dc1f6 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -201,8 +201,6 @@ '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 f4f2678..82f99c7 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, 0, NULL, PP_BlockUntilComplete()); + decoder, NULL, PP_BlockUntilComplete()); pp::Module::Get()->core()->ReleaseResource(decoder); if (pp_error != PP_ERROR_BADARGUMENT) return "Initialize: error detecting null callback"; |