| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014 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. |
| 4 |
| 5 #include "ppapi/cpp/media_codec_video_decoder.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_media_codec_video_decoder.h" |
| 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/instance_handle.h" |
| 11 #include "ppapi/cpp/module.h" |
| 12 #include "ppapi/cpp/module_impl.h" |
| 13 |
| 14 namespace pp { |
| 15 |
| 16 namespace { |
| 17 |
| 18 template <> |
| 19 const char* interface_name<PPB_MediaCodecVideoDecoder_0_1>() { |
| 20 return PPB_MEDIACODECVIDEODECODER_INTERFACE_0_1; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 25 MediaCodecVideoDecoder::MediaCodecVideoDecoder() { |
| 26 } |
| 27 |
| 28 MediaCodecVideoDecoder::MediaCodecVideoDecoder(const InstanceHandle& instance) { |
| 29 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 30 PassRefFromConstructor( |
| 31 get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Create( |
| 32 instance.pp_instance())); |
| 33 } |
| 34 } |
| 35 |
| 36 MediaCodecVideoDecoder::MediaCodecVideoDecoder( |
| 37 const MediaCodecVideoDecoder& other) |
| 38 : Resource(other) { |
| 39 } |
| 40 |
| 41 int32_t MediaCodecVideoDecoder::Initialize(const Graphics3D& context, |
| 42 PP_MediaCodec_VideoProfile profile, |
| 43 bool allow_software_fallback, |
| 44 const CompletionCallback& cc) { |
| 45 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 46 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Initialize( |
| 47 pp_resource(), |
| 48 context.pp_resource(), |
| 49 profile, |
| 50 PP_FromBool(allow_software_fallback), |
| 51 cc.pp_completion_callback()); |
| 52 } |
| 53 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 54 } |
| 55 |
| 56 int32_t MediaCodecVideoDecoder::Decode(uint32_t decode_id, |
| 57 uint32_t size, |
| 58 const void* buffer, |
| 59 const CompletionCallback& cc) { |
| 60 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 61 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Decode( |
| 62 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); |
| 63 } |
| 64 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 65 } |
| 66 |
| 67 int32_t MediaCodecVideoDecoder::GetPicture( |
| 68 const CompletionCallbackWithOutput<PP_MediaCodec_Picture>& cc) { |
| 69 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 70 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->GetPicture( |
| 71 pp_resource(), cc.output(), cc.pp_completion_callback()); |
| 72 } |
| 73 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 74 } |
| 75 |
| 76 void MediaCodecVideoDecoder::RecyclePicture( |
| 77 const PP_MediaCodec_Picture& picture) { |
| 78 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 79 get_interface<PPB_MediaCodecVideoDecoder_0_1>()->RecyclePicture( |
| 80 pp_resource(), &picture); |
| 81 } |
| 82 } |
| 83 |
| 84 int32_t MediaCodecVideoDecoder::Flush(const CompletionCallback& cc) { |
| 85 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 86 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Flush( |
| 87 pp_resource(), cc.pp_completion_callback()); |
| 88 } |
| 89 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 90 } |
| 91 |
| 92 int32_t MediaCodecVideoDecoder::Reset(const CompletionCallback& cc) { |
| 93 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 94 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Reset( |
| 95 pp_resource(), cc.pp_completion_callback()); |
| 96 } |
| 97 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 98 } |
| 99 |
| 100 } // namespace pp |
| OLD | NEW |