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

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

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 #include "ppapi/thunk/common.h"
14 15
15 namespace pp { 16 namespace pp {
16 17
17 namespace { 18 namespace {
18 19
19 template <> const char* interface_name<PPB_VideoDecoder_Dev>() { 20 template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
20 return PPB_VIDEODECODER_DEV_INTERFACE; 21 return PPB_VIDEODECODER_DEV_INTERFACE;
21 } 22 }
22 23
23 } // namespace 24 } // namespace
24 25
25 VideoDecoder::VideoDecoder(const Instance* instance, Client* client) 26 VideoDecoder::VideoDecoder(const Instance* instance, Client* client)
26 : client_(client) { 27 : client_(client) {
27 if (!has_interface<PPB_VideoDecoder_Dev>()) 28 if (!has_interface<PPB_VideoDecoder_Dev>())
28 return; 29 return;
29 PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create( 30 PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
30 instance->pp_instance())); 31 instance->pp_instance()));
31 } 32 }
32 33
33 VideoDecoder::~VideoDecoder() {} 34 VideoDecoder::~VideoDecoder() {}
34 35
35 int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config, 36 int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config,
36 CompletionCallback callback) { 37 CompletionCallback callback) {
37 if (!has_interface<PPB_VideoDecoder_Dev>()) 38 if (!has_interface<PPB_VideoDecoder_Dev>())
38 return PP_ERROR_NOINTERFACE; 39 return callback.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
piman 2011/06/07 17:32:14 no need for static_cast ? here and below
polina 2011/06/09 23:53:51 Done.
39 return get_interface<PPB_VideoDecoder_Dev>()->Initialize( 40 return get_interface<PPB_VideoDecoder_Dev>()->Initialize(
40 pp_resource(), config, callback.pp_completion_callback()); 41 pp_resource(), config, callback.pp_completion_callback());
41 } 42 }
42 43
43 bool VideoDecoder::GetConfigs(Instance* instance, 44 bool VideoDecoder::GetConfigs(Instance* instance,
44 const PP_VideoConfigElement* prototype_config, 45 const PP_VideoConfigElement* prototype_config,
45 PP_VideoConfigElement* matching_configs, 46 PP_VideoConfigElement* matching_configs,
46 uint32_t matching_configs_size, 47 uint32_t matching_configs_size,
47 uint32_t* num_of_matching_configs) { 48 uint32_t* num_of_matching_configs) {
48 if (!has_interface<PPB_VideoDecoder_Dev>()) 49 if (!has_interface<PPB_VideoDecoder_Dev>())
(...skipping 16 matching lines...) Expand all
65 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) 66 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
66 return; 67 return;
67 get_interface<PPB_VideoDecoder_Dev>()->AssignSysmemBuffers( 68 get_interface<PPB_VideoDecoder_Dev>()->AssignSysmemBuffers(
68 pp_resource(), buffers.size(), &buffers[0]); 69 pp_resource(), buffers.size(), &buffers[0]);
69 } 70 }
70 71
71 int32_t VideoDecoder::Decode( 72 int32_t VideoDecoder::Decode(
72 const PP_VideoBitstreamBuffer_Dev& bitstream_buffer, 73 const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
73 CompletionCallback callback) { 74 CompletionCallback callback) {
74 if (!has_interface<PPB_VideoDecoder_Dev>()) 75 if (!has_interface<PPB_VideoDecoder_Dev>())
75 return PP_ERROR_NOINTERFACE; 76 return callback.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
76 if (!pp_resource())
piman 2011/06/07 17:32:14 Why removing the check for pp_resource ?
polina 2011/06/09 23:53:51 This check must be and is performed by the C funct
77 return PP_ERROR_BADRESOURCE;
78 return get_interface<PPB_VideoDecoder_Dev>()->Decode( 77 return get_interface<PPB_VideoDecoder_Dev>()->Decode(
79 pp_resource(), &bitstream_buffer, callback.pp_completion_callback()); 78 pp_resource(), &bitstream_buffer, callback.pp_completion_callback());
80 } 79 }
81 80
82 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { 81 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
83 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource()) 82 if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
84 return; 83 return;
85 get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer( 84 get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer(
86 pp_resource(), picture_buffer_id); 85 pp_resource(), picture_buffer_id);
87 } 86 }
88 87
89 int32_t VideoDecoder::Flush(CompletionCallback callback) { 88 int32_t VideoDecoder::Flush(CompletionCallback callback) {
90 if (!has_interface<PPB_VideoDecoder_Dev>()) 89 if (!has_interface<PPB_VideoDecoder_Dev>())
91 return PP_ERROR_NOINTERFACE; 90 return callback.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
92 if (!pp_resource())
93 return PP_ERROR_BADRESOURCE;
94 return get_interface<PPB_VideoDecoder_Dev>()->Flush( 91 return get_interface<PPB_VideoDecoder_Dev>()->Flush(
95 pp_resource(), callback.pp_completion_callback()); 92 pp_resource(), callback.pp_completion_callback());
96 } 93 }
97 94
98 int32_t VideoDecoder::Abort(CompletionCallback callback) { 95 int32_t VideoDecoder::Abort(CompletionCallback callback) {
99 if (!has_interface<PPB_VideoDecoder_Dev>()) 96 if (!has_interface<PPB_VideoDecoder_Dev>())
100 return PP_ERROR_NOINTERFACE; 97 return callback.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
101 if (!pp_resource())
102 return PP_ERROR_BADRESOURCE;
103 return get_interface<PPB_VideoDecoder_Dev>()->Abort( 98 return get_interface<PPB_VideoDecoder_Dev>()->Abort(
104 pp_resource(), callback.pp_completion_callback()); 99 pp_resource(), callback.pp_completion_callback());
105 } 100 }
106 101
107 } // namespace pp 102 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698