OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_CDM_CDM_MANAGER_H_ |
| 6 #define MEDIA_CDM_CDM_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "media/base/media_export.h" |
| 14 #include "media/cdm/cdm_manager_export.h" |
| 15 |
| 16 namespace media { |
| 17 |
| 18 class ContentDecryptionModule; |
| 19 |
| 20 // Provides a singleton registry of CDM instances. This is used to share |
| 21 // ContentDecryptionModules between the MojoMediaService and |
| 22 // AndroidVideoDecodeAccelerator, and should be removed along with AVDA in the |
| 23 // future. (MojoCdmServiceContext serves the same purpose for Media Mojo |
| 24 // services, but scoped to a single InterfaceFactory.) |
| 25 class CDM_MANAGER_EXPORT CdmManager { |
| 26 public: |
| 27 CdmManager(); |
| 28 ~CdmManager(); |
| 29 |
| 30 static CdmManager* GetInstance(); |
| 31 |
| 32 // Returns the CDM associated with |cdm_id|. Can be called on any thread. |
| 33 scoped_refptr<ContentDecryptionModule> GetCdm(int cdm_id); |
| 34 |
| 35 // Registers the |cdm| for |cdm_id|. |
| 36 void RegisterCdm(int cdm_id, scoped_refptr<ContentDecryptionModule> cdm); |
| 37 |
| 38 // Unregisters the CDM associated with |cdm_id|. |
| 39 void UnregisterCdm(int cdm_id); |
| 40 |
| 41 private: |
| 42 base::Lock lock_; |
| 43 std::map<int, scoped_refptr<ContentDecryptionModule>> cdm_map_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(CdmManager); |
| 46 }; |
| 47 |
| 48 } // namespace media |
| 49 |
| 50 #endif // MEDIA_CDM_CDM_MANAGER_H_ |
OLD | NEW |