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 switch (codec) { | |
| 388 case media::kCodecVP8: | |
| 389 return PP_VIDEOCODEC_VP8; | |
| 390 | |
| 391 case media::kCodecH264: | |
| 392 case media::kCodecVC1: | |
| 393 case media::kCodecMPEG2: | |
| 394 case media::kCodecMPEG4: | |
| 395 case media::kCodecTheora: | |
|
xhwang
2012/10/08 17:16:13
Why do we need to list them all? Is it because if
Tom Finegan
2012/10/08 23:23:27
Done.
| |
| 396 default: | |
| 397 NOTREACHED(); | |
|
xhwang
2012/10/08 17:16:13
By having NOTREACHED() here, we are assuming that
Tom Finegan
2012/10/08 23:23:27
Removed the NOTREACHED (here and in other conversi
| |
| 398 } | |
| 399 return PP_VIDEOCODEC_UNKNOWN; | |
| 400 } | |
| 401 | |
| 402 PP_VideoCodecProfile MediaVideoCodecProfileToPpVideoCodecProfile( | |
| 403 media::VideoCodecProfile profile) { | |
| 404 switch (profile) { | |
| 405 case media::VP8PROFILE_MAIN: | |
| 406 return PP_VIDEOCODECPROFILE_VP8_MAIN; | |
| 407 | |
| 408 case media::VIDEO_CODEC_PROFILE_UNKNOWN: | |
| 409 case media::H264PROFILE_BASELINE: | |
| 410 case media::H264PROFILE_MAIN: | |
| 411 case media::H264PROFILE_EXTENDED: | |
| 412 case media::H264PROFILE_HIGH: | |
| 413 case media::H264PROFILE_HIGH10PROFILE: | |
| 414 case media::H264PROFILE_HIGH422PROFILE: | |
| 415 case media::H264PROFILE_HIGH444PREDICTIVEPROFILE: | |
| 416 case media::H264PROFILE_SCALABLEBASELINE: | |
| 417 case media::H264PROFILE_SCALABLEHIGH: | |
| 418 case media::H264PROFILE_STEREOHIGH: | |
| 419 case media::H264PROFILE_MULTIVIEWHIGH: | |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
| |
| 420 default: | |
| 421 NOTREACHED(); | |
| 422 } | |
| 423 return PP_VIDEOCODECPROFILE_UNKNOWN; | |
| 424 } | |
| 425 | |
| 426 PP_DecryptedFrameFormat MediaVideoFormatToPpDecryptedFrameFormat( | |
| 427 media::VideoFrame::Format format) { | |
| 428 switch (format) { | |
| 429 case media::VideoFrame::YV12: | |
| 430 return PP_DECRYPTEDFRAMEFORMAT_YV12; | |
| 431 | |
| 432 case media::VideoFrame::I420: | |
| 433 return PP_DECRYPTEDFRAMEFORMAT_I420; | |
| 434 | |
| 435 case media::VideoFrame::INVALID: | |
| 436 case media::VideoFrame::RGB32: | |
| 437 case media::VideoFrame::YV16: | |
| 438 case media::VideoFrame::EMPTY: | |
| 439 case media::VideoFrame::NATIVE_TEXTURE: | |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
xhwang
2012/10/09 00:49:08
This is not done?
Tom Finegan
2012/10/09 01:12:42
Sorry. Missed it, done now.
| |
| 440 default: | |
| 441 NOTREACHED(); | |
| 442 } | |
| 443 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; | |
| 444 } | |
| 445 | |
| 446 | |
| 384 } // namespace | 447 } // namespace |
| 385 | 448 |
| 386 // static | 449 // static |
| 387 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 450 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
| 388 PluginModule* module) { | 451 PluginModule* module) { |
| 389 base::Callback<const void*(const char*)> get_plugin_interface_func = | 452 base::Callback<const void*(const char*)> get_plugin_interface_func = |
| 390 base::Bind(&PluginModule::GetPluginInterface, module); | 453 base::Bind(&PluginModule::GetPluginInterface, module); |
| 391 PPP_Instance_Combined* ppp_instance_combined = | 454 PPP_Instance_Combined* ppp_instance_combined = |
| 392 PPP_Instance_Combined::Create(get_plugin_interface_func); | 455 PPP_Instance_Combined::Create(get_plugin_interface_func); |
| 393 if (!ppp_instance_combined) | 456 if (!ppp_instance_combined) |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 | 1602 |
| 1540 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); | 1603 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1541 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); | 1604 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1542 | 1605 |
| 1543 plugin_decryption_interface_->Decrypt(pp_instance(), | 1606 plugin_decryption_interface_->Decrypt(pp_instance(), |
| 1544 encrypted_resource, | 1607 encrypted_resource, |
| 1545 &block_info); | 1608 &block_info); |
| 1546 return true; | 1609 return true; |
| 1547 } | 1610 } |
| 1548 | 1611 |
| 1549 // Note: this method can be used with an unencrypted frame. | 1612 bool PluginInstance::InitializeVideoDecoder( |
| 1613 const media::VideoDecoderConfig& decoder_config, | |
| 1614 const media::Decryptor::DecryptCB& decrypt_cb) { | |
| 1615 PP_VideoDecoderConfig pp_decoder_config; | |
| 1616 pp_decoder_config.codec = | |
| 1617 MediaVideoCodecToPpVideoCodec(decoder_config.codec()); | |
|
xhwang
2012/10/08 17:16:13
So here if the codec is invalid (unknown), we are
Tom Finegan
2012/10/08 23:23:27
Done.
| |
| 1618 pp_decoder_config.profile = | |
| 1619 MediaVideoCodecProfileToPpVideoCodecProfile(decoder_config.profile()); | |
| 1620 pp_decoder_config.format = | |
| 1621 MediaVideoFormatToPpDecryptedFrameFormat(decoder_config.format()); | |
| 1622 pp_decoder_config.width = decoder_config.coded_size().width(); | |
| 1623 pp_decoder_config.height = decoder_config.coded_size().height(); | |
| 1624 pp_decoder_config.request_id = next_decryption_request_id_++; | |
| 1625 | |
| 1626 DCHECK(!ContainsKey(pending_decryption_cbs_, pp_decoder_config.request_id)); | |
|
xhwang
2012/10/08 17:16:13
We'll have at most two pending decoder initializat
Tom Finegan
2012/10/08 23:23:27
Added TODO(xhwang).
xhwang
2012/10/09 00:49:08
Thanks!
| |
| 1627 pending_decryption_cbs_.insert(std::make_pair(pp_decoder_config.request_id, | |
| 1628 decrypt_cb)); | |
| 1629 | |
| 1630 ScopedPPResource extra_data_resource( | |
| 1631 ScopedPPResource::PassRef(), | |
| 1632 MakeBufferResource(pp_instance(), | |
| 1633 decoder_config.extra_data(), | |
| 1634 decoder_config.extra_data_size())); | |
| 1635 | |
| 1636 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance(), | |
| 1637 &pp_decoder_config, | |
| 1638 extra_data_resource); | |
| 1639 return false; | |
|
xhwang
2012/10/08 17:16:13
always return false?
Tom Finegan
2012/10/08 23:23:27
Oops! Done.
| |
| 1640 } | |
| 1641 | |
| 1550 bool PluginInstance::DecryptAndDecodeFrame( | 1642 bool PluginInstance::DecryptAndDecodeFrame( |
| 1551 const scoped_refptr<media::DecoderBuffer>& encrypted_frame, | 1643 const scoped_refptr<media::DecoderBuffer>& encrypted_frame, |
| 1552 const media::Decryptor::DecryptCB& decrypt_cb) { | 1644 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1553 if (!LoadContentDecryptorInterface()) | 1645 if (!LoadContentDecryptorInterface()) |
| 1554 return false; | 1646 return false; |
| 1555 | 1647 |
| 1556 ScopedPPResource encrypted_resource(MakeBufferResource( | 1648 ScopedPPResource encrypted_resource(MakeBufferResource( |
| 1557 pp_instance(), | 1649 pp_instance(), |
| 1558 encrypted_frame->GetData(), | 1650 encrypted_frame->GetData(), |
| 1559 encrypted_frame->GetDataSize())); | 1651 encrypted_frame->GetDataSize())); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2272 } | 2364 } |
| 2273 | 2365 |
| 2274 DCHECK(decryptor_client_); | 2366 DCHECK(decryptor_client_); |
| 2275 decryptor_client_->KeyError( | 2367 decryptor_client_->KeyError( |
| 2276 key_system_string->value(), | 2368 key_system_string->value(), |
| 2277 session_id_string->value(), | 2369 session_id_string->value(), |
| 2278 static_cast<media::Decryptor::KeyError>(media_error), | 2370 static_cast<media::Decryptor::KeyError>(media_error), |
| 2279 system_code); | 2371 system_code); |
| 2280 } | 2372 } |
| 2281 | 2373 |
| 2374 void PluginInstance::DecoderInitializeStatus(PP_Instance instance, | |
| 2375 PP_Bool success, | |
| 2376 uint32_t request_id) { | |
| 2377 DecryptionCBMap::iterator found = pending_decryption_cbs_.find(request_id); | |
|
xhwang
2012/10/08 17:16:13
ditto, we'll not use map here and use individual v
Tom Finegan
2012/10/08 23:23:27
Added TODO(xhwang).
| |
| 2378 if (found == pending_decryption_cbs_.end()) | |
| 2379 return; | |
| 2380 media::Decryptor::DecryptCB decrypt_cb = found->second; | |
| 2381 pending_decryption_cbs_.erase(found); | |
| 2382 | |
| 2383 media::Decryptor::Status status = | |
| 2384 success == PP_TRUE ? media::Decryptor::kSuccess : | |
| 2385 media::Decryptor::kError; | |
| 2386 decrypt_cb.Run(status, NULL); | |
| 2387 } | |
| 2388 | |
| 2282 void PluginInstance::DeliverBlock(PP_Instance instance, | 2389 void PluginInstance::DeliverBlock(PP_Instance instance, |
| 2283 PP_Resource decrypted_block, | 2390 PP_Resource decrypted_block, |
| 2284 const PP_DecryptedBlockInfo* block_info) { | 2391 const PP_DecryptedBlockInfo* block_info) { |
| 2285 DCHECK(block_info); | 2392 DCHECK(block_info); |
| 2286 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | 2393 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2287 block_info->tracking_info.request_id); | 2394 block_info->tracking_info.request_id); |
| 2288 if (found == pending_decryption_cbs_.end()) | 2395 if (found == pending_decryption_cbs_.end()) |
| 2289 return; | 2396 return; |
| 2290 media::Decryptor::DecryptCB decrypt_cb = found->second; | 2397 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2291 pending_decryption_cbs_.erase(found); | 2398 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(); | 2815 screen_size_for_fullscreen_ = gfx::Size(); |
| 2709 WebElement element = container_->element(); | 2816 WebElement element = container_->element(); |
| 2710 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2817 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2711 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2818 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2712 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2819 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2713 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2820 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2714 } | 2821 } |
| 2715 | 2822 |
| 2716 } // namespace ppapi | 2823 } // namespace ppapi |
| 2717 } // namespace webkit | 2824 } // namespace webkit |
| OLD | NEW |