| 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 MediaCodecVideoDecoder::MediaCodecVideoDecoder(const InstanceHandle& instance) { |
| 28 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 29 PassRefFromConstructor( |
| 30 get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Create( |
| 31 instance.pp_instance())); |
| 32 } |
| 33 } |
| 34 |
| 35 MediaCodecVideoDecoder::MediaCodecVideoDecoder( |
| 36 const MediaCodecVideoDecoder& other) |
| 37 : Resource(other) {} |
| 38 |
| 39 int32_t MediaCodecVideoDecoder::Initialize( |
| 40 const Graphics3D& context, |
| 41 PP_MediaCodec_Profile profile, |
| 42 const CompletionCallback& cc) { |
| 43 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 44 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Initialize( |
| 45 pp_resource(), |
| 46 context.pp_resource(), |
| 47 profile, |
| 48 cc.pp_completion_callback()); |
| 49 } |
| 50 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 51 } |
| 52 |
| 53 int32_t MediaCodecVideoDecoder::Decode( |
| 54 uint32_t picture_id, |
| 55 uint32_t size, |
| 56 const void* buffer, |
| 57 const CompletionCallback& cc) { |
| 58 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 59 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Decode( |
| 60 pp_resource(), |
| 61 picture_id, |
| 62 size, |
| 63 buffer, |
| 64 cc.pp_completion_callback()); |
| 65 } |
| 66 return PP_ERROR_NOINTERFACE; |
| 67 } |
| 68 |
| 69 int32_t MediaCodecVideoDecoder::GetPictureBuffer( |
| 70 const CompletionCallbackWithOutput<PP_MediaCodec_PictureBuffer>& cc) { |
| 71 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 72 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->GetPictureBuffer( |
| 73 pp_resource(), |
| 74 cc.output(), |
| 75 cc.pp_completion_callback()); |
| 76 } |
| 77 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 78 } |
| 79 |
| 80 void MediaCodecVideoDecoder::RecyclePictureBuffer( |
| 81 const PP_MediaCodec_PictureBuffer& picture_buffer) { |
| 82 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 83 get_interface<PPB_MediaCodecVideoDecoder_0_1>()->RecyclePictureBuffer( |
| 84 pp_resource(), &picture_buffer); |
| 85 } |
| 86 } |
| 87 |
| 88 int32_t MediaCodecVideoDecoder::Flush(const CompletionCallback& cc) { |
| 89 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 90 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Flush( |
| 91 pp_resource(), cc.pp_completion_callback()); |
| 92 } |
| 93 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 94 } |
| 95 |
| 96 int32_t MediaCodecVideoDecoder::Reset(const CompletionCallback& cc) { |
| 97 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 98 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Reset( |
| 99 pp_resource(), cc.pp_completion_callback()); |
| 100 } |
| 101 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 102 } |
| 103 |
| 104 } // namespace pp |
| OLD | NEW |