Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: content/common/media/cdm_service.cc

Issue 1637083002: Add CdmService to keep track of CDMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename + simplification Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/media/cdm_service.cc
diff --git a/content/common/media/cdm_service.cc b/content/common/media/cdm_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c2907af937c170492c45cdef12d1bbffc76f2ddb
--- /dev/null
+++ b/content/common/media/cdm_service.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 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 "content/public/common/cdm_service.h"
+
+#include <stddef.h>
+
+#include "content/public/common/content_client.h"
+
+namespace content {
+
+static base::LazyInstance<CdmService>::Leaky g_cdm_service =
+ LAZY_INSTANCE_INITIALIZER;
+
+// static
+CdmService* CdmService::GetInstance() {
+ return g_cdm_service.Pointer();
+}
+
+CdmService::CdmService() {
+ GetContentClient()->AddContentDecryptionModules(&registered_modules_);
+}
+
+CdmService::~CdmService() {}
+
+void CdmService::Register(
+ const std::string& cdm_id,
+ const std::string& version,
+ const base::FilePath& module_library_path,
+ const std::vector<base::string16>& supported_codecs,
+ const std::vector<base::string16>& supported_init_data_types) {
+ DCHECK(!cdm_id.empty());
+ DCHECK(!version.empty());
ddorwin 2016/03/18 19:24:18 Really? What about Android, etc.?
jrummell 2016/03/23 21:38:09 Removed.
+ for (size_t i = 0; i < registered_modules_.size(); i++) {
+ if (registered_modules_[i].cdm_id == cdm_id &&
ddorwin 2016/03/18 19:24:18 As mentioned later, why not just always insert?
jrummell 2016/03/23 21:38:09 Done.
+ registered_modules_[i].version == version) {
+ registered_modules_[i].module_library_path = module_library_path;
+ registered_modules_[i].supported_codecs = supported_codecs;
+ registered_modules_[i].supported_init_data_types =
+ supported_init_data_types;
+ return;
+ }
+ }
+
+ registered_modules_.insert(
+ registered_modules_.begin(),
+ CdmInfo(cdm_id, version, module_library_path, supported_codecs,
+ supported_init_data_types));
+}
+
+const std::vector<CdmInfo>& CdmService::GetAllRegisteredCdms() const {
+ return registered_modules_;
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698