| 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 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::GetBitstreamBuffer( |
| 54 uint32_t size, |
| 55 const CompletionCallbackWithOutput<PP_MediaCodec_BitstreamBuffer>& cc) { |
| 56 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 57 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->GetBitstreamBuffer( |
| 58 pp_resource(), |
| 59 size, |
| 60 cc.output(), |
| 61 cc.pp_completion_callback()); |
| 62 } |
| 63 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 64 } |
| 65 |
| 66 int32_t MediaCodecVideoDecoder::Decode( |
| 67 const PP_MediaCodec_BitstreamBuffer& bitstream_buffer, |
| 68 const CompletionCallback& cc) { |
| 69 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 70 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Decode( |
| 71 pp_resource(), |
| 72 &bitstream_buffer, |
| 73 cc.pp_completion_callback()); |
| 74 } |
| 75 return PP_ERROR_NOINTERFACE; |
| 76 } |
| 77 |
| 78 int32_t MediaCodecVideoDecoder::GetPictureBuffer( |
| 79 const CompletionCallbackWithOutput<PP_MediaCodec_PictureBuffer>& cc) { |
| 80 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 81 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->GetPictureBuffer( |
| 82 pp_resource(), |
| 83 cc.output(), |
| 84 cc.pp_completion_callback()); |
| 85 } |
| 86 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 87 } |
| 88 |
| 89 void MediaCodecVideoDecoder::RecyclePictureBuffer( |
| 90 const PP_MediaCodec_PictureBuffer& picture_buffer) { |
| 91 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 92 get_interface<PPB_MediaCodecVideoDecoder_0_1>()->RecyclePictureBuffer( |
| 93 pp_resource(), &picture_buffer); |
| 94 } |
| 95 } |
| 96 |
| 97 int32_t MediaCodecVideoDecoder::Flush(const CompletionCallback& cc) { |
| 98 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 99 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Flush( |
| 100 pp_resource(), cc.pp_completion_callback()); |
| 101 } |
| 102 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 103 } |
| 104 |
| 105 int32_t MediaCodecVideoDecoder::Reset(const CompletionCallback& cc) { |
| 106 if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| 107 return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Reset( |
| 108 pp_resource(), cc.pp_completion_callback()); |
| 109 } |
| 110 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 111 } |
| 112 |
| 113 } // namespace pp |
| OLD | NEW |