Chromium Code Reviews| 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..e2dcbed09c7f0352c4551cc5180bd8dc38c7c502 |
| --- /dev/null |
| +++ b/media/cdm/cdm_manager.h |
| @@ -0,0 +1,48 @@ |
| +// 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" |
| + |
| +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. (MojoCdmContext serves the same purpose for Media Mojo services, |
|
xhwang
2017/05/04 01:41:41
nit: MojoCdmContext -> MojoCdmServiceContext
sandersd (OOO until July 31)
2017/05/04 19:56:11
Done.
|
| +// but scoped to a single InterfaceFactory.) |
| +class 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_ |