diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 20:15:28 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 20:15:28 +0000 |
commit | f4edc3f0c16c2ef77fbce071d5a7fcf3a00a77c6 (patch) | |
tree | 9a46556854e698acf4d42297e398ca898b1436fa /ppapi | |
parent | 6201e21a3f78df752d25f8ac4dd8a34e0c8e5139 (diff) | |
download | chromium_src-f4edc3f0c16c2ef77fbce071d5a7fcf3a00a77c6.zip chromium_src-f4edc3f0c16c2ef77fbce071d5a7fcf3a00a77c6.tar.gz chromium_src-f4edc3f0c16c2ef77fbce071d5a7fcf3a00a77c6.tar.bz2 |
Re-added decoder id to PPP_VideoDecoder_Dev methods
This supports having multiple decoders per PP_Instance, which was removed as
part of 92704.
BUG=none
TEST=gles2 works, trybots
Review URL: http://codereview.chromium.org/7489012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/dev/ppp_video_decoder_dev.h | 29 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_client_dev.cc | 23 | ||||
-rw-r--r-- | ppapi/cpp/dev/video_decoder_client_dev.h | 17 | ||||
-rw-r--r-- | ppapi/examples/gles2/gles2.cc | 32 |
4 files changed, 64 insertions, 37 deletions
diff --git a/ppapi/c/dev/ppp_video_decoder_dev.h b/ppapi/c/dev/ppp_video_decoder_dev.h index e1bb657..b924fd4 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -9,7 +9,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/dev/pp_video_dev.h" -#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.7" +#define PPP_VIDEODECODER_DEV_INTERFACE "PPP_VideoDecoder(Dev);0.8" // PPP_VideoDecoder_Dev structure contains the function pointers that the // plugin MUST implement to provide services needed by the video decoder @@ -25,21 +25,25 @@ struct PPP_VideoDecoder_Dev { // // Parameters: // |instance| the plugin instance to which the callback is responding. + // |decoder| the PPB_VideoDecoder_Dev 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, - uint32_t req_num_of_bufs, - struct PP_Size dimensions); + void (*ProvidePictureBuffers)(PP_Instance instance, + PP_Resource decoder, + uint32_t req_num_of_bufs, + struct PP_Size dimensions); // Callback function for decoder to deliver unneeded picture buffers back to // the plugin. // // Parameters: // |instance| the plugin instance to which the callback is responding. + // |decoder| the PPB_VideoDecoder_Dev resource. // |picture_buffer| points to the picture buffer that is no longer needed. - void (*DismissPictureBuffer)(PP_Instance instance, int32_t picture_buffer_id); + void (*DismissPictureBuffer)(PP_Instance instance, + PP_Resource decoder, + int32_t picture_buffer_id); // Callback function for decoder to deliver decoded pictures ready to be // displayed. Decoder expects the plugin to return the buffer back to the @@ -47,8 +51,11 @@ struct PPP_VideoDecoder_Dev { // // Parameters: // |instance| the plugin instance to which the callback is responding. + // |decoder| the PPB_VideoDecoder_Dev resource. // |picture| is the picture that is ready. - void (*PictureReady)(PP_Instance instance, struct PP_Picture_Dev picture); + 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 // marker and output all the pictures that should be displayed from the @@ -56,15 +63,19 @@ struct PPP_VideoDecoder_Dev { // // Parameters: // |instance| the plugin instance to which the callback is responding. - void (*EndOfStream)(PP_Instance instance); + // |decoder| the PPB_VideoDecoder_Dev resource. + void (*EndOfStream)(PP_Instance instance, PP_Resource decoder); // Error handler callback for decoder to deliver information about detected // errors to the plugin. // // Parameters: // |instance| the plugin instance to which the callback is responding. + // |decoder| the PPB_VideoDecoder_Dev resource. // |error| error is the enumeration specifying the error. - void (*NotifyError)(PP_Instance instance, 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 index 90596ba..d70cff5 100644 --- a/ppapi/cpp/dev/video_decoder_client_dev.cc +++ b/ppapi/cpp/dev/video_decoder_client_dev.cc @@ -18,6 +18,7 @@ const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; // Callback to provide buffers for the decoded output pictures. void ProvidePictureBuffers(PP_Instance instance, + PP_Resource decoder, uint32_t req_num_of_bufs, struct PP_Size dimensions) { void* object = pp::Instance::GetPerInstanceObject( @@ -25,41 +26,47 @@ void ProvidePictureBuffers(PP_Instance instance, if (!object) return; static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( - req_num_of_bufs, dimensions); + decoder, req_num_of_bufs, dimensions); } void DismissPictureBuffer(PP_Instance instance, + PP_Resource decoder, int32_t picture_buffer_id) { void* object = pp::Instance::GetPerInstanceObject( instance, kPPPVideoDecoderInterface); if (!object) return; static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( - picture_buffer_id); + decoder, picture_buffer_id); } -void PictureReady(PP_Instance instance, PP_Picture_Dev picture) { +void PictureReady(PP_Instance instance, + PP_Resource decoder, + PP_Picture_Dev picture) { void* object = pp::Instance::GetPerInstanceObject( instance, kPPPVideoDecoderInterface); if (!object) return; - static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(picture); + static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(decoder, picture); } -void EndOfStream(PP_Instance instance) { +void EndOfStream(PP_Instance instance, + PP_Resource decoder) { void* object = pp::Instance::GetPerInstanceObject( instance, kPPPVideoDecoderInterface); if (!object) return; - static_cast<VideoDecoderClient_Dev*>(object)->EndOfStream(); + static_cast<VideoDecoderClient_Dev*>(object)->EndOfStream(decoder); } -void NotifyError(PP_Instance instance, PP_VideoDecodeError_Dev error) { +void NotifyError(PP_Instance instance, + PP_Resource decoder, + PP_VideoDecodeError_Dev error) { void* object = pp::Instance::GetPerInstanceObject( instance, kPPPVideoDecoderInterface); if (!object) return; - static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(error); + static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(decoder, error); } static PPP_VideoDecoder_Dev videodecoder_interface = { diff --git a/ppapi/cpp/dev/video_decoder_client_dev.h b/ppapi/cpp/dev/video_decoder_client_dev.h index 3d1a96b..5249fed 100644 --- a/ppapi/cpp/dev/video_decoder_client_dev.h +++ b/ppapi/cpp/dev/video_decoder_client_dev.h @@ -23,23 +23,26 @@ class VideoDecoderClient_Dev { virtual ~VideoDecoderClient_Dev(); // Callback to provide buffers for the decoded output pictures. - virtual void ProvidePictureBuffers( - uint32_t req_num_of_bufs, - struct PP_Size dimensions) = 0; + virtual void ProvidePictureBuffers(PP_Resource decoder, + uint32_t req_num_of_bufs, + struct PP_Size dimensions) = 0; // Callback for decoder to deliver unneeded picture buffers back to the // plugin. - virtual void DismissPictureBuffer(int32_t picture_buffer_id) = 0; + virtual void DismissPictureBuffer(PP_Resource decoder, + int32_t picture_buffer_id) = 0; // Callback to deliver decoded pictures ready to be displayed. - virtual void PictureReady(const PP_Picture_Dev& picture) = 0; + virtual void PictureReady(PP_Resource 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() = 0; + virtual void EndOfStream(PP_Resource decoder) = 0; // Callback to notify about decoding errors. - virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0; + virtual void NotifyError(PP_Resource decoder, + PP_VideoDecodeError_Dev error) = 0; private: Instance* associated_instance_; diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc index fc866dd..24a9727 100644 --- a/ppapi/examples/gles2/gles2.cc +++ b/ppapi/examples/gles2/gles2.cc @@ -40,7 +40,8 @@ namespace { -class GLES2DemoInstance : public pp::Instance, public pp::Graphics3DClient_Dev, +class GLES2DemoInstance : public pp::Instance, + public pp::Graphics3DClient_Dev, public pp::VideoDecoderClient_Dev { public: GLES2DemoInstance(PP_Instance instance, pp::Module* module); @@ -60,12 +61,14 @@ class GLES2DemoInstance : public pp::Instance, public pp::Graphics3DClient_Dev, } // pp::VideoDecoderClient_Dev implementation. - virtual void ProvidePictureBuffers( - uint32_t req_num_of_bufs, PP_Size dimensions); - virtual void DismissPictureBuffer(int32_t picture_buffer_id); - virtual void PictureReady(const PP_Picture_Dev& picture); - virtual void EndOfStream(); - virtual void NotifyError(PP_VideoDecodeError_Dev error); + virtual void ProvidePictureBuffers(PP_Resource decoder, + uint32_t req_num_of_bufs, + PP_Size dimensions); + virtual void DismissPictureBuffer(PP_Resource decoder, + int32_t picture_buffer_id); + virtual void PictureReady(PP_Resource decoder, const PP_Picture_Dev& picture); + virtual void EndOfStream(PP_Resource decoder); + virtual void NotifyError(PP_Resource decoder, PP_VideoDecodeError_Dev error); private: enum { kNumConcurrentDecodes = 7 }; @@ -278,7 +281,7 @@ void GLES2DemoInstance::DecodeNextNALU() { } void GLES2DemoInstance::ProvidePictureBuffers( - uint32_t req_num_of_bufs, PP_Size dimensions) { + PP_Resource /* decoder */, uint32_t req_num_of_bufs, PP_Size dimensions) { std::vector<PP_PictureBuffer_Dev> buffers; for (uint32_t i = 0; i < req_num_of_bufs; i++) { PP_PictureBuffer_Dev buffer; @@ -291,14 +294,16 @@ void GLES2DemoInstance::ProvidePictureBuffers( video_decoder_->AssignPictureBuffers(buffers); } -void GLES2DemoInstance::DismissPictureBuffer(int32_t picture_buffer_id) { +void GLES2DemoInstance::DismissPictureBuffer(PP_Resource /* decoder */, + int32_t picture_buffer_id) { PictureBufferMap::iterator it = buffers_by_id_.find(picture_buffer_id); assert(it != buffers_by_id_.end()); DeleteTexture(it->second.texture_id); buffers_by_id_.erase(it); } -void GLES2DemoInstance::PictureReady(const PP_Picture_Dev& picture) { +void GLES2DemoInstance::PictureReady(PP_Resource /* decoder */, + const PP_Picture_Dev& picture) { if (first_frame_delivered_ticks_ == -1) assert((first_frame_delivered_ticks_ = core_if_->GetTimeTicks()) != -1); if (is_painting_) { @@ -311,10 +316,11 @@ void GLES2DemoInstance::PictureReady(const PP_Picture_Dev& picture) { Render(it->second); } -void GLES2DemoInstance::EndOfStream() { +void GLES2DemoInstance::EndOfStream(PP_Resource /* decoder */) { } -void GLES2DemoInstance::NotifyError(PP_VideoDecodeError_Dev error) { +void GLES2DemoInstance::NotifyError(PP_Resource /* decoder */, + PP_VideoDecodeError_Dev error) { LogError(this).s() << "Received error: " << error; assert(!"Unexpected error; see stderr for details"); } @@ -391,7 +397,7 @@ void GLES2DemoInstance::PaintFinished(int32_t result, int picture_buffer_id) { while (!pictures_pending_paint_.empty() && !is_painting_) { PP_Picture_Dev picture = pictures_pending_paint_.front(); pictures_pending_paint_.pop_front(); - PictureReady(picture); + PictureReady(0 /* ignored */, picture); } } |