| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 platform_video_decoder_->GetConfigs(requested, &matched); | 204 platform_video_decoder_->GetConfigs(requested, &matched); |
| 202 | 205 |
| 203 uint32 i; | 206 uint32 i; |
| 204 for (i = 0; i < matched.size() && i < matching_configs_size; i++) | 207 for (i = 0; i < matched.size() && i < matching_configs_size; i++) |
| 205 matching_configs[i] = matched[i]; | 208 matching_configs[i] = matched[i]; |
| 206 *num_of_matching_configs = i; | 209 *num_of_matching_configs = i; |
| 207 | 210 |
| 208 return true; | 211 return true; |
| 209 } | 212 } |
| 210 | 213 |
| 211 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config) { | 214 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config, |
| 215 PP_CompletionCallback callback) { |
| 212 if (!instance()) | 216 if (!instance()) |
| 213 return false; | 217 return false; |
| 214 | 218 |
| 215 platform_video_decoder_.reset( | 219 platform_video_decoder_.reset( |
| 216 instance()->delegate()->CreateVideoDecoder(this)); | 220 instance()->delegate()->CreateVideoDecoder(this)); |
| 217 | 221 |
| 218 std::vector<uint32> copied; | 222 std::vector<uint32> copied; |
| 219 // TODO(vrk): Validate configs before copy. | 223 // TODO(vrk): Validate configs before copy. |
| 220 CopyToConfigList(decoder_config, &copied); | 224 CopyToConfigList(decoder_config, &copied); |
| 221 platform_video_decoder_->Initialize(copied); | 225 platform_video_decoder_->Initialize(copied); |
| 222 | 226 |
| 227 initialization_callback_ = callback; |
| 228 |
| 223 return platform_video_decoder_.get()? true : false; | 229 return platform_video_decoder_.get()? true : false; |
| 224 } | 230 } |
| 225 | 231 |
| 226 bool PPB_VideoDecoder_Impl::Decode( | 232 bool PPB_VideoDecoder_Impl::Decode( |
| 227 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 233 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 228 PP_CompletionCallback callback) { | 234 PP_CompletionCallback callback) { |
| 229 if (!platform_video_decoder_.get()) | 235 if (!platform_video_decoder_.get()) |
| 230 return false; | 236 return false; |
| 231 | 237 |
| 232 media::BitstreamBuffer decode_buffer( | 238 media::BitstreamBuffer decode_buffer( |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 381 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 376 if (flush_callback_.func == NULL) | 382 if (flush_callback_.func == NULL) |
| 377 return; | 383 return; |
| 378 | 384 |
| 379 // Call the callback that was stored to be called when Flush is done. | 385 // Call the callback that was stored to be called when Flush is done. |
| 380 PP_CompletionCallback callback = PP_BlockUntilComplete(); | 386 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 381 std::swap(callback, flush_callback_); | 387 std::swap(callback, flush_callback_); |
| 382 PP_RunCompletionCallback(&callback, PP_OK); | 388 PP_RunCompletionCallback(&callback, PP_OK); |
| 383 } | 389 } |
| 384 | 390 |
| 391 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 392 if (initialization_callback_.func == NULL) |
| 393 return; |
| 394 |
| 395 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 396 std::swap(callback, initialization_callback_); |
| 397 PP_RunCompletionCallback(&callback, PP_OK); |
| 398 } |
| 399 |
| 385 } // namespace ppapi | 400 } // namespace ppapi |
| 386 } // namespace webkit | 401 } // namespace webkit |
| 387 | 402 |
| 388 // These functions are declared in picture.h but are defined here because of | 403 // These functions are declared in picture.h but are defined here because of |
| 389 // dependencies (we can't depend on ppapi types from media). | 404 // dependencies (we can't depend on ppapi types from media). |
| 390 namespace media { | 405 namespace media { |
| 391 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info) | 406 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info) |
| 392 : id_(info.id), | 407 : id_(info.id), |
| 393 size_(info.size.width, info.size.height) { | 408 size_(info.size.width, info.size.height) { |
| 394 } | 409 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 409 assert(pepper_buffer->is_mapped()); | 424 assert(pepper_buffer->is_mapped()); |
| 410 data_ = pepper_buffer->mapped_buffer(); | 425 data_ = pepper_buffer->mapped_buffer(); |
| 411 } | 426 } |
| 412 | 427 |
| 413 Picture::Picture(const PP_Picture_Dev& picture) | 428 Picture::Picture(const PP_Picture_Dev& picture) |
| 414 : picture_buffer_id_(picture.picture_buffer_id), | 429 : picture_buffer_id_(picture.picture_buffer_id), |
| 415 bitstream_buffer_id_(picture.bitstream_buffer_id) { | 430 bitstream_buffer_id_(picture.bitstream_buffer_id) { |
| 416 } | 431 } |
| 417 | 432 |
| 418 } // namespace media | 433 } // namespace media |
| OLD | NEW |