| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 scoped_refptr<MediaKeys> MojoCdmService::GetCdm(int cdm_id) { | 75 scoped_refptr<MediaKeys> MojoCdmService::GetCdm(int cdm_id) { |
| 76 DVLOG(1) << __FUNCTION__ << ": " << cdm_id; | 76 DVLOG(1) << __FUNCTION__ << ": " << cdm_id; |
| 77 return g_cdm_manager.Get().GetCdm(cdm_id); | 77 return g_cdm_manager.Get().GetCdm(cdm_id); |
| 78 } | 78 } |
| 79 | 79 |
| 80 MojoCdmService::MojoCdmService( | 80 MojoCdmService::MojoCdmService( |
| 81 base::WeakPtr<MojoCdmServiceContext> context, | 81 base::WeakPtr<MojoCdmServiceContext> context, |
| 82 mojo::ServiceProvider* service_provider, | 82 mojo::ServiceProvider* service_provider, |
| 83 CdmFactory* cdm_factory, | 83 CdmFactory* cdm_factory, |
| 84 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request) | 84 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request) |
| 85 : binding_(this, request.Pass()), | 85 : binding_(this, std::move(request)), |
| 86 context_(context), | 86 context_(context), |
| 87 service_provider_(service_provider), | 87 service_provider_(service_provider), |
| 88 cdm_factory_(cdm_factory), | 88 cdm_factory_(cdm_factory), |
| 89 cdm_id_(CdmContext::kInvalidCdmId), | 89 cdm_id_(CdmContext::kInvalidCdmId), |
| 90 weak_factory_(this) { | 90 weak_factory_(this) { |
| 91 DCHECK(context_); | 91 DCHECK(context_); |
| 92 DCHECK(cdm_factory_); | 92 DCHECK(cdm_factory_); |
| 93 } | 93 } |
| 94 | 94 |
| 95 MojoCdmService::~MojoCdmService() { | 95 MojoCdmService::~MojoCdmService() { |
| 96 g_cdm_manager.Get().UnregisterCdm(cdm_id_); | 96 g_cdm_manager.Get().UnregisterCdm(cdm_id_); |
| 97 | 97 |
| 98 if (cdm_id_ != CdmContext::kInvalidCdmId && context_) | 98 if (cdm_id_ != CdmContext::kInvalidCdmId && context_) |
| 99 context_->UnregisterCdm(cdm_id_); | 99 context_->UnregisterCdm(cdm_id_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void MojoCdmService::SetClient( | 102 void MojoCdmService::SetClient( |
| 103 interfaces::ContentDecryptionModuleClientPtr client) { | 103 interfaces::ContentDecryptionModuleClientPtr client) { |
| 104 client_ = client.Pass(); | 104 client_ = std::move(client); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void MojoCdmService::Initialize(const mojo::String& key_system, | 107 void MojoCdmService::Initialize(const mojo::String& key_system, |
| 108 const mojo::String& security_origin, | 108 const mojo::String& security_origin, |
| 109 interfaces::CdmConfigPtr cdm_config, | 109 interfaces::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(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, | 241 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, |
| 242 bool has_additional_usable_key, | 242 bool has_additional_usable_key, |
| 243 CdmKeysInfo keys_info) { | 243 CdmKeysInfo keys_info) { |
| 244 DVLOG(2) << __FUNCTION__; | 244 DVLOG(2) << __FUNCTION__; |
| 245 | 245 |
| 246 mojo::Array<interfaces::CdmKeyInformationPtr> keys_data; | 246 mojo::Array<interfaces::CdmKeyInformationPtr> keys_data; |
| 247 for (const auto& key : keys_info) | 247 for (const auto& key : keys_info) |
| 248 keys_data.push_back(interfaces::CdmKeyInformation::From(*key)); | 248 keys_data.push_back(interfaces::CdmKeyInformation::From(*key)); |
| 249 client_->OnSessionKeysChange(session_id, has_additional_usable_key, | 249 client_->OnSessionKeysChange(session_id, has_additional_usable_key, |
| 250 keys_data.Pass()); | 250 std::move(keys_data)); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void MojoCdmService::OnSessionExpirationUpdate( | 253 void MojoCdmService::OnSessionExpirationUpdate( |
| 254 const std::string& session_id, | 254 const std::string& session_id, |
| 255 const base::Time& new_expiry_time_sec) { | 255 const base::Time& new_expiry_time_sec) { |
| 256 DVLOG(2) << __FUNCTION__; | 256 DVLOG(2) << __FUNCTION__; |
| 257 client_->OnSessionExpirationUpdate(session_id, | 257 client_->OnSessionExpirationUpdate(session_id, |
| 258 new_expiry_time_sec.ToDoubleT()); | 258 new_expiry_time_sec.ToDoubleT()); |
| 259 } | 259 } |
| 260 | 260 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 275 | 275 |
| 276 void MojoCdmService::OnDecryptorConnectionError() { | 276 void MojoCdmService::OnDecryptorConnectionError() { |
| 277 DVLOG(2) << __FUNCTION__; | 277 DVLOG(2) << __FUNCTION__; |
| 278 | 278 |
| 279 // MojoDecryptorService has lost connectivity to it's client, so it can be | 279 // MojoDecryptorService has lost connectivity to it's client, so it can be |
| 280 // freed. | 280 // freed. |
| 281 decryptor_.reset(); | 281 decryptor_.reset(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace media | 284 } // namespace media |
| OLD | NEW |