OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_context.h" | 5 #include "media/mojo/services/mojo_cdm_service_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "media/base/media_keys.h" | 9 #include "media/base/content_decryption_module.h" |
10 #include "media/mojo/services/mojo_cdm_service.h" | 10 #include "media/mojo/services/mojo_cdm_service.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 MojoCdmServiceContext::MojoCdmServiceContext() : weak_ptr_factory_(this) {} | 14 MojoCdmServiceContext::MojoCdmServiceContext() : weak_ptr_factory_(this) {} |
15 | 15 |
16 MojoCdmServiceContext::~MojoCdmServiceContext() { | 16 MojoCdmServiceContext::~MojoCdmServiceContext() { |
17 } | 17 } |
18 | 18 |
19 base::WeakPtr<MojoCdmServiceContext> MojoCdmServiceContext::GetWeakPtr() { | 19 base::WeakPtr<MojoCdmServiceContext> MojoCdmServiceContext::GetWeakPtr() { |
20 return weak_ptr_factory_.GetWeakPtr(); | 20 return weak_ptr_factory_.GetWeakPtr(); |
21 } | 21 } |
22 | 22 |
23 void MojoCdmServiceContext::RegisterCdm(int cdm_id, | 23 void MojoCdmServiceContext::RegisterCdm(int cdm_id, |
24 MojoCdmService* cdm_service) { | 24 MojoCdmService* cdm_service) { |
25 DCHECK(!cdm_services_.count(cdm_id)); | 25 DCHECK(!cdm_services_.count(cdm_id)); |
26 DCHECK(cdm_service); | 26 DCHECK(cdm_service); |
27 cdm_services_[cdm_id] = cdm_service; | 27 cdm_services_[cdm_id] = cdm_service; |
28 } | 28 } |
29 | 29 |
30 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) { | 30 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) { |
31 DCHECK(cdm_services_.count(cdm_id)); | 31 DCHECK(cdm_services_.count(cdm_id)); |
32 cdm_services_.erase(cdm_id); | 32 cdm_services_.erase(cdm_id); |
33 } | 33 } |
34 | 34 |
35 scoped_refptr<MediaKeys> MojoCdmServiceContext::GetCdm(int cdm_id) { | 35 scoped_refptr<ContentDecryptionModule> MojoCdmServiceContext::GetCdm( |
| 36 int cdm_id) { |
36 auto cdm_service = cdm_services_.find(cdm_id); | 37 auto cdm_service = cdm_services_.find(cdm_id); |
37 if (cdm_service == cdm_services_.end()) { | 38 if (cdm_service == cdm_services_.end()) { |
38 LOG(ERROR) << "CDM service not found: " << cdm_id; | 39 LOG(ERROR) << "CDM service not found: " << cdm_id; |
39 return nullptr; | 40 return nullptr; |
40 } | 41 } |
41 | 42 |
42 return cdm_service->second->GetCdm(); | 43 return cdm_service->second->GetCdm(); |
43 } | 44 } |
44 | 45 |
45 } // namespace media | 46 } // namespace media |
OLD | NEW |