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 <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 mojom::CdmConfigPtr cdm_config, | 109 mojom::CdmConfigPtr cdm_config, |
110 const InitializeCallback& callback) { | 110 const InitializeCallback& callback) { |
111 DVLOG(1) << __FUNCTION__ << ": " << key_system; | 111 DVLOG(1) << __FUNCTION__ << ": " << key_system; |
112 DCHECK(!cdm_); | 112 DCHECK(!cdm_); |
113 | 113 |
114 auto weak_this = weak_factory_.GetWeakPtr(); | 114 auto weak_this = weak_factory_.GetWeakPtr(); |
115 cdm_factory_->Create( | 115 cdm_factory_->Create( |
116 key_system, GURL(security_origin.get()), cdm_config.To<CdmConfig>(), | 116 key_system, GURL(security_origin.get()), cdm_config.To<CdmConfig>(), |
117 base::Bind(&MojoCdmService::OnSessionMessage, weak_this), | 117 base::Bind(&MojoCdmService::OnSessionMessage, weak_this), |
118 base::Bind(&MojoCdmService::OnSessionClosed, weak_this), | 118 base::Bind(&MojoCdmService::OnSessionClosed, weak_this), |
119 base::Bind(&MojoCdmService::OnLegacySessionError, weak_this), | |
120 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this), | 119 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this), |
121 base::Bind(&MojoCdmService::OnSessionExpirationUpdate, weak_this), | 120 base::Bind(&MojoCdmService::OnSessionExpirationUpdate, weak_this), |
122 base::Bind(&MojoCdmService::OnCdmCreated, weak_this, callback)); | 121 base::Bind(&MojoCdmService::OnCdmCreated, weak_this, callback)); |
123 } | 122 } |
124 | 123 |
125 void MojoCdmService::SetServerCertificate( | 124 void MojoCdmService::SetServerCertificate( |
126 mojo::Array<uint8_t> certificate_data, | 125 mojo::Array<uint8_t> certificate_data, |
127 const SetServerCertificateCallback& callback) { | 126 const SetServerCertificateCallback& callback) { |
128 DVLOG(2) << __FUNCTION__; | 127 DVLOG(2) << __FUNCTION__; |
129 cdm_->SetServerCertificate( | 128 cdm_->SetServerCertificate( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 214 } |
216 | 215 |
217 DVLOG(1) << __FUNCTION__ << ": CDM successfully created with ID " << cdm_id_; | 216 DVLOG(1) << __FUNCTION__ << ": CDM successfully created with ID " << cdm_id_; |
218 cdm_promise_result->success = true; | 217 cdm_promise_result->success = true; |
219 callback.Run(std::move(cdm_promise_result), cdm_id_, | 218 callback.Run(std::move(cdm_promise_result), cdm_id_, |
220 std::move(decryptor_service)); | 219 std::move(decryptor_service)); |
221 } | 220 } |
222 | 221 |
223 void MojoCdmService::OnSessionMessage(const std::string& session_id, | 222 void MojoCdmService::OnSessionMessage(const std::string& session_id, |
224 MediaKeys::MessageType message_type, | 223 MediaKeys::MessageType message_type, |
225 const std::vector<uint8_t>& message, | 224 const std::vector<uint8_t>& message) { |
226 const GURL& legacy_destination_url) { | |
227 DVLOG(2) << __FUNCTION__ << "(" << message_type << ")"; | 225 DVLOG(2) << __FUNCTION__ << "(" << message_type << ")"; |
228 client_->OnSessionMessage( | 226 client_->OnSessionMessage(session_id, |
229 session_id, static_cast<mojom::CdmMessageType>(message_type), | 227 static_cast<mojom::CdmMessageType>(message_type), |
230 mojo::Array<uint8_t>::From(message), legacy_destination_url); | 228 mojo::Array<uint8_t>::From(message)); |
231 } | 229 } |
232 | 230 |
233 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, | 231 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, |
234 bool has_additional_usable_key, | 232 bool has_additional_usable_key, |
235 CdmKeysInfo keys_info) { | 233 CdmKeysInfo keys_info) { |
236 DVLOG(2) << __FUNCTION__ | 234 DVLOG(2) << __FUNCTION__ |
237 << " has_additional_usable_key=" << has_additional_usable_key; | 235 << " has_additional_usable_key=" << has_additional_usable_key; |
238 | 236 |
239 mojo::Array<mojom::CdmKeyInformationPtr> keys_data; | 237 mojo::Array<mojom::CdmKeyInformationPtr> keys_data; |
240 for (auto* key : keys_info) | 238 for (auto* key : keys_info) |
241 keys_data.push_back(mojom::CdmKeyInformation::From(*key)); | 239 keys_data.push_back(mojom::CdmKeyInformation::From(*key)); |
242 client_->OnSessionKeysChange(session_id, has_additional_usable_key, | 240 client_->OnSessionKeysChange(session_id, has_additional_usable_key, |
243 std::move(keys_data)); | 241 std::move(keys_data)); |
244 } | 242 } |
245 | 243 |
246 void MojoCdmService::OnSessionExpirationUpdate( | 244 void MojoCdmService::OnSessionExpirationUpdate( |
247 const std::string& session_id, | 245 const std::string& session_id, |
248 const base::Time& new_expiry_time_sec) { | 246 const base::Time& new_expiry_time_sec) { |
249 DVLOG(2) << __FUNCTION__ << " expiry=" << new_expiry_time_sec; | 247 DVLOG(2) << __FUNCTION__ << " expiry=" << new_expiry_time_sec; |
250 client_->OnSessionExpirationUpdate(session_id, | 248 client_->OnSessionExpirationUpdate(session_id, |
251 new_expiry_time_sec.ToDoubleT()); | 249 new_expiry_time_sec.ToDoubleT()); |
252 } | 250 } |
253 | 251 |
254 void MojoCdmService::OnSessionClosed(const std::string& session_id) { | 252 void MojoCdmService::OnSessionClosed(const std::string& session_id) { |
255 DVLOG(2) << __FUNCTION__; | 253 DVLOG(2) << __FUNCTION__; |
256 client_->OnSessionClosed(session_id); | 254 client_->OnSessionClosed(session_id); |
257 } | 255 } |
258 | 256 |
259 void MojoCdmService::OnLegacySessionError(const std::string& session_id, | |
260 MediaKeys::Exception exception, | |
261 uint32_t system_code, | |
262 const std::string& error_message) { | |
263 DVLOG(2) << __FUNCTION__ << "(" << exception << ") " << error_message; | |
264 client_->OnLegacySessionError(session_id, | |
265 static_cast<mojom::CdmException>(exception), | |
266 system_code, error_message); | |
267 } | |
268 | |
269 void MojoCdmService::OnDecryptorConnectionError() { | 257 void MojoCdmService::OnDecryptorConnectionError() { |
270 DVLOG(2) << __FUNCTION__; | 258 DVLOG(2) << __FUNCTION__; |
271 | 259 |
272 // MojoDecryptorService has lost connectivity to it's client, so it can be | 260 // MojoDecryptorService has lost connectivity to it's client, so it can be |
273 // freed. | 261 // freed. |
274 decryptor_.reset(); | 262 decryptor_.reset(); |
275 } | 263 } |
276 | 264 |
277 } // namespace media | 265 } // namespace media |
OLD | NEW |