Index: media/cdm/cdm_manager.h |
diff --git a/media/cdm/cdm_manager.h b/media/cdm/cdm_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75f5e7ba4b7e05ebae7dc50773bea8312af94ecf |
--- /dev/null |
+++ b/media/cdm/cdm_manager.h |
@@ -0,0 +1,49 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_CDM_CDM_MANAGER_H_ |
+#define MEDIA_CDM_CDM_MANAGER_H_ |
+ |
+#include <map> |
+ |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/synchronization/lock.h" |
+#include "media/base/media_export.h" |
+ |
+namespace media { |
+ |
+class ContentDecryptionModule; |
+ |
+// Provides a singleton registry of CDM instances. This is used to share |
+// ContentDecryptionModules between the MojoMediaService and |
+// AndroidVideoDecodeAccelerator, and should be removed along with AVDA in the |
+// future. (MojoCdmServiceContext serves the same purpose for Media Mojo |
+// services, but scoped to a single InterfaceFactory.) |
+class MEDIA_EXPORT CdmManager { |
+ public: |
+ CdmManager(); |
+ ~CdmManager(); |
+ |
+ static CdmManager* GetInstance(); |
+ |
+ // Returns the CDM associated with |cdm_id|. Can be called on any thread. |
+ scoped_refptr<ContentDecryptionModule> GetCdm(int cdm_id); |
+ |
+ // Registers the |cdm| for |cdm_id|. |
+ void RegisterCdm(int cdm_id, scoped_refptr<ContentDecryptionModule> cdm); |
+ |
+ // Unregisters the CDM associated with |cdm_id|. |
+ void UnregisterCdm(int cdm_id); |
+ |
+ private: |
+ base::Lock lock_; |
+ std::map<int, scoped_refptr<ContentDecryptionModule>> cdm_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CdmManager); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_CDM_CDM_MANAGER_H_ |