OLD | NEW |
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 "media/video/picture.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 37 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
38 new PPB_VideoDecoder_Impl(instance)); | 38 new PPB_VideoDecoder_Impl(instance)); |
39 | 39 |
40 return BoolToPPBool(decoder->GetConfigs(proto_config, | 40 return BoolToPPBool(decoder->GetConfigs(proto_config, |
41 matching_configs, | 41 matching_configs, |
42 matching_configs_size, | 42 matching_configs_size, |
43 num_of_matching_configs)); | 43 num_of_matching_configs)); |
44 } | 44 } |
45 | 45 |
46 PP_Resource Create(PP_Instance instance_id, | 46 PP_Resource Create(PP_Instance instance_id, |
47 PP_VideoConfigElement* decoder_config) { | 47 PP_VideoConfigElement* decoder_config, |
| 48 PP_CompletionCallback callback) { |
48 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 49 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
49 if (!instance) | 50 if (!instance) |
50 return 0; | 51 return 0; |
51 | 52 |
52 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 53 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
53 new PPB_VideoDecoder_Impl(instance)); | 54 new PPB_VideoDecoder_Impl(instance)); |
54 | 55 |
55 if (!decoder->Init(const_cast<PP_VideoConfigElement*>(decoder_config))) | 56 if (!decoder->Init( |
| 57 const_cast<PP_VideoConfigElement*>(decoder_config), callback)) { |
56 return 0; | 58 return 0; |
| 59 } |
57 | 60 |
58 return decoder->GetReference(); | 61 return decoder->GetReference(); |
59 } | 62 } |
60 | 63 |
61 PP_Bool IsVideoDecoder(PP_Resource resource) { | 64 PP_Bool IsVideoDecoder(PP_Resource resource) { |
62 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); | 65 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); |
63 } | 66 } |
64 | 67 |
65 PP_Bool Decode(PP_Resource decoder_id, | 68 PP_Bool Decode(PP_Resource decoder_id, |
66 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 69 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 platform_video_decoder_->GetConfigs(requested, &matched); | 208 platform_video_decoder_->GetConfigs(requested, &matched); |
206 | 209 |
207 uint32 i; | 210 uint32 i; |
208 for (i = 0; i < matched.size() && i < matching_configs_size; i++) | 211 for (i = 0; i < matched.size() && i < matching_configs_size; i++) |
209 matching_configs[i] = matched[i]; | 212 matching_configs[i] = matched[i]; |
210 *num_of_matching_configs = i; | 213 *num_of_matching_configs = i; |
211 | 214 |
212 return true; | 215 return true; |
213 } | 216 } |
214 | 217 |
215 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config) { | 218 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config, |
| 219 PP_CompletionCallback callback) { |
216 if (!instance()) | 220 if (!instance()) |
217 return false; | 221 return false; |
218 | 222 |
219 platform_video_decoder_.reset( | 223 platform_video_decoder_.reset( |
220 instance()->delegate()->CreateVideoDecoder(this)); | 224 instance()->delegate()->CreateVideoDecoder(this)); |
221 | 225 |
222 std::vector<uint32> copied; | 226 std::vector<uint32> copied; |
223 // TODO(vrk): Validate configs before copy. | 227 // TODO(vrk): Validate configs before copy. |
224 CopyToConfigList(decoder_config, &copied); | 228 CopyToConfigList(decoder_config, &copied); |
225 platform_video_decoder_->Initialize(copied); | 229 platform_video_decoder_->Initialize(copied); |
226 | 230 |
| 231 initialization_callback_ = callback; |
| 232 |
227 return platform_video_decoder_.get()? true : false; | 233 return platform_video_decoder_.get()? true : false; |
228 } | 234 } |
229 | 235 |
230 bool PPB_VideoDecoder_Impl::Decode( | 236 bool PPB_VideoDecoder_Impl::Decode( |
231 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 237 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
232 PP_CompletionCallback callback) { | 238 PP_CompletionCallback callback) { |
233 if (!platform_video_decoder_.get()) | 239 if (!platform_video_decoder_.get()) |
234 return false; | 240 return false; |
235 | 241 |
236 media::BitstreamBuffer decode_buffer( | 242 media::BitstreamBuffer decode_buffer( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 391 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
386 if (flush_callback_.func == NULL) | 392 if (flush_callback_.func == NULL) |
387 return; | 393 return; |
388 | 394 |
389 // Call the callback that was stored to be called when Flush is done. | 395 // Call the callback that was stored to be called when Flush is done. |
390 PP_CompletionCallback callback = PP_BlockUntilComplete(); | 396 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
391 std::swap(callback, flush_callback_); | 397 std::swap(callback, flush_callback_); |
392 PP_RunCompletionCallback(&callback, PP_OK); | 398 PP_RunCompletionCallback(&callback, PP_OK); |
393 } | 399 } |
394 | 400 |
| 401 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 402 if (initialization_callback_.func == NULL) |
| 403 return; |
| 404 |
| 405 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 406 std::swap(callback, initialization_callback_); |
| 407 PP_RunCompletionCallback(&callback, PP_OK); |
| 408 } |
| 409 |
395 } // namespace ppapi | 410 } // namespace ppapi |
396 } // namespace webkit | 411 } // namespace webkit |
397 | 412 |
398 // These functions are declared in picture.h but are defined here because of | 413 // These functions are declared in picture.h but are defined here because of |
399 // dependencies (we can't depend on ppapi types from media). | 414 // dependencies (we can't depend on ppapi types from media). |
400 namespace media { | 415 namespace media { |
401 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info) | 416 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info) |
402 : id_(info.id), | 417 : id_(info.id), |
403 size_(info.size.width, info.size.height) { | 418 size_(info.size.width, info.size.height) { |
404 } | 419 } |
(...skipping 16 matching lines...) Expand all Loading... |
421 } | 436 } |
422 | 437 |
423 Picture::Picture(const PP_Picture_Dev& picture) | 438 Picture::Picture(const PP_Picture_Dev& picture) |
424 : picture_buffer_id_(picture.picture_buffer_id), | 439 : picture_buffer_id_(picture.picture_buffer_id), |
425 bitstream_buffer_id_(picture.bitstream_buffer_id), | 440 bitstream_buffer_id_(picture.bitstream_buffer_id), |
426 visible_size_(picture.visible_size.width, picture.visible_size.height), | 441 visible_size_(picture.visible_size.width, picture.visible_size.height), |
427 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | 442 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { |
428 } | 443 } |
429 | 444 |
430 } // namespace media | 445 } // namespace media |
OLD | NEW |