| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; | 17 const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; |
| 18 | 18 |
| 19 // Callback to provide buffers for the decoded output pictures. | 19 // Callback to provide buffers for the decoded output pictures. |
| 20 void ProvidePictureBuffers(PP_Instance instance, | 20 void ProvidePictureBuffers(PP_Instance instance, |
| 21 PP_Resource decoder_id, | |
| 22 uint32_t req_num_of_bufs, | 21 uint32_t req_num_of_bufs, |
| 23 struct PP_Size dimensions, | 22 struct PP_Size dimensions, |
| 24 enum PP_PictureBufferType_Dev type) { | 23 enum PP_PictureBufferType_Dev type) { |
| 25 void* object = pp::Instance::GetPerInstanceObject( | 24 void* object = pp::Instance::GetPerInstanceObject( |
| 26 instance, kPPPVideoDecoderInterface); | 25 instance, kPPPVideoDecoderInterface); |
| 27 if (!object) | 26 if (!object) |
| 28 return; | 27 return; |
| 29 static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( | 28 static_cast<VideoDecoderClient_Dev*>(object)->ProvidePictureBuffers( |
| 30 VideoDecoder_Dev(decoder_id), req_num_of_bufs, dimensions, type); | 29 req_num_of_bufs, dimensions, type); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void DismissPictureBuffer(PP_Instance instance, | 32 void DismissPictureBuffer(PP_Instance instance, |
| 34 PP_Resource decoder_id, | |
| 35 int32_t picture_buffer_id) { | 33 int32_t picture_buffer_id) { |
| 36 void* object = pp::Instance::GetPerInstanceObject( | 34 void* object = pp::Instance::GetPerInstanceObject( |
| 37 instance, kPPPVideoDecoderInterface); | 35 instance, kPPPVideoDecoderInterface); |
| 38 if (!object) | 36 if (!object) |
| 39 return; | 37 return; |
| 40 static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( | 38 static_cast<VideoDecoderClient_Dev*>(object)->DismissPictureBuffer( |
| 41 VideoDecoder_Dev(decoder_id), picture_buffer_id); | 39 picture_buffer_id); |
| 42 } | 40 } |
| 43 | 41 |
| 44 void PictureReady(PP_Instance instance, | 42 void PictureReady(PP_Instance instance, PP_Picture_Dev picture) { |
| 45 PP_Resource decoder_id, | |
| 46 PP_Picture_Dev picture) { | |
| 47 void* object = pp::Instance::GetPerInstanceObject( | 43 void* object = pp::Instance::GetPerInstanceObject( |
| 48 instance, kPPPVideoDecoderInterface); | 44 instance, kPPPVideoDecoderInterface); |
| 49 if (!object) | 45 if (!object) |
| 50 return; | 46 return; |
| 51 static_cast<VideoDecoderClient_Dev*>(object)->PictureReady( | 47 static_cast<VideoDecoderClient_Dev*>(object)->PictureReady(picture); |
| 52 VideoDecoder_Dev(decoder_id), picture); | |
| 53 } | 48 } |
| 54 | 49 |
| 55 void EndOfStream(PP_Instance instance, PP_Resource decoder_id) { | 50 void EndOfStream(PP_Instance instance) { |
| 56 void* object = pp::Instance::GetPerInstanceObject( | 51 void* object = pp::Instance::GetPerInstanceObject( |
| 57 instance, kPPPVideoDecoderInterface); | 52 instance, kPPPVideoDecoderInterface); |
| 58 if (!object) | 53 if (!object) |
| 59 return; | 54 return; |
| 60 static_cast<VideoDecoderClient_Dev*>(object)->EndOfStream( | 55 static_cast<VideoDecoderClient_Dev*>(object)->EndOfStream(); |
| 61 VideoDecoder_Dev(decoder_id)); | |
| 62 } | 56 } |
| 63 | 57 |
| 64 void NotifyError(PP_Instance instance, | 58 void NotifyError(PP_Instance instance, PP_VideoDecodeError_Dev error) { |
| 65 PP_Resource decoder_id, | |
| 66 PP_VideoDecodeError_Dev error) { | |
| 67 void* object = pp::Instance::GetPerInstanceObject( | 59 void* object = pp::Instance::GetPerInstanceObject( |
| 68 instance, kPPPVideoDecoderInterface); | 60 instance, kPPPVideoDecoderInterface); |
| 69 if (!object) | 61 if (!object) |
| 70 return; | 62 return; |
| 71 static_cast<VideoDecoderClient_Dev*>(object)->NotifyError( | 63 static_cast<VideoDecoderClient_Dev*>(object)->NotifyError(error); |
| 72 VideoDecoder_Dev(decoder_id), error); | |
| 73 } | 64 } |
| 74 | 65 |
| 75 static PPP_VideoDecoder_Dev videodecoder_interface = { | 66 static PPP_VideoDecoder_Dev videodecoder_interface = { |
| 76 &ProvidePictureBuffers, | 67 &ProvidePictureBuffers, |
| 77 &DismissPictureBuffer, | 68 &DismissPictureBuffer, |
| 78 &PictureReady, | 69 &PictureReady, |
| 79 &EndOfStream, | 70 &EndOfStream, |
| 80 &NotifyError, | 71 &NotifyError, |
| 81 }; | 72 }; |
| 82 | 73 |
| 83 } // namespace | 74 } // namespace |
| 84 | 75 |
| 85 VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance* instance) | 76 VideoDecoderClient_Dev::VideoDecoderClient_Dev(Instance* instance) |
| 86 : associated_instance_(instance) { | 77 : associated_instance_(instance) { |
| 87 pp::Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, | 78 pp::Module::Get()->AddPluginInterface(kPPPVideoDecoderInterface, |
| 88 &videodecoder_interface); | 79 &videodecoder_interface); |
| 89 associated_instance_->AddPerInstanceObject( | 80 associated_instance_->AddPerInstanceObject( |
| 90 kPPPVideoDecoderInterface, this); | 81 kPPPVideoDecoderInterface, this); |
| 91 } | 82 } |
| 92 | 83 |
| 93 VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { | 84 VideoDecoderClient_Dev::~VideoDecoderClient_Dev() { |
| 94 associated_instance_->RemovePerInstanceObject( | 85 associated_instance_->RemovePerInstanceObject( |
| 95 kPPPVideoDecoderInterface, this); | 86 kPPPVideoDecoderInterface, this); |
| 96 } | 87 } |
| 97 | 88 |
| 98 } // namespace pp | 89 } // namespace pp |
| OLD | NEW |