OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/cpp/dev/video_decoder_client_dev.h" | 5 #include "ppapi/cpp/dev/video_decoder_client_dev.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppp_video_decoder_dev.h" | 7 #include "ppapi/c/dev/ppp_video_decoder_dev.h" |
8 #include "ppapi/cpp/dev/video_decoder_dev.h" | 8 #include "ppapi/cpp/dev/video_decoder_dev.h" |
9 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/instance_handle.h" |
10 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
11 #include "ppapi/cpp/module_impl.h" | 12 #include "ppapi/cpp/module_impl.h" |
12 | 13 |
13 namespace pp { | 14 namespace pp { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; | 18 const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; |
18 | 19 |
19 // Callback to provide buffers for the decoded output pictures. | 20 // Callback to provide buffers for the decoded output pictures. |
20 void ProvidePictureBuffers(PP_Instance instance, | 21 void ProvidePictureBuffers(PP_Instance instance, |
21 PP_Resource decoder, | 22 PP_Resource decoder, |
22 uint32_t req_num_of_bufs, | 23 uint32_t req_num_of_bufs, |
23 const PP_Size* dimensions) { | 24 const PP_Size* dimensions) { |
24 void* object = pp::Instance::GetPerInstanceObject( | 25 void* object = Instance::GetPerInstanceObject(instance, |
25 instance, kPPPVideoDecoderInterface); | 26 kPPPVideoDecoderInterface); |
26 if (!object) | 27 if (!object) |
27 return; | 28 return; |
28 static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( | 29 static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( |
29 decoder, req_num_of_bufs, *dimensions); | 30 decoder, req_num_of_bufs, *dimensions); |
30 } | 31 } |
31 | 32 |
32 void DismissPictureBuffer(PP_Instance instance, | 33 void DismissPictureBuffer(PP_Instance instance, |
33 PP_Resource decoder, | 34 PP_Resource decoder, |
34 int32_t picture_buffer_id) { | 35 int32_t picture_buffer_id) { |
35 void* object = pp::Instance::GetPerInstanceObject( | 36 void* object = Instance::GetPerInstanceObject(instance, |
36 instance, kPPPVideoDecoderInterface); | 37 kPPPVideoDecoderInterface); |
37 if (!object) | 38 if (!object) |
38 return; | 39 return; |
39 static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( | 40 static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( |
40 decoder, picture_buffer_id); | 41 decoder, picture_buffer_id); |
41 } | 42 } |
42 | 43 |
43 void PictureReady(PP_Instance instance, | 44 void PictureReady(PP_Instance instance, |
44 PP_Resource decoder, | 45 PP_Resource decoder, |
45 const PP_Picture_Dev* picture) { | 46 const PP_Picture_Dev* picture) { |
46 void* object = pp::Instance::GetPerInstanceObject( | 47 void* object = Instance::GetPerInstanceObject(instance, |
47 instance, kPPPVideoDecoderInterface); | 48 kPPPVideoDecoderInterface); |
48 if (!object) | 49 if (!object) |
49 return; | 50 return; |
50 static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(decoder, *picture); | 51 static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(decoder, *picture); |
51 } | 52 } |
52 | 53 |
53 void NotifyError(PP_Instance instance, | 54 void NotifyError(PP_Instance instance, |
54 PP_Resource decoder, | 55 PP_Resource decoder, |
55 PP_VideoDecodeError_Dev error) { | 56 PP_VideoDecodeError_Dev error) { |
56 void* object = pp::Instance::GetPerInstanceObject( | 57 void* object = Instance::GetPerInstanceObject(instance, |
57 instance, kPPPVideoDecoderInterface); | 58 kPPPVideoDecoderInterface); |
58 if (!object) | 59 if (!object) |
59 return; | 60 return; |
60 static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(decoder, error); | 61 static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(decoder, error); |
61 } | 62 } |
62 | 63 |
63 static PPP_VideoDecoder_Dev videodecoder_interface = { | 64 static PPP_VideoDecoder_Dev videodecoder_interface = { |
64 &ProvidePictureBuffers, | 65 &ProvidePictureBuffers, |
65 &DismissPictureBuffer, | 66 &DismissPictureBuffer, |
66 &PictureReady, | 67 &PictureReady, |
67 &NotifyError, | 68 &NotifyError, |
68 }; | 69 }; |
69 | 70 |
70 } // namespace | 71 } // namespace |
71 | 72 |
72 VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance* instance) | 73 VideoDecoderClient_Dev::VideoDecoderClient_Dev(const InstanceHandle& instance) |
73 : associated_instance_(instance) { | 74 : associated_instance_(instance) { |
74 pp::Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, | 75 Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, |
75 &videodecoder_interface); | 76 &videodecoder_interface); |
76 associated_instance_->AddPerInstanceObject( | 77 Instance::AddPerInstanceObject(instance, kPPPVideoDecoderInterface, this); |
77 kPPPVideoDecoderInterface, this); | |
78 } | 78 } |
79 | 79 |
80 VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { | 80 VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { |
81 associated_instance_->RemovePerInstanceObject( | 81 Instance::RemovePerInstanceObject(associated_instance_, |
82 kPPPVideoDecoderInterface, this); | 82 kPPPVideoDecoderInterface, this); |
83 } | 83 } |
84 | 84 |
85 } // namespace pp | 85 } // namespace pp |
OLD | NEW |