| 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..310f0bfcf20905493508228534b35391c2a2a1d2
|
| --- /dev/null
|
| +++ b/ppapi/cpp/media_codec_video_decoder.cc
|
| @@ -0,0 +1,96 @@
|
| +// 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 picture_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(), picture_id, size, buffer, cc.pp_completion_callback());
|
| + }
|
| + return PP_ERROR_NOINTERFACE;
|
| +}
|
| +
|
| +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
|
|
|