| 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 <cstring> | 5 #include <cstring> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 class CdmWrapper : public pp::Instance, | 360 class CdmWrapper : public pp::Instance, |
| 361 public pp::ContentDecryptor_Private { | 361 public pp::ContentDecryptor_Private { |
| 362 public: | 362 public: |
| 363 CdmWrapper(PP_Instance instance, pp::Module* module); | 363 CdmWrapper(PP_Instance instance, pp::Module* module); |
| 364 virtual ~CdmWrapper(); | 364 virtual ~CdmWrapper(); |
| 365 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 365 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 366 return true; | 366 return true; |
| 367 } | 367 } |
| 368 | 368 |
| 369 // PPP_ContentDecryptor_Private methods | 369 // PPP_ContentDecryptor_Private methods |
| 370 // Note: As per comments in PPP_ContentDecryptor_Private, these calls should | 370 // Note: Results of calls to these methods must be reported through the |
| 371 // return false if the call was not forwarded to the CDM and should return | 371 // PPB_ContentDecryptor_Private interface. |
| 372 // true otherwise. Once the call reaches the CDM, the call result/status | |
| 373 // should be reported through the PPB_ContentDecryptor_Private interface. | |
| 374 virtual void GenerateKeyRequest(const std::string& key_system, | 372 virtual void GenerateKeyRequest(const std::string& key_system, |
| 375 pp::VarArrayBuffer init_data) OVERRIDE; | 373 pp::VarArrayBuffer init_data) OVERRIDE; |
| 376 virtual void AddKey(const std::string& session_id, | 374 virtual void AddKey(const std::string& session_id, |
| 377 pp::VarArrayBuffer key, | 375 pp::VarArrayBuffer key, |
| 378 pp::VarArrayBuffer init_data) OVERRIDE; | 376 pp::VarArrayBuffer init_data) OVERRIDE; |
| 379 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
| 380 virtual void Decrypt( | 378 virtual void Decrypt( |
| 381 pp::Buffer_Dev encrypted_buffer, | 379 pp::Buffer_Dev encrypted_buffer, |
| 382 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 383 virtual void DecryptAndDecode( | 381 virtual void DecryptAndDecodeFrame( |
| 384 pp::Buffer_Dev encrypted_buffer, | 382 pp::Buffer_Dev encrypted_frame, |
| 385 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 383 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; |
| 386 | 384 |
| 387 private: | 385 private: |
| 388 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
| 389 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
| 390 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
| 391 | 389 |
| 392 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
| 393 // <code>callback_factory_</code> to ensure that calls into | 391 // <code>callback_factory_</code> to ensure that calls into |
| 394 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
| 395 void KeyAdded(int32_t result, const std::string& session_id); | 393 void KeyAdded(int32_t result, const std::string& session_id); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); | 523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); |
| 526 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); | 524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); |
| 527 | 525 |
| 528 CallOnMain(callback_factory_.NewCallback( | 526 CallOnMain(callback_factory_.NewCallback( |
| 529 &CdmWrapper::DeliverBlock, | 527 &CdmWrapper::DeliverBlock, |
| 530 status, | 528 status, |
| 531 decrypted_block, | 529 decrypted_block, |
| 532 encrypted_block_info.tracking_info)); | 530 encrypted_block_info.tracking_info)); |
| 533 } | 531 } |
| 534 | 532 |
| 535 void CdmWrapper::DecryptAndDecode( | 533 void CdmWrapper::DecryptAndDecodeFrame( |
| 536 pp::Buffer_Dev encrypted_buffer, | 534 pp::Buffer_Dev encrypted_frame, |
| 537 const PP_EncryptedBlockInfo& encrypted_block_info) { | 535 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
| 538 PP_DCHECK(!encrypted_buffer.is_null()); | 536 PP_DCHECK(!encrypted_frame.is_null()); |
| 539 PP_DCHECK(cdm_); | 537 PP_DCHECK(cdm_); |
| 540 | 538 |
| 541 cdm::InputBuffer input_buffer; | 539 cdm::InputBuffer input_buffer; |
| 542 std::vector<cdm::SubsampleEntry> subsamples; | 540 std::vector<cdm::SubsampleEntry> subsamples; |
| 543 ConfigureInputBuffer(encrypted_buffer, encrypted_block_info, &subsamples, | 541 ConfigureInputBuffer(encrypted_frame, |
| 542 encrypted_video_frame_info.encryption_info, |
| 543 &subsamples, |
| 544 &input_buffer); | 544 &input_buffer); |
| 545 | 545 |
| 546 LinkedVideoFrame video_frame(new VideoFrameImpl()); | 546 LinkedVideoFrame video_frame(new VideoFrameImpl()); |
| 547 cdm::Status status = cdm_->DecryptAndDecodeVideo(input_buffer, | 547 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
| 548 video_frame.get()); | 548 video_frame.get()); |
| 549 CallOnMain(callback_factory_.NewCallback( | 549 CallOnMain(callback_factory_.NewCallback( |
| 550 &CdmWrapper::DeliverFrame, | 550 &CdmWrapper::DeliverFrame, |
| 551 status, | 551 status, |
| 552 video_frame, | 552 video_frame, |
| 553 encrypted_block_info.tracking_info)); | 553 encrypted_video_frame_info.encryption_info.tracking_info)); |
| 554 } | 554 } |
| 555 | 555 |
| 556 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { | 556 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { |
| 557 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); | 557 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void CdmWrapper::KeyMessage(int32_t result, | 560 void CdmWrapper::KeyMessage(int32_t result, |
| 561 const LinkedKeyMessage& key_message) { | 561 const LinkedKeyMessage& key_message) { |
| 562 pp::Buffer_Dev message_buffer = | 562 pp::Buffer_Dev message_buffer = |
| 563 static_cast<const PpbBuffer*>(key_message->message())->buffer_dev(); | 563 static_cast<const PpbBuffer*>(key_message->message())->buffer_dev(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } // namespace webkit_media | 675 } // namespace webkit_media |
| 676 | 676 |
| 677 namespace pp { | 677 namespace pp { |
| 678 | 678 |
| 679 // Factory function for your specialization of the Module object. | 679 // Factory function for your specialization of the Module object. |
| 680 Module* CreateModule() { | 680 Module* CreateModule() { |
| 681 return new webkit_media::CdmWrapperModule(); | 681 return new webkit_media::CdmWrapperModule(); |
| 682 } | 682 } |
| 683 | 683 |
| 684 } // namespace pp | 684 } // namespace pp |
| OLD | NEW |