1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/cpp/dev/video_decoder_client_dev.h"
7 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
8 #include "ppapi/cpp/dev/video_decoder_dev.h"
9 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h"
18 const char kPPPVideoDecoderInterface
[] = PPP_VIDEODECODER_DEV_INTERFACE
;
20 // Callback to provide buffers for the decoded output pictures.
21 void ProvidePictureBuffers(PP_Instance instance
,
23 uint32_t req_num_of_bufs
,
24 const PP_Size
* dimensions
,
25 uint32_t texture_target
) {
26 void* object
= Instance::GetPerInstanceObject(instance
,
27 kPPPVideoDecoderInterface
);
30 static_cast<VideoDecoderClient_Dev
*>(object
)->ProvidePictureBuffers(
31 decoder
, req_num_of_bufs
, *dimensions
, texture_target
);
34 void DismissPictureBuffer(PP_Instance instance
,
36 int32_t picture_buffer_id
) {
37 void* object
= Instance::GetPerInstanceObject(instance
,
38 kPPPVideoDecoderInterface
);
41 static_cast<VideoDecoderClient_Dev
*>(object
)->DismissPictureBuffer(
42 decoder
, picture_buffer_id
);
45 void PictureReady(PP_Instance instance
,
47 const PP_Picture_Dev
* picture
) {
48 void* object
= Instance::GetPerInstanceObject(instance
,
49 kPPPVideoDecoderInterface
);
52 static_cast<VideoDecoderClient_Dev
*>(object
)->PictureReady(decoder
, *picture
);
55 void NotifyError(PP_Instance instance
,
57 PP_VideoDecodeError_Dev error
) {
58 void* object
= Instance::GetPerInstanceObject(instance
,
59 kPPPVideoDecoderInterface
);
62 static_cast<VideoDecoderClient_Dev
*>(object
)->NotifyError(decoder
, error
);
65 static PPP_VideoDecoder_Dev videodecoder_interface
= {
66 &ProvidePictureBuffers
,
67 &DismissPictureBuffer
,
74 VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance
* instance
)
75 : associated_instance_(instance
) {
76 Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface
,
77 &videodecoder_interface
);
78 instance
->AddPerInstanceObject(kPPPVideoDecoderInterface
, this);
81 VideoDecoderClient_Dev::~VideoDecoderClient_Dev() {
82 Instance::RemovePerInstanceObject(associated_instance_
,
83 kPPPVideoDecoderInterface
, this);