forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract CdmManager from MojoCdmService.
This allows us to remove the conditional dependency from //media/gpu to //media/mojo/services, thus allowing future dependencies in the other direction. CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Review-Url: https://codereview.chromium.org/2857953006 Cr-Commit-Position: refs/heads/master@{#469544}
- Loading branch information
sandersd
authored and
Commit bot
committed
May 5, 2017
1 parent
8d03afa
commit 2c899c7
Showing
8 changed files
with
157 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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. | ||
|
||
#include "media/cdm/cdm_manager.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/logging.h" | ||
#include "media/base/content_decryption_module.h" | ||
|
||
namespace media { | ||
|
||
CdmManager::CdmManager() {} | ||
|
||
CdmManager::~CdmManager() {} | ||
|
||
// static | ||
CdmManager* CdmManager::GetInstance() { | ||
static CdmManager* manager = new CdmManager(); | ||
return manager; | ||
} | ||
|
||
scoped_refptr<ContentDecryptionModule> CdmManager::GetCdm(int cdm_id) { | ||
base::AutoLock lock(lock_); | ||
auto iter = cdm_map_.find(cdm_id); | ||
return iter == cdm_map_.end() ? nullptr : iter->second; | ||
} | ||
|
||
void CdmManager::RegisterCdm(int cdm_id, | ||
scoped_refptr<ContentDecryptionModule> cdm) { | ||
base::AutoLock lock(lock_); | ||
DCHECK(!cdm_map_.count(cdm_id)); | ||
cdm_map_[cdm_id] = cdm; | ||
} | ||
|
||
void CdmManager::UnregisterCdm(int cdm_id) { | ||
base::AutoLock lock(lock_); | ||
DCHECK(cdm_map_.count(cdm_id)); | ||
cdm_map_.erase(cdm_id); | ||
} | ||
|
||
} // namespace media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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" | ||
#include "media/cdm/cdm_manager_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 CDM_MANAGER_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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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_EXPORT_H_ | ||
#define MEDIA_CDM_CDM_MANAGER_EXPORT_H_ | ||
|
||
// Define CDM_MANAGER_EXPORT so that functionality implemented by the | ||
// cdm_manager component can be exported to consumers. | ||
|
||
#if defined(COMPONENT_BUILD) | ||
#if defined(WIN32) | ||
|
||
#if defined(CDM_MANAGER_IMPLEMENTATION) | ||
#define CDM_MANAGER_EXPORT __declspec(dllexport) | ||
#else | ||
#define CDM_MANAGER_EXPORT __declspec(dllimport) | ||
#endif // defined(CDM_MANAGER_IMPLEMENTATION) | ||
|
||
#else // defined(WIN32) | ||
#if defined(CDM_MANAGER_IMPLEMENTATION) | ||
#define CDM_MANAGER_EXPORT __attribute__((visibility("default"))) | ||
#else | ||
#define CDM_MANAGER_EXPORT | ||
#endif | ||
#endif | ||
|
||
#else // defined(COMPONENT_BUILD) | ||
#define CDM_MANAGER_EXPORT | ||
#endif | ||
|
||
#endif // MEDIA_BASE_CDM_MANAGER_EXPORT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters