OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cdm/ppapi/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 namespace media { | 205 namespace media { |
206 | 206 |
207 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 207 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
208 : pp::Instance(instance), | 208 : pp::Instance(instance), |
209 pp::ContentDecryptor_Private(this), | 209 pp::ContentDecryptor_Private(this), |
210 allocator_(this), | 210 allocator_(this), |
211 cdm_(NULL) { | 211 cdm_(NULL) { |
212 callback_factory_.Initialize(this); | 212 callback_factory_.Initialize(this); |
213 } | 213 } |
214 | 214 |
215 CdmAdapter::~CdmAdapter() { | 215 CdmAdapter::~CdmAdapter() {} |
216 if (cdm_) | |
217 cdm_->Destroy(); | |
218 } | |
219 | 216 |
220 bool CdmAdapter::CreateCdmInstance(const std::string& key_system) { | 217 bool CdmAdapter::CreateCdmInstance(const std::string& key_system) { |
221 PP_DCHECK(!cdm_); | 218 PP_DCHECK(!cdm_); |
222 cdm_ = static_cast<cdm::ContentDecryptionModule*>( | 219 cdm_ = make_linked_ptr(CdmWrapper::Create( |
223 ::CreateCdmInstance(cdm::kCdmInterfaceVersion, | 220 key_system.data(), key_system.size(), GetCdmHost, this)); |
224 key_system.data(), key_system.size(), | |
225 GetCdmHost, this)); | |
226 | |
227 return (cdm_ != NULL); | 221 return (cdm_ != NULL); |
228 } | 222 } |
229 | 223 |
230 // No KeyErrors should be reported in this function because they cannot be | 224 // No KeyErrors should be reported in this function because they cannot be |
231 // bubbled up in the WD EME API. Those errors will be reported during session | 225 // bubbled up in the WD EME API. Those errors will be reported during session |
232 // creation (aka GenerateKeyRequest). | 226 // creation (aka GenerateKeyRequest). |
233 void CdmAdapter::Initialize(const std::string& key_system, | 227 void CdmAdapter::Initialize(const std::string& key_system, |
234 bool can_challenge_platform) { | 228 bool can_challenge_platform) { |
235 PP_DCHECK(!key_system.empty()); | 229 PP_DCHECK(!key_system.empty()); |
236 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); | 230 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 } // namespace media | 769 } // namespace media |
776 | 770 |
777 namespace pp { | 771 namespace pp { |
778 | 772 |
779 // Factory function for your specialization of the Module object. | 773 // Factory function for your specialization of the Module object. |
780 Module* CreateModule() { | 774 Module* CreateModule() { |
781 return new media::CdmAdapterModule(); | 775 return new media::CdmAdapterModule(); |
782 } | 776 } |
783 | 777 |
784 } // namespace pp | 778 } // namespace pp |
OLD | NEW |