| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/mojo/services/mojo_cdm_service.h" | 5 #include "media/mojo/services/mojo_cdm_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "media/base/cdm_key_information.h" | 8 #include "media/base/cdm_key_information.h" |
| 9 #include "media/base/key_systems.h" | 9 #include "media/base/key_systems.h" |
| 10 #include "media/cdm/aes_decryptor.h" | 10 #include "media/cdm/aes_decryptor.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MojoCdmService::SetClient(mojo::ContentDecryptionModuleClientPtr client) { | 42 void MojoCdmService::SetClient(mojo::ContentDecryptionModuleClientPtr client) { |
| 43 client_ = client.Pass(); | 43 client_ = client.Pass(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // mojo::MediaRenderer implementation. | 46 // mojo::MediaRenderer implementation. |
| 47 void MojoCdmService::SetServerCertificate( | 47 void MojoCdmService::SetServerCertificate( |
| 48 mojo::Array<uint8_t> certificate_data, | 48 mojo::Array<uint8_t> certificate_data, |
| 49 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { | 49 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { |
| 50 const std::vector<uint8_t>& certificate_data_vector = | |
| 51 certificate_data.storage(); | |
| 52 cdm_->SetServerCertificate( | 50 cdm_->SetServerCertificate( |
| 53 certificate_data_vector.empty() ? nullptr : &certificate_data_vector[0], | 51 certificate_data.storage(), |
| 54 certificate_data_vector.size(), | |
| 55 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); | 52 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); |
| 56 } | 53 } |
| 57 | 54 |
| 58 void MojoCdmService::CreateSessionAndGenerateRequest( | 55 void MojoCdmService::CreateSessionAndGenerateRequest( |
| 59 mojo::ContentDecryptionModule::SessionType session_type, | 56 mojo::ContentDecryptionModule::SessionType session_type, |
| 60 mojo::ContentDecryptionModule::InitDataType init_data_type, | 57 mojo::ContentDecryptionModule::InitDataType init_data_type, |
| 61 mojo::Array<uint8_t> init_data, | 58 mojo::Array<uint8_t> init_data, |
| 62 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>& | 59 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>& |
| 63 callback) { | 60 callback) { |
| 64 const std::vector<uint8_t>& init_data_vector = init_data.storage(); | |
| 65 cdm_->CreateSessionAndGenerateRequest( | 61 cdm_->CreateSessionAndGenerateRequest( |
| 66 static_cast<MediaKeys::SessionType>(session_type), | 62 static_cast<MediaKeys::SessionType>(session_type), |
| 67 static_cast<EmeInitDataType>(init_data_type), | 63 static_cast<EmeInitDataType>(init_data_type), init_data.storage(), |
| 68 init_data_vector.empty() ? nullptr : &init_data_vector[0], | |
| 69 init_data_vector.size(), | |
| 70 scoped_ptr<NewSessionCdmPromise>(new NewSessionMojoCdmPromise(callback))); | 64 scoped_ptr<NewSessionCdmPromise>(new NewSessionMojoCdmPromise(callback))); |
| 71 } | 65 } |
| 72 | 66 |
| 73 void MojoCdmService::LoadSession( | 67 void MojoCdmService::LoadSession( |
| 74 mojo::ContentDecryptionModule::SessionType session_type, | 68 mojo::ContentDecryptionModule::SessionType session_type, |
| 75 const mojo::String& session_id, | 69 const mojo::String& session_id, |
| 76 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>& | 70 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>& |
| 77 callback) { | 71 callback) { |
| 78 cdm_->LoadSession( | 72 cdm_->LoadSession( |
| 79 static_cast<MediaKeys::SessionType>(session_type), | 73 static_cast<MediaKeys::SessionType>(session_type), |
| 80 session_id.To<std::string>(), | 74 session_id.To<std::string>(), |
| 81 scoped_ptr<NewSessionCdmPromise>(new NewSessionMojoCdmPromise(callback))); | 75 scoped_ptr<NewSessionCdmPromise>(new NewSessionMojoCdmPromise(callback))); |
| 82 } | 76 } |
| 83 | 77 |
| 84 void MojoCdmService::UpdateSession( | 78 void MojoCdmService::UpdateSession( |
| 85 const mojo::String& session_id, | 79 const mojo::String& session_id, |
| 86 mojo::Array<uint8_t> response, | 80 mojo::Array<uint8_t> response, |
| 87 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { | 81 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { |
| 88 const std::vector<uint8_t>& response_vector = response.storage(); | |
| 89 cdm_->UpdateSession( | 82 cdm_->UpdateSession( |
| 90 session_id.To<std::string>(), | 83 session_id.To<std::string>(), response.storage(), |
| 91 response_vector.empty() ? nullptr : &response_vector[0], | |
| 92 response_vector.size(), | |
| 93 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); | 84 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); |
| 94 } | 85 } |
| 95 | 86 |
| 96 void MojoCdmService::CloseSession( | 87 void MojoCdmService::CloseSession( |
| 97 const mojo::String& session_id, | 88 const mojo::String& session_id, |
| 98 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { | 89 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) { |
| 99 cdm_->CloseSession( | 90 cdm_->CloseSession( |
| 100 session_id.To<std::string>(), | 91 session_id.To<std::string>(), |
| 101 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); | 92 scoped_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); |
| 102 } | 93 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void MojoCdmService::OnLegacySessionError(const std::string& session_id, | 140 void MojoCdmService::OnLegacySessionError(const std::string& session_id, |
| 150 MediaKeys::Exception exception, | 141 MediaKeys::Exception exception, |
| 151 uint32_t system_code, | 142 uint32_t system_code, |
| 152 const std::string& error_message) { | 143 const std::string& error_message) { |
| 153 client_->OnLegacySessionError(session_id, | 144 client_->OnLegacySessionError(session_id, |
| 154 static_cast<mojo::CdmException>(exception), | 145 static_cast<mojo::CdmException>(exception), |
| 155 system_code, error_message); | 146 system_code, error_message); |
| 156 } | 147 } |
| 157 | 148 |
| 158 } // namespace media | 149 } // namespace media |
| OLD | NEW |