Chromium Code Reviews| Index: media/cdm/ppapi/cdm_wrapper.cc |
| diff --git a/media/cdm/ppapi/cdm_wrapper.cc b/media/cdm/ppapi/cdm_wrapper.cc |
| index 6348f1954d0e9b8c30d724e2f6bbce62a1ccb1d9..5256018ecac7b705dff00bccd1929b55c70f7519 100644 |
| --- a/media/cdm/ppapi/cdm_wrapper.cc |
| +++ b/media/cdm/ppapi/cdm_wrapper.cc |
| @@ -498,8 +498,9 @@ class CdmWrapper : public pp::Instance, |
| // PPP_ContentDecryptor_Private implementation. |
| // Note: Results of calls to these methods must be reported through the |
| // PPB_ContentDecryptor_Private interface. |
| - virtual void GenerateKeyRequest(const std::string& key_system, |
| - const std::string& type, |
| + virtual void Initialize(const std::string& key_system, |
| + const PP_KeySystemFlags& key_system_flags) OVERRIDE; |
| + virtual void GenerateKeyRequest(const std::string& type, |
| pp::VarArrayBuffer init_data) OVERRIDE; |
| virtual void AddKey(const std::string& session_id, |
| pp::VarArrayBuffer key, |
| @@ -636,11 +637,25 @@ bool CdmWrapper::CreateCdmInstance(const std::string& key_system) { |
| return (cdm_ != NULL); |
| } |
| -void CdmWrapper::GenerateKeyRequest(const std::string& key_system, |
| - const std::string& type, |
| - pp::VarArrayBuffer init_data) { |
| +void CdmWrapper::Initialize(const std::string& key_system, |
| + const PP_KeySystemFlags& key_system_flags) { |
| PP_DCHECK(!key_system.empty()); |
| - PP_DCHECK(key_system_.empty() || key_system_ == key_system); |
| + PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
| + |
| + if (!cdm_) { |
| + if (!CreateCdmInstance(key_system)) { |
| + // TODO(jrummell): Is UnknownKeyError the correct response? |
| + SendUnknownKeyError(key_system, std::string()); |
| + return; |
| + } |
| + } |
| + PP_DCHECK(cdm_); |
| + key_system_ = key_system; |
| +} |
| + |
| +void CdmWrapper::GenerateKeyRequest(const std::string& type, |
| + pp::VarArrayBuffer init_data) { |
|
DaleCurtis
2013/09/18 21:29:30
dmichael@ pointed out on my cl that every pp::VarA
jrummell
2013/09/19 00:37:28
It fails to compile as Map() is not const.
|
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| #if defined(CHECK_DOCUMENT_URL) |
| PP_URLComponents_Dev url_components = {}; |
| @@ -652,36 +667,17 @@ void CdmWrapper::GenerateKeyRequest(const std::string& key_system, |
| PP_DCHECK(0 < url_components.host.len); |
| #endif // defined(CHECK_DOCUMENT_URL) |
| - if (!cdm_) { |
| - if (!CreateCdmInstance(key_system)) { |
| - SendUnknownKeyError(key_system, std::string()); |
| - return; |
| - } |
| - } |
| - PP_DCHECK(cdm_); |
| - |
| - // Must be set here in case the CDM synchronously calls a cdm::Host method. |
| - // Clear below on error. |
| - // TODO(ddorwin): Set/clear key_system_ & cdm_ at same time; clear both on |
| - // error below. |
| - key_system_ = key_system; |
| cdm::Status status = cdm_->GenerateKeyRequest( |
| type.data(), type.size(), |
| static_cast<const uint8_t*>(init_data.Map()), |
| init_data.ByteLength()); |
| PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); |
| - if (status != cdm::kSuccess) { |
| - key_system_.clear(); // See comment above. |
| - return; |
| - } |
| - |
| - key_system_ = key_system; |
| } |
| void CdmWrapper::AddKey(const std::string& session_id, |
| pp::VarArrayBuffer key, |
| pp::VarArrayBuffer init_data) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| if (!cdm_) { |
| SendUnknownKeyError(key_system_, session_id); |
| return; |
| @@ -711,7 +707,7 @@ void CdmWrapper::AddKey(const std::string& session_id, |
| } |
| void CdmWrapper::CancelKeyRequest(const std::string& session_id) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| if (!cdm_) { |
| SendUnknownKeyError(key_system_, session_id); |
| return; |
| @@ -729,7 +725,7 @@ void CdmWrapper::CancelKeyRequest(const std::string& session_id) { |
| void CdmWrapper::Decrypt(pp::Buffer_Dev encrypted_buffer, |
| const PP_EncryptedBlockInfo& encrypted_block_info) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| PP_DCHECK(!encrypted_buffer.is_null()); |
| // Release a buffer that the caller indicated it is finished with. |
| @@ -759,7 +755,7 @@ void CdmWrapper::Decrypt(pp::Buffer_Dev encrypted_buffer, |
| void CdmWrapper::InitializeAudioDecoder( |
| const PP_AudioDecoderConfig& decoder_config, |
| pp::Buffer_Dev extra_data_buffer) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| cdm::Status status = cdm::kSessionError; |
| if (cdm_) { |
| @@ -786,7 +782,7 @@ void CdmWrapper::InitializeAudioDecoder( |
| void CdmWrapper::InitializeVideoDecoder( |
| const PP_VideoDecoderConfig& decoder_config, |
| pp::Buffer_Dev extra_data_buffer) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| cdm::Status status = cdm::kSessionError; |
| if (cdm_) { |
| @@ -815,7 +811,7 @@ void CdmWrapper::InitializeVideoDecoder( |
| void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| uint32_t request_id) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| if (cdm_) { |
| cdm_->DeinitializeDecoder( |
| PpDecryptorStreamTypeToCdmStreamType(decoder_type)); |
| @@ -829,7 +825,7 @@ void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, |
| uint32_t request_id) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| if (cdm_) |
| cdm_->ResetDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type)); |
| @@ -842,7 +838,7 @@ void CdmWrapper::DecryptAndDecode( |
| PP_DecryptorStreamType decoder_type, |
| pp::Buffer_Dev encrypted_buffer, |
| const PP_EncryptedBlockInfo& encrypted_block_info) { |
| - PP_DCHECK(cdm_); // GenerateKeyRequest() should have succeeded. |
| + PP_DCHECK(cdm_); // Initialize() should have succeeded. |
| // Release a buffer that the caller indicated it is finished with. |
| allocator_.Release(encrypted_block_info.tracking_info.buffer_id); |