Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_offset_string_conversions.h" | 15 #include "base/utf_offset_string_conversions.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "media/base/decoder_buffer.h" | 17 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/decryptor_client.h" | 18 #include "media/base/decryptor_client.h" |
| 19 #include "media/base/video_decoder_config.h" | |
| 20 #include "media/base/video_frame.h" | |
| 19 #include "ppapi/c/dev/ppb_find_dev.h" | 21 #include "ppapi/c/dev/ppb_find_dev.h" |
| 20 #include "ppapi/c/dev/ppb_zoom_dev.h" | 22 #include "ppapi/c/dev/ppb_zoom_dev.h" |
| 21 #include "ppapi/c/dev/ppp_find_dev.h" | 23 #include "ppapi/c/dev/ppp_find_dev.h" |
| 22 #include "ppapi/c/dev/ppp_selection_dev.h" | 24 #include "ppapi/c/dev/ppp_selection_dev.h" |
| 23 #include "ppapi/c/dev/ppp_text_input_dev.h" | 25 #include "ppapi/c/dev/ppp_text_input_dev.h" |
| 24 #include "ppapi/c/dev/ppp_zoom_dev.h" | 26 #include "ppapi/c/dev/ppp_zoom_dev.h" |
| 25 #include "ppapi/c/pp_rect.h" | 27 #include "ppapi/c/pp_rect.h" |
| 26 #include "ppapi/c/ppb_audio_config.h" | 28 #include "ppapi/c/ppb_audio_config.h" |
| 27 #include "ppapi/c/ppb_core.h" | 29 #include "ppapi/c/ppb_core.h" |
| 28 #include "ppapi/c/ppb_gamepad.h" | 30 #include "ppapi/c/ppb_gamepad.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { | 376 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { |
| 375 block_info->subsamples[i].clear_bytes = | 377 block_info->subsamples[i].clear_bytes = |
| 376 decrypt_config.subsamples()[i].clear_bytes; | 378 decrypt_config.subsamples()[i].clear_bytes; |
| 377 block_info->subsamples[i].cipher_bytes = | 379 block_info->subsamples[i].cipher_bytes = |
| 378 decrypt_config.subsamples()[i].cypher_bytes; | 380 decrypt_config.subsamples()[i].cypher_bytes; |
| 379 } | 381 } |
| 380 | 382 |
| 381 return true; | 383 return true; |
| 382 } | 384 } |
| 383 | 385 |
| 386 PP_VideoCodec MediaVideoCodecToPpVideoCodec(media::VideoCodec codec) { | |
| 387 if (codec == media::kCodecVP8) | |
| 388 return PP_VIDEOCODEC_VP8; | |
| 389 | |
| 390 return PP_VIDEOCODEC_UNKNOWN; | |
| 391 } | |
| 392 | |
| 393 PP_VideoCodecProfile MediaVideoCodecProfileToPpVideoCodecProfile( | |
| 394 media::VideoCodecProfile profile) { | |
| 395 if (profile == media::VP8PROFILE_MAIN) | |
| 396 return PP_VIDEOCODECPROFILE_VP8_MAIN; | |
| 397 | |
| 398 return PP_VIDEOCODECPROFILE_UNKNOWN; | |
| 399 } | |
| 400 | |
| 401 PP_DecryptedFrameFormat MediaVideoFormatToPpDecryptedFrameFormat( | |
| 402 media::VideoFrame::Format format) { | |
| 403 if (format == media::VideoFrame::YV12) | |
| 404 return PP_DECRYPTEDFRAMEFORMAT_YV12; | |
| 405 else if (format == media::VideoFrame::I420) | |
| 406 return PP_DECRYPTEDFRAMEFORMAT_I420; | |
| 407 else if (format == media::VideoFrame::EMPTY) | |
| 408 return PP_DECRYPTEDFRAMEFORMAT_EMPTY; | |
| 409 else | |
|
Ami GONE FROM CHROMIUM
2012/10/09 07:21:12
else is not necessary
Tom Finegan
2012/10/09 19:49:09
Done.
| |
| 410 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; | |
| 411 } | |
| 412 | |
| 384 } // namespace | 413 } // namespace |
| 385 | 414 |
| 386 // static | 415 // static |
| 387 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 416 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
| 388 PluginModule* module) { | 417 PluginModule* module) { |
| 389 base::Callback<const void*(const char*)> get_plugin_interface_func = | 418 base::Callback<const void*(const char*)> get_plugin_interface_func = |
| 390 base::Bind(&PluginModule::GetPluginInterface, module); | 419 base::Bind(&PluginModule::GetPluginInterface, module); |
| 391 PPP_Instance_Combined* ppp_instance_combined = | 420 PPP_Instance_Combined* ppp_instance_combined = |
| 392 PPP_Instance_Combined::Create(get_plugin_interface_func); | 421 PPP_Instance_Combined::Create(get_plugin_interface_func); |
| 393 if (!ppp_instance_combined) | 422 if (!ppp_instance_combined) |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 | 1568 |
| 1540 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); | 1569 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1541 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); | 1570 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1542 | 1571 |
| 1543 plugin_decryption_interface_->Decrypt(pp_instance(), | 1572 plugin_decryption_interface_->Decrypt(pp_instance(), |
| 1544 encrypted_resource, | 1573 encrypted_resource, |
| 1545 &block_info); | 1574 &block_info); |
| 1546 return true; | 1575 return true; |
| 1547 } | 1576 } |
| 1548 | 1577 |
| 1549 // Note: this method can be used with an unencrypted frame. | 1578 bool PluginInstance::InitializeVideoDecoder( |
| 1579 const media::VideoDecoderConfig& decoder_config, | |
| 1580 const media::Decryptor::DecryptCB& decrypt_cb) { | |
| 1581 PP_VideoDecoderConfig pp_decoder_config; | |
| 1582 pp_decoder_config.codec = | |
| 1583 MediaVideoCodecToPpVideoCodec(decoder_config.codec()); | |
| 1584 pp_decoder_config.profile = | |
| 1585 MediaVideoCodecProfileToPpVideoCodecProfile(decoder_config.profile()); | |
| 1586 pp_decoder_config.format = | |
| 1587 MediaVideoFormatToPpDecryptedFrameFormat(decoder_config.format()); | |
| 1588 pp_decoder_config.width = decoder_config.coded_size().width(); | |
| 1589 pp_decoder_config.height = decoder_config.coded_size().height(); | |
| 1590 pp_decoder_config.request_id = next_decryption_request_id_++; | |
| 1591 | |
| 1592 // TODO(xhwang): Use individual variables for decoder init request tracking. | |
| 1593 DCHECK(!ContainsKey(pending_decryption_cbs_, pp_decoder_config.request_id)); | |
| 1594 pending_decryption_cbs_.insert(std::make_pair(pp_decoder_config.request_id, | |
| 1595 decrypt_cb)); | |
| 1596 | |
| 1597 ScopedPPResource extra_data_resource( | |
| 1598 ScopedPPResource::PassRef(), | |
| 1599 MakeBufferResource(pp_instance(), | |
| 1600 decoder_config.extra_data(), | |
| 1601 decoder_config.extra_data_size())); | |
| 1602 | |
| 1603 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance(), | |
| 1604 &pp_decoder_config, | |
| 1605 extra_data_resource); | |
| 1606 return true; | |
| 1607 } | |
| 1608 | |
| 1550 bool PluginInstance::DecryptAndDecodeFrame( | 1609 bool PluginInstance::DecryptAndDecodeFrame( |
| 1551 const scoped_refptr<media::DecoderBuffer>& encrypted_frame, | 1610 const scoped_refptr<media::DecoderBuffer>& encrypted_frame, |
| 1552 const media::Decryptor::DecryptCB& decrypt_cb) { | 1611 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1553 if (!LoadContentDecryptorInterface()) | 1612 if (!LoadContentDecryptorInterface()) |
| 1554 return false; | 1613 return false; |
| 1555 | 1614 |
| 1556 ScopedPPResource encrypted_resource(MakeBufferResource( | 1615 ScopedPPResource encrypted_resource(MakeBufferResource( |
| 1557 pp_instance(), | 1616 pp_instance(), |
| 1558 encrypted_frame->GetData(), | 1617 encrypted_frame->GetData(), |
| 1559 encrypted_frame->GetDataSize())); | 1618 encrypted_frame->GetDataSize())); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2272 } | 2331 } |
| 2273 | 2332 |
| 2274 DCHECK(decryptor_client_); | 2333 DCHECK(decryptor_client_); |
| 2275 decryptor_client_->KeyError( | 2334 decryptor_client_->KeyError( |
| 2276 key_system_string->value(), | 2335 key_system_string->value(), |
| 2277 session_id_string->value(), | 2336 session_id_string->value(), |
| 2278 static_cast<media::Decryptor::KeyError>(media_error), | 2337 static_cast<media::Decryptor::KeyError>(media_error), |
| 2279 system_code); | 2338 system_code); |
| 2280 } | 2339 } |
| 2281 | 2340 |
| 2341 void PluginInstance::DecoderInitialized(PP_Instance instance, | |
| 2342 PP_Bool success, | |
| 2343 uint32_t request_id) { | |
| 2344 // TODO(xhwang): Use individual variables for decoder init request tracking. | |
| 2345 DecryptionCBMap::iterator found = pending_decryption_cbs_.find(request_id); | |
| 2346 if (found == pending_decryption_cbs_.end()) | |
| 2347 return; | |
| 2348 media::Decryptor::DecryptCB decrypt_cb = found->second; | |
| 2349 pending_decryption_cbs_.erase(found); | |
| 2350 | |
| 2351 media::Decryptor::Status status = | |
| 2352 success == PP_TRUE ? media::Decryptor::kSuccess : | |
| 2353 media::Decryptor::kError; | |
| 2354 decrypt_cb.Run(status, NULL); | |
| 2355 } | |
| 2356 | |
| 2282 void PluginInstance::DeliverBlock(PP_Instance instance, | 2357 void PluginInstance::DeliverBlock(PP_Instance instance, |
| 2283 PP_Resource decrypted_block, | 2358 PP_Resource decrypted_block, |
| 2284 const PP_DecryptedBlockInfo* block_info) { | 2359 const PP_DecryptedBlockInfo* block_info) { |
| 2285 DCHECK(block_info); | 2360 DCHECK(block_info); |
| 2286 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | 2361 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2287 block_info->tracking_info.request_id); | 2362 block_info->tracking_info.request_id); |
| 2288 if (found == pending_decryption_cbs_.end()) | 2363 if (found == pending_decryption_cbs_.end()) |
| 2289 return; | 2364 return; |
| 2290 media::Decryptor::DecryptCB decrypt_cb = found->second; | 2365 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2291 pending_decryption_cbs_.erase(found); | 2366 pending_decryption_cbs_.erase(found); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2708 screen_size_for_fullscreen_ = gfx::Size(); | 2783 screen_size_for_fullscreen_ = gfx::Size(); |
| 2709 WebElement element = container_->element(); | 2784 WebElement element = container_->element(); |
| 2710 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2785 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2711 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2786 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2712 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2787 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2713 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2788 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2714 } | 2789 } |
| 2715 | 2790 |
| 2716 } // namespace ppapi | 2791 } // namespace ppapi |
| 2717 } // namespace webkit | 2792 } // namespace webkit |
| OLD | NEW |