Elim cr-checkbox
[chromium-blink-merge.git] / ppapi / cpp / dev / video_decoder_dev.cc
blobdf34986401d4506f04e11b5d2bf98a907720802a
1 // Copyright (c) 2012 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.
5 #include "ppapi/cpp/dev/video_decoder_dev.h"
7 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
8 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/graphics_3d.h"
11 #include "ppapi/cpp/instance_handle.h"
12 #include "ppapi/cpp/module.h"
13 #include "ppapi/cpp/module_impl.h"
15 namespace pp {
17 namespace {
19 template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
20 return PPB_VIDEODECODER_DEV_INTERFACE;
23 } // namespace
25 VideoDecoder_Dev::VideoDecoder_Dev(const InstanceHandle& instance,
26 const Graphics3D& context,
27 PP_VideoDecoder_Profile profile) {
28 if (!has_interface<PPB_VideoDecoder_Dev>())
29 return;
30 PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
31 instance.pp_instance(), context.pp_resource(), profile));
34 VideoDecoder_Dev::VideoDecoder_Dev(PP_Resource resource) : Resource(resource) {
37 VideoDecoder_Dev::~VideoDecoder_Dev() {
40 void VideoDecoder_Dev::AssignPictureBuffers(
41 const std::vector<PP_PictureBuffer_Dev>& buffers) {
42 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
43 return;
44 get_interface<PPB_VideoDecoder_Dev>()->AssignPictureBuffers(
45 pp_resource(), static_cast<uint32_t>(buffers.size()), &buffers[0]);
48 int32_t VideoDecoder_Dev::Decode(
49 const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
50 const CompletionCallback& callback) {
51 if (!has_interface<PPB_VideoDecoder_Dev>())
52 return callback.MayForce(PP_ERROR_NOINTERFACE);
53 return get_interface<PPB_VideoDecoder_Dev>()->Decode(
54 pp_resource(), &bitstream_buffer, callback.pp_completion_callback());
57 void VideoDecoder_Dev::ReusePictureBuffer(int32_t picture_buffer_id) {
58 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
59 return;
60 get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer(
61 pp_resource(), picture_buffer_id);
64 int32_t VideoDecoder_Dev::Flush(const CompletionCallback& callback) {
65 if (!has_interface<PPB_VideoDecoder_Dev>())
66 return callback.MayForce(PP_ERROR_NOINTERFACE);
67 return get_interface<PPB_VideoDecoder_Dev>()->Flush(
68 pp_resource(), callback.pp_completion_callback());
71 int32_t VideoDecoder_Dev::Reset(const CompletionCallback& callback) {
72 if (!has_interface<PPB_VideoDecoder_Dev>())
73 return callback.MayForce(PP_ERROR_NOINTERFACE);
74 return get_interface<PPB_VideoDecoder_Dev>()->Reset(
75 pp_resource(), callback.pp_completion_callback());
78 } // namespace pp