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

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: Fixing a few parameter types 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
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 AssignPictureBuffer(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_PictureBuffer_Dev* picture_buffer) {
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->AssignPictureBuffer(no_of_buffers, picture_buffer);
82 } 85 }
83 86
84 void ReusePictureBuffer(PP_Resource video_decoder, 87 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) {
85 union PP_PictureData_Dev* picture_buffer) {
86 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 88 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
87 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 89 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
88 if (!decoder) 90 if (!decoder)
89 return; 91 return;
90 92
91 decoder->ReusePictureBuffer(picture_buffer); 93 decoder->ReusePictureBuffer(picture_buffer_id);
92 } 94 }
93 95
94 PP_Bool Flush(PP_Resource video_decoder, 96 PP_Bool Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
95 PP_CompletionCallback callback) {
96 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 97 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
97 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); 98 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder));
98 if (!decoder) 99 if (!decoder)
99 return PP_FALSE; 100 return PP_FALSE;
100 101
101 return BoolToPPBool(decoder->Flush(callback)); 102 return BoolToPPBool(decoder->Flush(callback));
102 } 103 }
103 104
104 PP_Bool Abort(PP_Resource video_decoder, 105 PP_Bool Abort(PP_Resource video_decoder,
105 PP_CompletionCallback callback) { 106 PP_CompletionCallback callback) {
(...skipping 18 matching lines...) Expand all
124 }; 125 };
125 126
126 } // namespace 127 } // namespace
127 128
128 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) 129 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance)
129 : Resource(instance), 130 : Resource(instance),
130 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 131 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
131 abort_callback_(PP_BlockUntilComplete()), 132 abort_callback_(PP_BlockUntilComplete()),
132 flush_callback_(PP_BlockUntilComplete()), 133 flush_callback_(PP_BlockUntilComplete()),
133 bitstream_buffer_callback_(PP_BlockUntilComplete()) { 134 bitstream_buffer_callback_(PP_BlockUntilComplete()) {
135 ppp_videodecoder_ =
136 static_cast<const PPP_VideoDecoder_Dev*>(instance->module()->
137 GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
134 } 138 }
135 139
136 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { 140 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() {
137 } 141 }
138 142
139 // static 143 // static
140 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() { 144 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() {
141 return &ppb_videodecoder; 145 return &ppb_videodecoder;
142 } 146 }
143 147
144 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() { 148 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() {
145 return this; 149 return this;
146 } 150 }
147 151
148 bool PPB_VideoDecoder_Impl::GetConfigs( 152 bool PPB_VideoDecoder_Impl::GetConfigs(
149 PP_VideoDecoderConfig_Dev* proto_config, 153 PP_VideoConfigElement* proto_configs,
150 PP_VideoDecoderConfig_Dev* matching_configs, 154 PP_VideoConfigElement* matching_configs,
151 int32_t matching_configs_size, 155 uint32_t matching_configs_size,
152 int32_t* num_of_matching_configs) { 156 uint32_t* num_of_matching_configs) {
153 if (!instance()) 157 if (!instance())
154 return false; 158 return false;
155 if (!platform_video_decoder_.get()) 159 if (!platform_video_decoder_.get())
156 return false; 160 return false;
161 if (!matching_configs)
162 return false;
157 163
158 // TODO(vmr): Implement. 164 std::vector<uint32> requested;
159 NOTIMPLEMENTED(); 165 CopyToConfigList(proto_configs, requested);
166 std::vector<uint32> matched = platform_video_decoder_->GetConfigs(requested);
160 167
161 return false; 168 int i;
169 for (i = 0; i < matched.size() && i < matching_configs_size; i++)
170 matching_configs[i] = matched[i];
171 *num_of_matching_configs = i;
172
173 return true;
162 } 174 }
163 175
164 bool PPB_VideoDecoder_Impl::Init(PP_VideoDecoderConfig_Dev* decoder_config) { 176 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config) {
165 if (!instance()) 177 if (!instance())
166 return false; 178 return false;
167 179
168 platform_video_decoder_.reset( 180 platform_video_decoder_.reset(
169 instance()->delegate()->CreateVideoDecoder(decoder_config)); 181 instance()->delegate()->CreateVideoDecoder(decoder_config, this));
170 182
171 return platform_video_decoder_.get()? true : false; 183 return platform_video_decoder_.get()? true : false;
172 } 184 }
173 185
174 bool PPB_VideoDecoder_Impl::Decode( 186 bool PPB_VideoDecoder_Impl::Decode(
175 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 187 PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
176 PP_CompletionCallback callback) { 188 PP_CompletionCallback callback) {
177 if (!platform_video_decoder_.get()) 189 if (!platform_video_decoder_.get())
178 return false; 190 return false;
179 191
180 media::BitstreamBuffer* decode_buffer = NULL; 192 scoped_refptr<PPB_Buffer_Impl> pepper_buffer =
181 // TODO(vmr): Convert bitstream_buffer to BitstreamBuffer object. 193 Resource::GetAs<PPB_Buffer_Impl>(bitstream_buffer->bitstream);
182 NOTIMPLEMENTED(); 194
195 media::BitstreamBuffer decode_buffer(pepper_buffer->mapped_buffer(),
196 bitstream_buffer->bitstream_size,
197 bitstream_buffer->user_handle);
183 198
184 // Store the callback to inform when bitstream buffer has been processed. 199 // Store the callback to inform when bitstream buffer has been processed.
185 // TODO(vmr): handle simultaneous decodes + callbacks. 200 // TODO(vmr): handle simultaneous decodes + callbacks.
186 bitstream_buffer_callback_ = callback; 201 bitstream_buffer_callback_ = callback;
187 202
188 return platform_video_decoder_->Decode( 203 return platform_video_decoder_->Decode(
189 decode_buffer, 204 decode_buffer,
190 callback_factory_.NewCallback( 205 callback_factory_.NewCallback(
191 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed)); 206 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed));
192 } 207 }
193 208
194 void PPB_VideoDecoder_Impl::AssignPictureBuffer( 209 void PPB_VideoDecoder_Impl::AssignPictureBuffer(
195 uint32_t no_of_picture_buffers, 210 uint32_t no_of_picture_buffers,
196 PP_PictureData_Dev* picture_buffers) { 211 PP_PictureBuffer_Dev* picture_buffers) {
197 if (!platform_video_decoder_.get()) 212 if (!platform_video_decoder_.get())
198 return; 213 return;
199 214
200 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object. 215 std::vector<media::PictureBuffer> wrapped_buffers;
201 NOTIMPLEMENTED(); 216 for (uint i = 0; i < no_of_picture_buffers; i++) {
202 217 PP_PictureBuffer_Dev in_buf = picture_buffers[i];
203 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL; 218 media::PictureBuffer buffer;
204 platform_video_decoder_->ReusePictureBuffer(buffer); 219 if (CopyToMediaPictureBuffer(in_buf, buffer))
220 wrapped_buffers.push_back(buffer);
221 }
222 platform_video_decoder_->AssignPictureBuffer(wrapped_buffers);
205 } 223 }
206 224
207 void PPB_VideoDecoder_Impl::ReusePictureBuffer( 225 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
208 PP_PictureData_Dev* picture_buffer) {
209 if (!platform_video_decoder_.get()) 226 if (!platform_video_decoder_.get())
210 return; 227 return;
211 228 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id);
212 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object.
213 NOTIMPLEMENTED();
214
215 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL;
216 platform_video_decoder_->ReusePictureBuffer(buffer);
217 } 229 }
218 230
219 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { 231 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
220 if (!platform_video_decoder_.get()) 232 if (!platform_video_decoder_.get())
221 return false; 233 return false;
222 234
223 // Store the callback to be called when Flush() is done. 235 // Store the callback to be called when Flush() is done.
224 // TODO(vmr): Check for current flush/abort operations. 236 // TODO(vmr): Check for current flush/abort operations.
225 flush_callback_ = callback; 237 flush_callback_ = callback;
226 238
227 return platform_video_decoder_->Flush( 239 return platform_video_decoder_->Flush(
228 callback_factory_.NewCallback( 240 callback_factory_.NewCallback(
229 &PPB_VideoDecoder_Impl::OnFlushComplete)); 241 &PPB_VideoDecoder_Impl::OnFlushComplete));
230 } 242 }
231 243
232 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { 244 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) {
233 if (!platform_video_decoder_.get()) 245 if (!platform_video_decoder_.get())
234 return false; 246 return false;
235 247
236 // Store the callback to be called when Abort() is done. 248 // Store the callback to be called when Abort() is done.
237 // TODO(vmr): Check for current flush/abort operations. 249 // TODO(vmr): Check for current flush/abort operations.
238 abort_callback_ = callback; 250 abort_callback_ = callback;
239 251
240 return platform_video_decoder_->Abort( 252 return platform_video_decoder_->Abort(
241 callback_factory_.NewCallback( 253 callback_factory_.NewCallback(
242 &PPB_VideoDecoder_Impl::OnAbortComplete)); 254 &PPB_VideoDecoder_Impl::OnAbortComplete));
243 } 255 }
244 256
245 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( 257 void PPB_VideoDecoder_Impl::ProvidePictureBuffers(
246 uint32_t requested_num_of_buffers, 258 uint32 requested_num_of_buffers,
247 const std::vector<uint32_t>& buffer_properties) { 259 gfx::Size dimensions,
248 // TODO(vmr): Implement. 260 media::PictureBuffer::MemoryType type) {
249 NOTIMPLEMENTED(); 261 if (!ppp_videodecoder_)
262 return;
263
264 // TODO(vrk): Compiler assert or use switch statement instead of making
265 // a blind cast.
266 PP_PictureBufferType_Dev out_type =
267 static_cast<PP_PictureBufferType_Dev>(type);
268 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height());
269 ScopedResourceId resource(this);
270 ppp_videodecoder_->ProvidePictureBuffers(
271 resource.id, requested_num_of_buffers, out_dim, out_type);
250 } 272 }
251 273
252 void PPB_VideoDecoder_Impl::PictureReady( 274 void PPB_VideoDecoder_Impl::PictureReady(
253 media::VideoDecodeAccelerator::Picture* picture) { 275 const media::Picture& picture) {
254 // TODO(vmr): Implement. 276 if (!ppp_videodecoder_)
255 NOTIMPLEMENTED(); 277 return;
256 278
257 // Convert the picture. 279 ScopedResourceId resource(this);
258 // Get plugin's PPP interface function pointers. 280 PP_Picture_Dev out_pic;
259 // PPP_VideoDecoder* ppp_videodecoder; 281 CopyToPictureDev(picture, out_pic);
260 // Call ProvidePictureBuffers function pointer and return. 282 ppp_videodecoder_->PictureReady(resource.id, out_pic);
261 // ppp_videodecoder->PictureReady(resource_decoder, picture,
262 // pic_buffer_used_again);
263 } 283 }
264 284
265 void PPB_VideoDecoder_Impl::DismissPictureBuffer( 285 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) {
266 media::VideoDecodeAccelerator::PictureBuffer* picture_buffer) { 286 if (!ppp_videodecoder_)
267 // TODO(vmr): Implement. 287 return;
268 NOTIMPLEMENTED(); 288
289 ScopedResourceId resource(this);
290 ppp_videodecoder_->DismissPictureBuffer(resource.id, picture_buffer_id);
269 } 291 }
270 292
271 void PPB_VideoDecoder_Impl::NotifyEndOfStream() { 293 void PPB_VideoDecoder_Impl::NotifyEndOfStream() {
272 // TODO(vmr): Implement. 294 if (!ppp_videodecoder_)
273 NOTIMPLEMENTED(); 295 return;
274 296
275 // Get decoder's resource handle. 297 ScopedResourceId resource(this);
276 // PP_Resource resource_decoder; 298 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 } 299 }
282 300
283 void PPB_VideoDecoder_Impl::NotifyError( 301 void PPB_VideoDecoder_Impl::NotifyError(
284 media::VideoDecodeAccelerator::Error error) { 302 media::VideoDecodeAccelerator::Error error) {
285 // TODO(vmr): Implement. 303 if (!ppp_videodecoder_)
286 NOTIMPLEMENTED(); 304 return;
287 305
288 // Get decoder's resource handle. 306 ScopedResourceId resource(this);
289 // PP_Resource resource_decoder; 307 // TODO(vrk): This is assuming VideoDecodeAccelerator::Error and
290 // Get plugin's PPP interface function pointers. 308 // PP_VideoDecodeError_Dev have identical enum values. There is no compiler
291 // PPP_VideoDecoder* ppp_videodecoder; 309 // assert to guarantee this. We either need to add such asserts or
292 // Call NotifyError function pointer. 310 // merge these two enums.
293 // ppp_videodecoder->NotifyError(error, error_data, data_size); 311 ppp_videodecoder_->NotifyError(resource.id,
312 static_cast<PP_VideoDecodeError_Dev>(error));
313 }
314
315 bool PPB_VideoDecoder_Impl::CopyToMediaPictureBuffer(
316 const PP_PictureBuffer_Dev& input, media::PictureBuffer& output) {
317 media::PictureBuffer::Data out_data;
318 media::PictureBuffer::MemoryType memory_type;
319 switch (input.storage_type) {
320 case PP_PICTUREBUFFERTYPE_SYSTEM: {
321 memory_type = media::PictureBuffer::PICTUREBUFFER_MEMORYTYPE_SYSTEM;
322 scoped_refptr<PPB_Buffer_Impl> pepper_buffer =
323 Resource::GetAs<PPB_Buffer_Impl>(input.data.sysmem);
324 assert(pepper_buffer->is_mapped());
325 out_data.sysmem = static_cast<void*>(pepper_buffer->mapped_buffer());
326 break;
327 }
328 case PP_PICTUREBUFFERTYPE_GLESTEXTURE: {
329 memory_type = media::PictureBuffer::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE;
330 out_data.gles2_texture.texture_id =
331 input.data.gles2_texture.texture_id;
332 out_data.gles2_texture.context_id =
333 input.data.gles2_texture.context_id;
334 break;
335 }
336 case PP_PICTUREBUFFERTYPE_NONE: {
337 NOTREACHED();
338 return false;
339 }
340 }
341 gfx::Size dimensions(input.dimensions.width, input.dimensions.height);
342 output.Initialize(input.id, memory_type, dimensions, out_data);
343 return true;
344 }
345
346 bool PPB_VideoDecoder_Impl::CopyToMediaPicture(
347 const PP_Picture_Dev& input, media::Picture& output) {
348 gfx::Size visible_size(input.visible_size.width, input.visible_size.height);
349 gfx::Size decoded_size(input.decoded_size.width, input.decoded_size.height);
350 output.Initialize(input.picture_buffer_id, decoded_size,
351 visible_size, input.bitstream_user_handle);
352 return true;
353 }
354
355 bool PPB_VideoDecoder_Impl::CopyToPictureDev(
356 const media::Picture& input, PP_Picture_Dev& output) {
357 output.picture_buffer_id = input.GetId();
358 output.bitstream_user_handle = input.GetUserHandle();
359 output.visible_size =
360 PP_MakeSize(input.GetVisibleSize().width(),
361 input.GetVisibleSize().height());
362 output.decoded_size =
363 PP_MakeSize(input.GetDecodedSize().width(),
364 input.GetDecodedSize().height());
365 return true;
366 }
367
368 bool PPB_VideoDecoder_Impl::CopyToConfigList(
369 const PP_VideoConfigElement* configs, std::vector<uint32>& output) {
370 // TODO(vrk): This is assuming PP_VideoAttributeDictionary and
371 // VideoAttributeKey have identical enum values. There is no compiler
372 // assert to guarantee this. We either need to add such asserts or
373 // merge PP_VideoAttributeDictionary and VideoAttributeKey.
374 const PP_VideoConfigElement* current = configs;
375 while (*current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) {
376 output.push_back(static_cast<uint32>(*configs));
377 current++;
378 }
379 return true;
294 } 380 }
295 381
296 void PPB_VideoDecoder_Impl::OnAbortComplete() { 382 void PPB_VideoDecoder_Impl::OnAbortComplete() {
297 if (abort_callback_.func == NULL) 383 if (abort_callback_.func == NULL)
298 return; 384 return;
299 385
300 // Call the callback that was stored to be called when Abort is done. 386 // Call the callback that was stored to be called when Abort is done.
301 PP_CompletionCallback callback = PP_BlockUntilComplete(); 387 PP_CompletionCallback callback = PP_BlockUntilComplete();
302 std::swap(callback, abort_callback_); 388 std::swap(callback, abort_callback_);
303 PP_RunCompletionCallback(&callback, PP_OK); 389 PP_RunCompletionCallback(&callback, PP_OK);
(...skipping 15 matching lines...) Expand all
319 return; 405 return;
320 406
321 // Call the callback that was stored to be called when Flush is done. 407 // Call the callback that was stored to be called when Flush is done.
322 PP_CompletionCallback callback = PP_BlockUntilComplete(); 408 PP_CompletionCallback callback = PP_BlockUntilComplete();
323 std::swap(callback, flush_callback_); 409 std::swap(callback, flush_callback_);
324 PP_RunCompletionCallback(&callback, PP_OK); 410 PP_RunCompletionCallback(&callback, PP_OK);
325 } 411 }
326 412
327 } // namespace ppapi 413 } // namespace ppapi
328 } // namespace webkit 414 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698