| 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" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { | 335 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { |
| 336 if (array_size < str.size()) | 336 if (array_size < str.size()) |
| 337 return false; | 337 return false; |
| 338 | 338 |
| 339 memcpy(array, str.data(), str.size()); | 339 memcpy(array, str.data(), str.size()); |
| 340 return true; | 340 return true; |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Fills the |block_info| with information from |decrypt_config|, |timestamp| | 343 // Fills the |block_info| with information from |decrypt_config|, |timestamp| |
| 344 // and |request_id|. | 344 // and |request_id|. |
| 345 // Returns true if |block_info| is successfully filled. Returns false otherwise. | 345 // Returns true if |block_info| is successfully filled. Returns false |
| 346 // otherwise. |
| 347 // Note: This function does not require that data is encrypted. |
| 346 bool MakeEncryptedBlockInfo( | 348 bool MakeEncryptedBlockInfo( |
| 347 const media::DecryptConfig& decrypt_config, | 349 const media::DecryptConfig& decrypt_config, |
| 348 int64_t timestamp, | 350 int64_t timestamp, |
| 349 uint32_t request_id, | 351 uint32_t request_id, |
| 350 PP_EncryptedBlockInfo* block_info) { | 352 PP_EncryptedBlockInfo* block_info) { |
| 351 DCHECK(block_info); | 353 DCHECK(block_info); |
| 352 | 354 |
| 353 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and | 355 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and |
| 354 // anywhere else. | 356 // anywhere else. |
| 355 memset(block_info, 0, sizeof(*block_info)); | 357 memset(block_info, 0, sizeof(*block_info)); |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 | 1539 |
| 1538 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); | 1540 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1539 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); | 1541 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1540 | 1542 |
| 1541 plugin_decryption_interface_->Decrypt(pp_instance(), | 1543 plugin_decryption_interface_->Decrypt(pp_instance(), |
| 1542 encrypted_resource, | 1544 encrypted_resource, |
| 1543 &block_info); | 1545 &block_info); |
| 1544 return true; | 1546 return true; |
| 1545 } | 1547 } |
| 1546 | 1548 |
| 1547 bool PluginInstance::DecryptAndDecode( | 1549 bool PluginInstance::DecryptAndDecodeFrame( |
| 1548 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 1550 const scoped_refptr<media::DecoderBuffer>& encrypted_frame, |
| 1549 const media::Decryptor::DecryptCB& decrypt_cb) { | 1551 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1550 if (!LoadContentDecryptorInterface()) | 1552 if (!LoadContentDecryptorInterface()) |
| 1551 return false; | 1553 return false; |
| 1552 | 1554 |
| 1553 ScopedPPResource encrypted_resource(MakeBufferResource( | 1555 ScopedPPResource encrypted_resource(MakeBufferResource( |
| 1554 pp_instance(), | 1556 pp_instance(), |
| 1555 encrypted_buffer->GetData(), | 1557 encrypted_frame->GetData(), |
| 1556 encrypted_buffer->GetDataSize())); | 1558 encrypted_frame->GetDataSize())); |
| 1557 if (!encrypted_resource.get()) | 1559 if (!encrypted_resource.get()) |
| 1558 return false; | 1560 return false; |
| 1559 | 1561 |
| 1560 PP_EncryptedBlockInfo block_info; | 1562 const uint32_t request_id = next_decryption_request_id_++; |
| 1561 | 1563 |
| 1562 // TODO(tomfinegan): Store callback and ID in a map, and pass ID to decryptor. | 1564 // TODO(tomfinegan): Need to get the video format information here somehow. |
| 1563 plugin_decryption_interface_->DecryptAndDecode(pp_instance(), | 1565 PP_EncryptedVideoFrameInfo frame_info; |
| 1564 encrypted_resource, | 1566 frame_info.width = 0; |
| 1565 &block_info); | 1567 frame_info.height = 0; |
| 1568 frame_info.format = PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; |
| 1569 frame_info.codec = PP_VIDEOCODEC_UNKNOWN; |
| 1570 |
| 1571 DCHECK(encrypted_frame->GetDecryptConfig()); |
| 1572 if (!MakeEncryptedBlockInfo(*encrypted_frame->GetDecryptConfig(), |
| 1573 encrypted_frame->GetTimestamp().InMicroseconds(), |
| 1574 request_id, |
| 1575 &frame_info.encryption_info)) { |
| 1576 return false; |
| 1577 } |
| 1578 |
| 1579 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); |
| 1580 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); |
| 1581 |
| 1582 plugin_decryption_interface_->DecryptAndDecodeFrame(pp_instance(), |
| 1583 encrypted_resource, |
| 1584 &frame_info); |
| 1566 return true; | 1585 return true; |
| 1567 } | 1586 } |
| 1568 | 1587 |
| 1569 bool PluginInstance::FlashIsFullscreenOrPending() { | 1588 bool PluginInstance::FlashIsFullscreenOrPending() { |
| 1570 return fullscreen_container_ != NULL; | 1589 return fullscreen_container_ != NULL; |
| 1571 } | 1590 } |
| 1572 | 1591 |
| 1573 bool PluginInstance::IsFullscreenOrPending() { | 1592 bool PluginInstance::IsFullscreenOrPending() { |
| 1574 return desired_fullscreen_state_; | 1593 return desired_fullscreen_state_; |
| 1575 } | 1594 } |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 screen_size_for_fullscreen_ = gfx::Size(); | 2707 screen_size_for_fullscreen_ = gfx::Size(); |
| 2689 WebElement element = container_->element(); | 2708 WebElement element = container_->element(); |
| 2690 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2709 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2691 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2710 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2692 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2711 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2693 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2712 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2694 } | 2713 } |
| 2695 | 2714 |
| 2696 } // namespace ppapi | 2715 } // namespace ppapi |
| 2697 } // namespace webkit | 2716 } // namespace webkit |
| OLD | NEW |