Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Side by Side Diff: ppapi/cpp/dev/video_decoder_dev.cc

Issue 7085030: Implementation for Pepper C++ Video Decoder API (wrapper on top of C API). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor style fixes. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/dev/video_decoder_dev.h" 5 #include "ppapi/cpp/dev/video_decoder_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 7 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
8 #include "ppapi/c/dev/ppp_video_decoder_dev.h" 8 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/common.h" 10 #include "ppapi/cpp/common.h"
11 #include "ppapi/cpp/instance.h" 11 #include "ppapi/cpp/instance.h"
12 #include "ppapi/cpp/module.h" 12 #include "ppapi/cpp/module.h"
13 #include "ppapi/cpp/module_impl.h" 13 #include "ppapi/cpp/module_impl.h"
14 14
15 using std::vector;
16
17 namespace pp { 15 namespace pp {
18 16
19 namespace { 17 namespace {
20 18
21 template <> const char* interface_name<PPB_VideoDecoder_Dev>() { 19 template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
22 return PPB_VIDEODECODER_DEV_INTERFACE; 20 return PPB_VIDEODECODER_DEV_INTERFACE;
23 } 21 }
24 22
25 } // namespace 23 } // namespace
26 24
27 VideoDecoder::VideoDecoder(const Instance* /* instance */, 25 VideoDecoder::VideoDecoder(const Instance* instance,
28 const std::vector<uint32_t>& /* config */, 26 const std::vector<PP_VideoConfigElement>& config,
29 CompletionCallback /* callback */, 27 CompletionCallback callback,
30 Client* client) 28 Client* client)
31 : client_(client) { 29 : client_(client) {
32 if (!has_interface<PPB_VideoDecoder_Dev>()) 30 if (!has_interface<PPB_VideoDecoder_Dev>())
33 return; 31 return;
34 // TODO(vmr): Implement. 32 PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
33 instance->pp_instance(), &config[0], callback.pp_completion_callback()));
35 } 34 }
36 35
37 VideoDecoder::~VideoDecoder() {} 36 VideoDecoder::~VideoDecoder() {}
38 37
39 vector<uint32_t> VideoDecoder::GetConfigs( 38 std::vector<PP_VideoConfigElement> VideoDecoder::GetConfigs(
40 Instance* /* instance */, 39 Instance* instance,
41 const vector<uint32_t>& /* prototype_config */) { 40 const std::vector<PP_VideoConfigElement>& prototype_config) {
42 // TODO(vmr): Implement. 41 std::vector<PP_VideoConfigElement> matching_configs;
43 vector<uint32_t> matching_configs;
44 if (!has_interface<PPB_VideoDecoder_Dev>()) 42 if (!has_interface<PPB_VideoDecoder_Dev>())
45 return matching_configs; 43 return matching_configs;
44 if (prototype_config.size() == 0)
45 return matching_configs;
46
47 // First ask the number of matching configs.
48 uint32_t num_of_matching_configs = 0;
49 get_interface<PPB_VideoDecoder_Dev>()->GetConfigs(
50 instance->pp_instance(), &prototype_config[0], NULL, 0,
51 &num_of_matching_configs);
52 if (num_of_matching_configs == 0)
53 return matching_configs;
54
55 // Then ask the actually matching configs and return them in the vector.
56 matching_configs.resize(num_of_matching_configs);
57 get_interface<PPB_VideoDecoder_Dev>()->GetConfigs(
58 instance->pp_instance(), &prototype_config[0], &matching_configs[0],
59 num_of_matching_configs, &num_of_matching_configs);
46 return matching_configs; 60 return matching_configs;
47 } 61 }
48 62
49 void VideoDecoder::AssignGLESBuffers(uint32_t /* no_of_buffers */, 63 void VideoDecoder::AssignGLESBuffers(
50 const PP_GLESBuffer_Dev& /* buffers */) { 64 const std::vector<PP_GLESBuffer_Dev>& buffers) {
51 // TODO(vmr): Implement. 65 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
66 return;
67 get_interface<PPB_VideoDecoder_Dev>()->AssignGLESBuffers(
68 pp_resource(), buffers.size(), &buffers[0]);
52 } 69 }
53 70
54 void VideoDecoder::AssignSysmemBuffers( 71 void VideoDecoder::AssignSysmemBuffers(
55 uint32_t /* no_of_buffers */, 72 const std::vector<PP_SysmemBuffer_Dev>& buffers) {
56 const PP_SysmemBuffer_Dev& /* buffers */) { 73 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
57 // TODO(vmr): Implement. 74 return;
75 get_interface<PPB_VideoDecoder_Dev>()->AssignSysmemBuffers(
76 pp_resource(), buffers.size(), &buffers[0]);
58 } 77 }
59 78
60 bool VideoDecoder::Decode( 79 bool VideoDecoder::Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
61 const PP_VideoBitstreamBuffer_Dev& /* bitstream_buffer */, 80 CompletionCallback callback) {
62 CompletionCallback /* callback */) {
63 // TODO(vmr): Implement.
64 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) 81 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
65 return false; 82 return false;
66 return false; 83 return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Decode(
84 pp_resource(), &bitstream_buffer, callback.pp_completion_callback()));
67 } 85 }
68 86
69 void VideoDecoder::ReusePictureBuffer(int32_t /* picture_buffer_id */) { 87 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
70 // TODO(vmr): Implement. 88 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
89 return;
90 get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer(
91 pp_resource(), picture_buffer_id);
71 } 92 }
72 93
73 bool VideoDecoder::Flush(CompletionCallback /* callback */) { 94 bool VideoDecoder::Flush(CompletionCallback callback) {
74 // TODO(vmr): Implement. 95 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
75 if (!has_interface<PPB_VideoDecoder_Dev>())
76 return false; 96 return false;
77 return true; 97 return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Flush(
98 pp_resource(), callback.pp_completion_callback()));
78 } 99 }
79 100
80 bool VideoDecoder::Abort(CompletionCallback /* callback */) { 101 bool VideoDecoder::Abort(CompletionCallback callback) {
81 // TODO(vmr): Implement. 102 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
82 if (!has_interface<PPB_VideoDecoder_Dev>())
83 return false; 103 return false;
84 return true; 104 return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Abort(
105 pp_resource(), callback.pp_completion_callback()));
85 } 106 }
86 107
87 } // namespace pp 108 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698