Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / cpp / dev / video_decoder_client_dev.cc
blob10c2619d9c6883c5d231e4ce55751dd8159b90a7
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"
14 namespace pp {
16 namespace {
18 const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE;
20 // Callback to provide buffers for the decoded output pictures.
21 void ProvidePictureBuffers(PP_Instance instance,
22 PP_Resource decoder,
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);
28 if (!object)
29 return;
30 static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers(
31 decoder, req_num_of_bufs, *dimensions, texture_target);
34 void DismissPictureBuffer(PP_Instance instance,
35 PP_Resource decoder,
36 int32_t picture_buffer_id) {
37 void* object = Instance::GetPerInstanceObject(instance,
38 kPPPVideoDecoderInterface);
39 if (!object)
40 return;
41 static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer(
42 decoder, picture_buffer_id);
45 void PictureReady(PP_Instance instance,
46 PP_Resource decoder,
47 const PP_Picture_Dev* picture) {
48 void* object = Instance::GetPerInstanceObject(instance,
49 kPPPVideoDecoderInterface);
50 if (!object)
51 return;
52 static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(decoder, *picture);
55 void NotifyError(PP_Instance instance,
56 PP_Resource decoder,
57 PP_VideoDecodeError_Dev error) {
58 void* object = Instance::GetPerInstanceObject(instance,
59 kPPPVideoDecoderInterface);
60 if (!object)
61 return;
62 static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(decoder, error);
65 static PPP_VideoDecoder_Dev videodecoder_interface = {
66 &ProvidePictureBuffers,
67 &DismissPictureBuffer,
68 &PictureReady,
69 &NotifyError,
72 } // namespace
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);
86 } // namespace pp