| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // PPB_ContentDecryptor_Private interface. | 371 // PPB_ContentDecryptor_Private interface. |
| 372 virtual void GenerateKeyRequest(const std::string& key_system, | 372 virtual void GenerateKeyRequest(const std::string& key_system, |
| 373 pp::VarArrayBuffer init_data) OVERRIDE; | 373 pp::VarArrayBuffer init_data) OVERRIDE; |
| 374 virtual void AddKey(const std::string& session_id, | 374 virtual void AddKey(const std::string& session_id, |
| 375 pp::VarArrayBuffer key, | 375 pp::VarArrayBuffer key, |
| 376 pp::VarArrayBuffer init_data) OVERRIDE; | 376 pp::VarArrayBuffer init_data) OVERRIDE; |
| 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
| 378 virtual void Decrypt( | 378 virtual void Decrypt( |
| 379 pp::Buffer_Dev encrypted_buffer, | 379 pp::Buffer_Dev encrypted_buffer, |
| 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 381 virtual void ResetVideoDecoder(uint32_t request_id); |
| 382 virtual void StopVideoDecoder(uint32_t request_id); |
| 381 virtual void DecryptAndDecodeFrame( | 383 virtual void DecryptAndDecodeFrame( |
| 382 pp::Buffer_Dev encrypted_frame, | 384 pp::Buffer_Dev encrypted_frame, |
| 383 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; | 385 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; |
| 384 | 386 |
| 385 private: | 387 private: |
| 386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 388 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
| 387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 389 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
| 388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 390 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
| 389 | 391 |
| 390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 392 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
| 391 // <code>callback_factory_</code> to ensure that calls into | 393 // <code>callback_factory_</code> to ensure that calls into |
| 392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 394 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
| 393 void KeyAdded(int32_t result, const std::string& session_id); | 395 void KeyAdded(int32_t result, const std::string& session_id); |
| 394 void KeyMessage(int32_t result, const LinkedKeyMessage& message); | 396 void KeyMessage(int32_t result, const LinkedKeyMessage& message); |
| 395 void KeyError(int32_t result, const std::string& session_id); | 397 void KeyError(int32_t result, const std::string& session_id); |
| 396 void DeliverBlock(int32_t result, | 398 void DeliverBlock(int32_t result, |
| 397 const cdm::Status& status, | 399 const cdm::Status& status, |
| 398 const LinkedDecryptedBlock& decrypted_block, | 400 const LinkedDecryptedBlock& decrypted_block, |
| 399 const PP_DecryptTrackingInfo& tracking_info); | 401 const PP_DecryptTrackingInfo& tracking_info); |
| 402 void DecoderReset(int32_t result, uint32_t request_id); |
| 403 void DecoderStopped(int32_t result, uint32_t request_id); |
| 400 void DeliverFrame(int32_t result, | 404 void DeliverFrame(int32_t result, |
| 401 const cdm::Status& status, | 405 const cdm::Status& status, |
| 402 const LinkedVideoFrame& video_frame, | 406 const LinkedVideoFrame& video_frame, |
| 403 const PP_DecryptTrackingInfo& tracking_info); | 407 const PP_DecryptTrackingInfo& tracking_info); |
| 404 | 408 |
| 405 PpbBufferAllocator allocator_; | 409 PpbBufferAllocator allocator_; |
| 406 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; | 410 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; |
| 407 cdm::ContentDecryptionModule* cdm_; | 411 cdm::ContentDecryptionModule* cdm_; |
| 408 std::string key_system_; | 412 std::string key_system_; |
| 409 }; | 413 }; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); | 527 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); |
| 524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); | 528 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); |
| 525 | 529 |
| 526 CallOnMain(callback_factory_.NewCallback( | 530 CallOnMain(callback_factory_.NewCallback( |
| 527 &CdmWrapper::DeliverBlock, | 531 &CdmWrapper::DeliverBlock, |
| 528 status, | 532 status, |
| 529 decrypted_block, | 533 decrypted_block, |
| 530 encrypted_block_info.tracking_info)); | 534 encrypted_block_info.tracking_info)); |
| 531 } | 535 } |
| 532 | 536 |
| 537 void CdmWrapper::ResetVideoDecoder(uint32_t request_id) { |
| 538 // TODO(tomfinegan): Implement ResetVideoDecoder in clear key CDM, and call |
| 539 // it here. |
| 540 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderReset, |
| 541 request_id)); |
| 542 } |
| 543 |
| 544 void CdmWrapper::StopVideoDecoder(uint32_t request_id) { |
| 545 // TODO(tomfinegan): Implement StopVideoDecoder in clear key CDM, and call it |
| 546 // here. |
| 547 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderStopped, |
| 548 request_id)); |
| 549 } |
| 550 |
| 533 void CdmWrapper::DecryptAndDecodeFrame( | 551 void CdmWrapper::DecryptAndDecodeFrame( |
| 534 pp::Buffer_Dev encrypted_frame, | 552 pp::Buffer_Dev encrypted_frame, |
| 535 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { | 553 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
| 536 PP_DCHECK(!encrypted_frame.is_null()); | 554 PP_DCHECK(!encrypted_frame.is_null()); |
| 537 PP_DCHECK(cdm_); | 555 PP_DCHECK(cdm_); |
| 538 | 556 |
| 539 cdm::InputBuffer input_buffer; | 557 cdm::InputBuffer input_buffer; |
| 540 std::vector<cdm::SubsampleEntry> subsamples; | 558 std::vector<cdm::SubsampleEntry> subsamples; |
| 541 ConfigureInputBuffer(encrypted_frame, | 559 ConfigureInputBuffer(encrypted_frame, |
| 542 encrypted_video_frame_info.encryption_info, | 560 encrypted_video_frame_info.encryption_info, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 } | 618 } |
| 601 | 619 |
| 602 const pp::Buffer_Dev& buffer = | 620 const pp::Buffer_Dev& buffer = |
| 603 decrypted_block.get() && decrypted_block->buffer() ? | 621 decrypted_block.get() && decrypted_block->buffer() ? |
| 604 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : | 622 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : |
| 605 pp::Buffer_Dev(); | 623 pp::Buffer_Dev(); |
| 606 | 624 |
| 607 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); | 625 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
| 608 } | 626 } |
| 609 | 627 |
| 628 void CdmWrapper::DecoderReset(int32_t result, uint32_t request_id) { |
| 629 pp::ContentDecryptor_Private::DecoderReset(request_id); |
| 630 } |
| 631 |
| 632 void CdmWrapper::DecoderStopped(int32_t result, uint32_t request_id) { |
| 633 pp::ContentDecryptor_Private::DecoderStopped(request_id); |
| 634 } |
| 635 |
| 610 void CdmWrapper::DeliverFrame( | 636 void CdmWrapper::DeliverFrame( |
| 611 int32_t result, | 637 int32_t result, |
| 612 const cdm::Status& status, | 638 const cdm::Status& status, |
| 613 const LinkedVideoFrame& video_frame, | 639 const LinkedVideoFrame& video_frame, |
| 614 const PP_DecryptTrackingInfo& tracking_info) { | 640 const PP_DecryptTrackingInfo& tracking_info) { |
| 615 PP_DecryptedFrameInfo decrypted_frame_info; | 641 PP_DecryptedFrameInfo decrypted_frame_info; |
| 616 decrypted_frame_info.tracking_info = tracking_info; | 642 decrypted_frame_info.tracking_info = tracking_info; |
| 617 | 643 |
| 618 switch (status) { | 644 switch (status) { |
| 619 case cdm::kSuccess: | 645 case cdm::kSuccess: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } // namespace webkit_media | 701 } // namespace webkit_media |
| 676 | 702 |
| 677 namespace pp { | 703 namespace pp { |
| 678 | 704 |
| 679 // Factory function for your specialization of the Module object. | 705 // Factory function for your specialization of the Module object. |
| 680 Module* CreateModule() { | 706 Module* CreateModule() { |
| 681 return new webkit_media::CdmWrapperModule(); | 707 return new webkit_media::CdmWrapperModule(); |
| 682 } | 708 } |
| 683 | 709 |
| 684 } // namespace pp | 710 } // namespace pp |
| OLD | NEW |