| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 // pp::Instance implementation. | 434 // pp::Instance implementation. |
| 435 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 435 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 436 return true; | 436 return true; |
| 437 } | 437 } |
| 438 | 438 |
| 439 // PPP_ContentDecryptor_Private implementation. | 439 // PPP_ContentDecryptor_Private implementation. |
| 440 // Note: Results of calls to these methods must be reported through the | 440 // Note: Results of calls to these methods must be reported through the |
| 441 // PPB_ContentDecryptor_Private interface. | 441 // PPB_ContentDecryptor_Private interface. |
| 442 virtual void GenerateKeyRequest(const std::string& key_system, | 442 virtual void GenerateKeyRequest(const std::string& key_system, |
| 443 const std::string& type, |
| 443 pp::VarArrayBuffer init_data) OVERRIDE; | 444 pp::VarArrayBuffer init_data) OVERRIDE; |
| 444 virtual void AddKey(const std::string& session_id, | 445 virtual void AddKey(const std::string& session_id, |
| 445 pp::VarArrayBuffer key, | 446 pp::VarArrayBuffer key, |
| 446 pp::VarArrayBuffer init_data) OVERRIDE; | 447 pp::VarArrayBuffer init_data) OVERRIDE; |
| 447 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 448 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
| 448 virtual void Decrypt( | 449 virtual void Decrypt( |
| 449 pp::Buffer_Dev encrypted_buffer, | 450 pp::Buffer_Dev encrypted_buffer, |
| 450 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 451 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 451 virtual void InitializeAudioDecoder( | 452 virtual void InitializeAudioDecoder( |
| 452 const PP_AudioDecoderConfig& decoder_config, | 453 const PP_AudioDecoderConfig& decoder_config, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 cdm_(NULL) { | 524 cdm_(NULL) { |
| 524 callback_factory_.Initialize(this); | 525 callback_factory_.Initialize(this); |
| 525 } | 526 } |
| 526 | 527 |
| 527 CdmWrapper::~CdmWrapper() { | 528 CdmWrapper::~CdmWrapper() { |
| 528 if (cdm_) | 529 if (cdm_) |
| 529 DestroyCdmInstance(cdm_); | 530 DestroyCdmInstance(cdm_); |
| 530 } | 531 } |
| 531 | 532 |
| 532 void CdmWrapper::GenerateKeyRequest(const std::string& key_system, | 533 void CdmWrapper::GenerateKeyRequest(const std::string& key_system, |
| 534 const std::string& type, |
| 533 pp::VarArrayBuffer init_data) { | 535 pp::VarArrayBuffer init_data) { |
| 534 PP_DCHECK(!key_system.empty()); | 536 PP_DCHECK(!key_system.empty()); |
| 535 | 537 |
| 536 if (!cdm_) { | 538 if (!cdm_) { |
| 537 cdm_ = CreateCdmInstance(&allocator_, this); | 539 cdm_ = CreateCdmInstance(key_system.data(), key_system.size(), |
| 540 &allocator_, this); |
| 538 PP_DCHECK(cdm_); | 541 PP_DCHECK(cdm_); |
| 539 if (!cdm_) { | 542 if (!cdm_) { |
| 540 FireKeyError(""); | 543 FireKeyError(""); |
| 541 return; | 544 return; |
| 542 } | 545 } |
| 543 } | 546 } |
| 544 | 547 |
| 545 LinkedKeyMessage key_request(new KeyMessageImpl()); | 548 LinkedKeyMessage key_request(new KeyMessageImpl()); |
| 546 cdm::Status status = cdm_->GenerateKeyRequest( | 549 cdm::Status status = cdm_->GenerateKeyRequest( |
| 550 type.data(), type.size(), |
| 547 static_cast<const uint8_t*>(init_data.Map()), | 551 static_cast<const uint8_t*>(init_data.Map()), |
| 548 init_data.ByteLength(), | 552 init_data.ByteLength(), |
| 549 key_request.get()); | 553 key_request.get()); |
| 550 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); | 554 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); |
| 551 if (status != cdm::kSuccess || | 555 if (status != cdm::kSuccess || |
| 552 !key_request->message() || | 556 !key_request->message() || |
| 553 key_request->message()->size() == 0) { | 557 key_request->message()->size() == 0) { |
| 554 FireKeyError(""); | 558 FireKeyError(""); |
| 555 return; | 559 return; |
| 556 } | 560 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } // namespace webkit_media | 979 } // namespace webkit_media |
| 976 | 980 |
| 977 namespace pp { | 981 namespace pp { |
| 978 | 982 |
| 979 // Factory function for your specialization of the Module object. | 983 // Factory function for your specialization of the Module object. |
| 980 Module* CreateModule() { | 984 Module* CreateModule() { |
| 981 return new webkit_media::CdmWrapperModule(); | 985 return new webkit_media::CdmWrapperModule(); |
| 982 } | 986 } |
| 983 | 987 |
| 984 } // namespace pp | 988 } // namespace pp |
| OLD | NEW |