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

Side by Side Diff: webkit/plugins/ppapi/ppb_video_decoder_impl.cc

Issue 6901036: Update VideoDecode PPAPI structs to be consistent with media structures, part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A few other little clean-up stuff Created 9 years, 7 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/video/picture.h"
10 #include "ppapi/c/dev/pp_video_dev.h" 11 #include "ppapi/c/dev/pp_video_dev.h"
11 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 12 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
13 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
12 #include "ppapi/c/pp_completion_callback.h" 14 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
14 #include "webkit/plugins/ppapi/common.h" 16 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/plugins/ppapi/plugin_module.h"
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
20 #include "webkit/plugins/ppapi/resource_tracker.h"
15 #include "webkit/plugins/ppapi/var.h" 21 #include "webkit/plugins/ppapi/var.h"
16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
17 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
18 #include "webkit/plugins/ppapi/resource_tracker.h"
19 22
20 namespace webkit { 23 namespace webkit {
21 namespace ppapi { 24 namespace ppapi {
22 25
23 namespace { 26 namespace {
24 27
25 PP_Bool GetConfigs(PP_Instance instance_id, 28 PP_Bool GetConfigs(PP_Instance instance_id,
26 PP_VideoDecoderConfig_Dev* proto_config, 29 PP_VideoConfigElement* proto_config,
27 PP_VideoDecoderConfig_Dev* matching_configs, 30 PP_VideoConfigElement* matching_configs,
28 int32_t matching_configs_size, 31 uint32_t matching_configs_size,
29 int32_t* num_of_matching_configs) { 32 uint32_t* num_of_matching_configs) {
30 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); 33 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
31 if (!instance) 34 if (!instance)
32 return PP_FALSE; 35 return PP_FALSE;
33 36
34 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 37 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
35 new PPB_VideoDecoder_Impl(instance)); 38 new PPB_VideoDecoder_Impl(instance));
36 39
37 return BoolToPPBool(decoder->GetConfigs(proto_config, 40 return BoolToPPBool(decoder->GetConfigs(proto_config,
38 matching_configs, 41 matching_configs,
39 matching_configs_size, 42 matching_configs_size,
40 num_of_matching_configs)); 43 num_of_matching_configs));
41 } 44 }
42 45
43 PP_Resource Create(PP_Instance instance_id, 46 PP_Resource Create(PP_Instance instance_id,
44 PP_VideoDecoderConfig_Dev* decoder_config) { 47 PP_VideoConfigElement* decoder_config) {
45 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); 48 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
46 if (!instance) 49 if (!instance)
47 return 0; 50 return 0;
48 51
49 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 52 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
50 new PPB_VideoDecoder_Impl(instance)); 53 new PPB_VideoDecoder_Impl(instance));
51 54
52 if (!decoder->Init(const_cast<PP_VideoDecoderConfig_Dev*>(decoder_config))) 55 if (!decoder->Init(const_cast<PP_VideoConfigElement*>(decoder_config)))
53 return 0; 56 return 0;
54 57
55 return decoder->GetReference(); 58 return decoder->GetReference();
56 } 59 }
57 60
58 PP_Bool IsVideoDecoder(PP_Resource resource) { 61 PP_Bool IsVideoDecoder(PP_Resource resource) {
59 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); 62 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource));
60 } 63 }
61 64
62 PP_Bool Decode(PP_Resource decoder_id, 65 PP_Bool Decode(PP_Resource decoder_id,
63 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 66 PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
64 PP_CompletionCallback callback) { 67 PP_CompletionCallback callback) {
65 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 68 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
66 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); 69 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id));
67 if (!decoder) 70 if (!decoder)
68 return PP_FALSE; 71 return PP_FALSE;
69 72
70 return BoolToPPBool(decoder->Decode(bitstream_buffer, callback)); 73 return BoolToPPBool(decoder->Decode(bitstream_buffer, callback));
71 } 74 }
72 75
73 void AssignPictureBuffer(PP_Resource video_decoder, 76 void AssignGLESBuffers(PP_Resource video_decoder,
74 uint32_t no_of_buffers, 77 uint32_t no_of_buffers,
75 union PP_PictureData_Dev* picture_buffer) { 78 PP_GLESBuffer_Dev* buffers) {
76 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 79 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
77 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 80 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
78 if (!decoder) 81 if (!decoder)
79 return; 82 return;
80 83
81 decoder->AssignPictureBuffer(no_of_buffers, picture_buffer); 84 decoder->AssignGLESBuffers(no_of_buffers, buffers);
82 } 85 }
83 86
84 void ReusePictureBuffer(PP_Resource video_decoder, 87 void AssignSysmemBuffers(PP_Resource video_decoder,
85 union PP_PictureData_Dev* picture_buffer) { 88 uint32_t no_of_buffers,
89 PP_SysmemBuffer_Dev* buffers) {
86 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 90 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
87 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 91 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
88 if (!decoder) 92 if (!decoder)
89 return; 93 return;
90 94
91 decoder->ReusePictureBuffer(picture_buffer); 95 decoder->AssignSysmemBuffers(no_of_buffers, buffers);
92 } 96 }
93 97
94 PP_Bool Flush(PP_Resource video_decoder, 98 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) {
95 PP_CompletionCallback callback) {
96 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 99 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
97 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 100 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
98 if (!decoder) 101 if (!decoder)
102 return;
103
104 decoder->ReusePictureBuffer(picture_buffer_id);
105 }
106
107 PP_Bool Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
108 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
109 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
110 if (!decoder)
99 return PP_FALSE; 111 return PP_FALSE;
100 112
101 return BoolToPPBool(decoder->Flush(callback)); 113 return BoolToPPBool(decoder->Flush(callback));
102 } 114 }
103 115
104 PP_Bool Abort(PP_Resource video_decoder, 116 PP_Bool Abort(PP_Resource video_decoder,
105 PP_CompletionCallback callback) { 117 PP_CompletionCallback callback) {
106 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 118 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
107 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 119 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
108 if (!decoder) 120 if (!decoder)
109 return PP_FALSE; 121 return PP_FALSE;
110 122
111 return BoolToPPBool(decoder->Abort(callback)); 123 return BoolToPPBool(decoder->Abort(callback));
112 } 124 }
113 125
114
115 const PPB_VideoDecoder_Dev ppb_videodecoder = { 126 const PPB_VideoDecoder_Dev ppb_videodecoder = {
116 &GetConfigs, 127 &GetConfigs,
117 &Create, 128 &Create,
118 &IsVideoDecoder, 129 &IsVideoDecoder,
119 &Decode, 130 &Decode,
120 &AssignPictureBuffer, 131 &AssignGLESBuffers,
132 &AssignSysmemBuffers,
121 &ReusePictureBuffer, 133 &ReusePictureBuffer,
122 &Flush, 134 &Flush,
123 &Abort, 135 &Abort,
124 }; 136 };
125 137
138 // Utility methods to convert data to and from the ppapi C-types and its
Ami GONE FROM CHROMIUM 2011/05/05 16:40:53 s/its/their/
139 // C++ media-namespace equivalents.
140 void CopyToPictureDev(const media::Picture& input, PP_Picture_Dev* output) {
141 output->picture_buffer_id = input.picture_buffer_id();
142 output->bitstream_user_handle = input.user_handle();
143 output->visible_size =
144 PP_MakeSize(input.visible_size().width(), input.visible_size().height());
145 output->decoded_size =
146 PP_MakeSize(input.decoded_size().width(), input.decoded_size().height());
147 }
148
149 void CopyToConfigList(
150 const PP_VideoConfigElement* configs, std::vector<uint32>* output) {
151 // TODO(vrk): This is assuming PP_VideoAttributeDictionary and
152 // VideoAttributeKey have identical enum values. There is no compiler
153 // assert to guarantee this. We either need to add such asserts or
154 // merge PP_VideoAttributeDictionary and VideoAttributeKey.
155 const PP_VideoConfigElement* current = configs;
156 while (*current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) {
157 output->push_back(static_cast<uint32>(*configs));
158 current++;
159 }
160 }
161
126 } // namespace 162 } // namespace
127 163
128 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) 164 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance)
129 : Resource(instance), 165 : Resource(instance),
130 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 166 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
131 abort_callback_(PP_BlockUntilComplete()), 167 abort_callback_(PP_BlockUntilComplete()),
132 flush_callback_(PP_BlockUntilComplete()), 168 flush_callback_(PP_BlockUntilComplete()),
133 bitstream_buffer_callback_(PP_BlockUntilComplete()) { 169 bitstream_buffer_callback_(PP_BlockUntilComplete()) {
170 ppp_videodecoder_ =
171 static_cast<const PPP_VideoDecoder_Dev*>(instance->module()->
172 GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
134 } 173 }
135 174
136 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { 175 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() {
137 } 176 }
138 177
139 // static 178 // static
140 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() { 179 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() {
141 return &ppb_videodecoder; 180 return &ppb_videodecoder;
142 } 181 }
143 182
144 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() { 183 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() {
145 return this; 184 return this;
146 } 185 }
147 186
148 bool PPB_VideoDecoder_Impl::GetConfigs( 187 bool PPB_VideoDecoder_Impl::GetConfigs(
149 PP_VideoDecoderConfig_Dev* proto_config, 188 PP_VideoConfigElement* requested_configs,
150 PP_VideoDecoderConfig_Dev* matching_configs, 189 PP_VideoConfigElement* matching_configs,
151 int32_t matching_configs_size, 190 uint32_t matching_configs_size,
152 int32_t* num_of_matching_configs) { 191 uint32_t* num_of_matching_configs) {
153 if (!instance()) 192 if (!instance())
154 return false; 193 return false;
155 if (!platform_video_decoder_.get()) 194 if (!platform_video_decoder_.get())
156 return false; 195 return false;
196 if (!matching_configs)
197 return false;
157 198
158 // TODO(vmr): Implement. 199 std::vector<uint32> requested;
159 NOTIMPLEMENTED(); 200 CopyToConfigList(requested_configs, &requested);
201 std::vector<uint32> matched;
202 platform_video_decoder_->GetConfigs(requested, &matched);
160 203
161 return false; 204 int i;
205 for (i = 0; i < matched.size() && i < matching_configs_size; i++)
206 matching_configs[i] = matched[i];
207 *num_of_matching_configs = i;
208
209 return true;
162 } 210 }
163 211
164 bool PPB_VideoDecoder_Impl::Init(PP_VideoDecoderConfig_Dev* decoder_config) { 212 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config) {
165 if (!instance()) 213 if (!instance())
166 return false; 214 return false;
167 215
168 platform_video_decoder_.reset( 216 platform_video_decoder_.reset(
169 instance()->delegate()->CreateVideoDecoder(decoder_config)); 217 instance()->delegate()->CreateVideoDecoder(decoder_config, this));
170 218
171 return platform_video_decoder_.get()? true : false; 219 return platform_video_decoder_.get()? true : false;
172 } 220 }
173 221
174 bool PPB_VideoDecoder_Impl::Decode( 222 bool PPB_VideoDecoder_Impl::Decode(
175 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 223 PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
176 PP_CompletionCallback callback) { 224 PP_CompletionCallback callback) {
177 if (!platform_video_decoder_.get()) 225 if (!platform_video_decoder_.get())
178 return false; 226 return false;
179 227
180 media::BitstreamBuffer* decode_buffer = NULL; 228 scoped_refptr<PPB_Buffer_Impl> pepper_buffer =
181 // TODO(vmr): Convert bitstream_buffer to BitstreamBuffer object. 229 Resource::GetAs<PPB_Buffer_Impl>(bitstream_buffer->bitstream);
182 NOTIMPLEMENTED(); 230
231 media::BitstreamBuffer decode_buffer(pepper_buffer->mapped_buffer(),
232 bitstream_buffer->bitstream_size,
233 bitstream_buffer->user_handle);
183 234
184 // Store the callback to inform when bitstream buffer has been processed. 235 // Store the callback to inform when bitstream buffer has been processed.
185 // TODO(vmr): handle simultaneous decodes + callbacks. 236 // TODO(vmr): handle simultaneous decodes + callbacks.
186 bitstream_buffer_callback_ = callback; 237 bitstream_buffer_callback_ = callback;
187 238
188 return platform_video_decoder_->Decode( 239 return platform_video_decoder_->Decode(
189 decode_buffer, 240 decode_buffer,
190 callback_factory_.NewCallback( 241 callback_factory_.NewCallback(
191 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed)); 242 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed));
192 } 243 }
193 244
194 void PPB_VideoDecoder_Impl::AssignPictureBuffer( 245 void PPB_VideoDecoder_Impl::AssignGLESBuffers(
195 uint32_t no_of_picture_buffers, 246 uint32_t no_of_buffers,
196 PP_PictureData_Dev* picture_buffers) { 247 PP_GLESBuffer_Dev* buffers) {
197 if (!platform_video_decoder_.get()) 248 if (!platform_video_decoder_.get())
198 return; 249 return;
199 250
200 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object. 251 std::vector<media::GLESBuffer> wrapped_buffers;
201 NOTIMPLEMENTED(); 252 for (uint i = 0; i < no_of_buffers; i++) {
202 253 PP_GLESBuffer_Dev in_buf = buffers[i];
203 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL; 254 media::GLESBuffer buffer(in_buf);
204 platform_video_decoder_->ReusePictureBuffer(buffer); 255 wrapped_buffers.push_back(buffer);
256 }
257 platform_video_decoder_->AssignGLESBuffers(wrapped_buffers);
205 } 258 }
206 259
207 void PPB_VideoDecoder_Impl::ReusePictureBuffer( 260 void PPB_VideoDecoder_Impl::AssignSysmemBuffers(
208 PP_PictureData_Dev* picture_buffer) { 261 uint32_t no_of_buffers,
262 PP_SysmemBuffer_Dev* buffers) {
209 if (!platform_video_decoder_.get()) 263 if (!platform_video_decoder_.get())
210 return; 264 return;
211 265
212 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object. 266 std::vector<media::SysmemBuffer> wrapped_buffers;
213 NOTIMPLEMENTED(); 267 for (uint i = 0; i < no_of_buffers; i++) {
268 PP_SysmemBuffer_Dev in_buf = buffers[i];
269 media::SysmemBuffer buffer(in_buf);
270 wrapped_buffers.push_back(buffer);
271 }
272 platform_video_decoder_->AssignSysmemBuffers(wrapped_buffers);
273 }
214 274
215 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL; 275 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
216 platform_video_decoder_->ReusePictureBuffer(buffer); 276 if (!platform_video_decoder_.get())
277 return;
278 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id);
217 } 279 }
218 280
219 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { 281 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
220 if (!platform_video_decoder_.get()) 282 if (!platform_video_decoder_.get())
221 return false; 283 return false;
222 284
223 // Store the callback to be called when Flush() is done. 285 // Store the callback to be called when Flush() is done.
224 // TODO(vmr): Check for current flush/abort operations. 286 // TODO(vmr): Check for current flush/abort operations.
225 flush_callback_ = callback; 287 flush_callback_ = callback;
226 288
227 return platform_video_decoder_->Flush( 289 return platform_video_decoder_->Flush(
228 callback_factory_.NewCallback( 290 callback_factory_.NewCallback(
229 &PPB_VideoDecoder_Impl::OnFlushComplete)); 291 &PPB_VideoDecoder_Impl::OnFlushComplete));
230 } 292 }
231 293
232 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { 294 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) {
233 if (!platform_video_decoder_.get()) 295 if (!platform_video_decoder_.get())
234 return false; 296 return false;
235 297
236 // Store the callback to be called when Abort() is done. 298 // Store the callback to be called when Abort() is done.
237 // TODO(vmr): Check for current flush/abort operations. 299 // TODO(vmr): Check for current flush/abort operations.
238 abort_callback_ = callback; 300 abort_callback_ = callback;
239 301
240 return platform_video_decoder_->Abort( 302 return platform_video_decoder_->Abort(
241 callback_factory_.NewCallback( 303 callback_factory_.NewCallback(
242 &PPB_VideoDecoder_Impl::OnAbortComplete)); 304 &PPB_VideoDecoder_Impl::OnAbortComplete));
243 } 305 }
244 306
245 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( 307 void PPB_VideoDecoder_Impl::ProvidePictureBuffers(
246 uint32_t requested_num_of_buffers, 308 uint32 requested_num_of_buffers,
247 const std::vector<uint32_t>& buffer_properties) { 309 gfx::Size dimensions,
248 // TODO(vmr): Implement. 310 media::VideoDecodeAccelerator::MemoryType type) {
249 NOTIMPLEMENTED(); 311 if (!ppp_videodecoder_)
312 return;
313
314 // TODO(vrk): Compiler assert or use switch statement instead of making
315 // a blind cast.
316 PP_PictureBufferType_Dev out_type =
317 static_cast<PP_PictureBufferType_Dev>(type);
318 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height());
319 ScopedResourceId resource(this);
320 ppp_videodecoder_->ProvidePictureBuffers(
321 resource.id, requested_num_of_buffers, out_dim, out_type);
250 } 322 }
251 323
252 void PPB_VideoDecoder_Impl::PictureReady( 324 void PPB_VideoDecoder_Impl::PictureReady(
253 media::VideoDecodeAccelerator::Picture* picture) { 325 const media::Picture& picture) {
254 // TODO(vmr): Implement. 326 if (!ppp_videodecoder_)
255 NOTIMPLEMENTED(); 327 return;
256 328
257 // Convert the picture. 329 ScopedResourceId resource(this);
258 // Get plugin's PPP interface function pointers. 330 PP_Picture_Dev out_pic;
259 // PPP_VideoDecoder* ppp_videodecoder; 331 CopyToPictureDev(picture, &out_pic);
260 // Call ProvidePictureBuffers function pointer and return. 332 ppp_videodecoder_->PictureReady(resource.id, out_pic);
261 // ppp_videodecoder->PictureReady(resource_decoder, picture,
262 // pic_buffer_used_again);
263 } 333 }
264 334
265 void PPB_VideoDecoder_Impl::DismissPictureBuffer( 335 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) {
266 media::VideoDecodeAccelerator::PictureBuffer* picture_buffer) { 336 if (!ppp_videodecoder_)
267 // TODO(vmr): Implement. 337 return;
268 NOTIMPLEMENTED(); 338
339 ScopedResourceId resource(this);
340 ppp_videodecoder_->DismissPictureBuffer(resource.id, picture_buffer_id);
269 } 341 }
270 342
271 void PPB_VideoDecoder_Impl::NotifyEndOfStream() { 343 void PPB_VideoDecoder_Impl::NotifyEndOfStream() {
272 // TODO(vmr): Implement. 344 if (!ppp_videodecoder_)
273 NOTIMPLEMENTED(); 345 return;
274 346
275 // Get decoder's resource handle. 347 ScopedResourceId resource(this);
276 // PP_Resource resource_decoder; 348 ppp_videodecoder_->EndOfStream(resource.id);
277 // Get plugin's PPP interface function pointers.
278 // PPP_VideoDecoder* ppp_videodecoder;
279 // Call EndOfStream function pointer and return.
280 // ppp_videodecoder->EndOfStream(resource_decoder);
281 } 349 }
282 350
283 void PPB_VideoDecoder_Impl::NotifyError( 351 void PPB_VideoDecoder_Impl::NotifyError(
284 media::VideoDecodeAccelerator::Error error) { 352 media::VideoDecodeAccelerator::Error error) {
285 // TODO(vmr): Implement. 353 if (!ppp_videodecoder_)
286 NOTIMPLEMENTED(); 354 return;
287 355
288 // Get decoder's resource handle. 356 ScopedResourceId resource(this);
289 // PP_Resource resource_decoder; 357 // TODO(vrk): This is assuming VideoDecodeAccelerator::Error and
290 // Get plugin's PPP interface function pointers. 358 // PP_VideoDecodeError_Dev have identical enum values. There is no compiler
291 // PPP_VideoDecoder* ppp_videodecoder; 359 // assert to guarantee this. We either need to add such asserts or
292 // Call NotifyError function pointer. 360 // merge these two enums.
293 // ppp_videodecoder->NotifyError(error, error_data, data_size); 361 ppp_videodecoder_->NotifyError(resource.id,
362 static_cast<PP_VideoDecodeError_Dev>(error));
294 } 363 }
295 364
296 void PPB_VideoDecoder_Impl::OnAbortComplete() { 365 void PPB_VideoDecoder_Impl::OnAbortComplete() {
297 if (abort_callback_.func == NULL) 366 if (abort_callback_.func == NULL)
298 return; 367 return;
299 368
300 // Call the callback that was stored to be called when Abort is done. 369 // Call the callback that was stored to be called when Abort is done.
301 PP_CompletionCallback callback = PP_BlockUntilComplete(); 370 PP_CompletionCallback callback = PP_BlockUntilComplete();
302 std::swap(callback, abort_callback_); 371 std::swap(callback, abort_callback_);
303 PP_RunCompletionCallback(&callback, PP_OK); 372 PP_RunCompletionCallback(&callback, PP_OK);
(...skipping 15 matching lines...) Expand all
319 return; 388 return;
320 389
321 // Call the callback that was stored to be called when Flush is done. 390 // Call the callback that was stored to be called when Flush is done.
322 PP_CompletionCallback callback = PP_BlockUntilComplete(); 391 PP_CompletionCallback callback = PP_BlockUntilComplete();
323 std::swap(callback, flush_callback_); 392 std::swap(callback, flush_callback_);
324 PP_RunCompletionCallback(&callback, PP_OK); 393 PP_RunCompletionCallback(&callback, PP_OK);
325 } 394 }
326 395
327 } // namespace ppapi 396 } // namespace ppapi
328 } // namespace webkit 397 } // namespace webkit
398
399 // These functions are declared in picture.h but are defined here because of
400 // dependencies (we can't depend on ppapi types from media).
401 namespace media {
402 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info)
403 : id_(info.id) {
404 size_ = gfx::Size(info.size.width, info.size.height);
405 }
406
407 // TODO(vrk): This assigns the PP_Resource context to be
408 // the context_id. Not sure what it's actually supposed to be.
409 GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer)
410 : texture_id_(buffer.texture_id),
411 context_id_(buffer.context),
412 info_(buffer.info) {
413 }
414
415 SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer)
416 : info_(buffer.info) {
417 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer =
418 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>(
419 buffer.data);
420 assert(pepper_buffer->is_mapped());
421 data_ = pepper_buffer->mapped_buffer();
422 }
423
424 Picture::Picture(const PP_Picture_Dev& picture)
425 : picture_buffer_id_(picture.picture_buffer_id),
426 user_handle_(picture.bitstream_user_handle),
427 visible_size_(picture.visible_size.width, picture.visible_size.height),
428 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) {
429 }
430
431 } // namespace media
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698