Chromium Code Reviews| Index: ppapi/cpp/media_codec_video_decoder.cc |
| diff --git a/ppapi/cpp/media_codec_video_decoder.cc b/ppapi/cpp/media_codec_video_decoder.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..273a757a293d5d06f9c5d47a2166efcf8caf5fe9 |
| --- /dev/null |
| +++ b/ppapi/cpp/media_codec_video_decoder.cc |
| @@ -0,0 +1,104 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/cpp/media_codec_video_decoder.h" |
| + |
| +#include "ppapi/c/pp_errors.h" |
| +#include "ppapi/c/ppb_media_codec_video_decoder.h" |
| +#include "ppapi/cpp/completion_callback.h" |
| +#include "ppapi/cpp/instance_handle.h" |
| +#include "ppapi/cpp/module.h" |
| +#include "ppapi/cpp/module_impl.h" |
| + |
| +namespace pp { |
| + |
| +namespace { |
| + |
| +template <> |
| +const char* interface_name<PPB_MediaCodecVideoDecoder_0_1>() { |
| + return PPB_MEDIACODECVIDEODECODER_INTERFACE_0_1; |
| +} |
| + |
| +} // namespace |
| + |
| +MediaCodecVideoDecoder::MediaCodecVideoDecoder() {} |
| + |
| +MediaCodecVideoDecoder::MediaCodecVideoDecoder(const InstanceHandle& instance) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + PassRefFromConstructor( |
| + get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Create( |
| + instance.pp_instance())); |
| + } |
| +} |
| + |
| +MediaCodecVideoDecoder::MediaCodecVideoDecoder( |
| + const MediaCodecVideoDecoder& other) |
| + : Resource(other) {} |
| + |
| +int32_t MediaCodecVideoDecoder::Initialize( |
| + const Graphics3D& context, |
| + PP_MediaCodec_VideoProfile profile, |
| + const CompletionCallback& cc) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Initialize( |
| + pp_resource(), |
| + context.pp_resource(), |
| + profile, |
| + cc.pp_completion_callback()); |
| + } |
| + return cc.MayForce(PP_ERROR_NOINTERFACE); |
| +} |
| + |
| +int32_t MediaCodecVideoDecoder::Decode( |
| + uint32_t user_id, |
| + uint32_t size, |
| + const void* buffer, |
| + const CompletionCallback& cc) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Decode( |
| + pp_resource(), |
| + user_id, |
| + size, |
| + buffer, |
| + cc.pp_completion_callback()); |
| + } |
| + return PP_ERROR_NOINTERFACE; |
|
dmichael (off chromium)
2014/04/17 20:23:26
cc.MayForce?
bbudge
2014/04/21 18:14:58
Missed this one. Done.
|
| +} |
| + |
| +int32_t MediaCodecVideoDecoder::GetPicture( |
| + const CompletionCallbackWithOutput<PP_MediaCodec_Picture>& cc) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->GetPicture( |
| + pp_resource(), |
| + cc.output(), |
| + cc.pp_completion_callback()); |
| + } |
| + return cc.MayForce(PP_ERROR_NOINTERFACE); |
| +} |
| + |
| +void MediaCodecVideoDecoder::RecyclePicture( |
| + const PP_MediaCodec_Picture& picture) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + get_interface<PPB_MediaCodecVideoDecoder_0_1>()->RecyclePicture( |
| + pp_resource(), &picture); |
| + } |
| +} |
| + |
| +int32_t MediaCodecVideoDecoder::Flush(const CompletionCallback& cc) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Flush( |
| + pp_resource(), cc.pp_completion_callback()); |
| + } |
| + return cc.MayForce(PP_ERROR_NOINTERFACE); |
| +} |
| + |
| +int32_t MediaCodecVideoDecoder::Reset(const CompletionCallback& cc) { |
| + if (has_interface<PPB_MediaCodecVideoDecoder_0_1>()) { |
| + return get_interface<PPB_MediaCodecVideoDecoder_0_1>()->Reset( |
| + pp_resource(), cc.pp_completion_callback()); |
| + } |
| + return cc.MayForce(PP_ERROR_NOINTERFACE); |
| +} |
| + |
| +} // namespace pp |