Bug 1406080 - Part2 - Reject creating with unsupported cdm version in clearkey cdm and cdm-fake. draft
authorJames Cheng <jacheng@mozilla.com>
Sat, 07 Oct 2017 00:06:06 +0800
changeset 680790 1eaeb8543ebe50af287b65c34c94da79b5c984d0
parent 680789 7adf376e2cae351539ea4e113aef577d7de3c5ec
child 680954 dc400ba581bed5c82a0fc8113b0cfad5d047d421
child 682202 37566a0f16eacb4b4b046443cf16736f91c01c1b
push id84624
push userbmo:jacheng@mozilla.com
push dateMon, 16 Oct 2017 10:07:40 +0000
bugs1406080
milestone58.0a1
Bug 1406080 - Part2 - Reject creating with unsupported cdm version in clearkey cdm and cdm-fake. MozReview-Commit-ID: JvSsqZekRQ6
dom/media/fake-cdm/cdm-fake.cpp
media/gmp-clearkey/0.1/gmp-clearkey.cpp
--- a/dom/media/fake-cdm/cdm-fake.cpp
+++ b/dom/media/fake-cdm/cdm-fake.cpp
@@ -47,16 +47,20 @@ void INITIALIZE_CDM_MODULE() {
 
 CDM_API
 void* CreateCdmInstance(int cdm_interface_version,
                         const char* key_system,
                         uint32_t key_system_size,
                         GetCdmHostFunc get_cdm_host_func,
                         void* user_data)
 {
+  if (cdm_interface_version != cdm::ContentDecryptionModule_8::kVersion) {
+    // Only support CDM version 8 currently.
+    return nullptr;
+  }
   cdm::Host_8* host = static_cast<cdm::Host_8*>(
     get_cdm_host_func(cdm_interface_version, user_data));
   return new FakeDecryptor(host);
 }
 
 
 CDM_API
 bool
--- a/media/gmp-clearkey/0.1/gmp-clearkey.cpp
+++ b/media/gmp-clearkey/0.1/gmp-clearkey.cpp
@@ -51,16 +51,21 @@ void* CreateCdmInstance(int cdm_interfac
                         const char* key_system,
                         uint32_t key_system_size,
                         GetCdmHostFunc get_cdm_host_func,
                         void* user_data)
 {
 
   CK_LOGE("ClearKey CreateCDMInstance");
 
+  if (cdm_interface_version != cdm::ContentDecryptionModule_8::kVersion) {
+    CK_LOGE("ClearKey CreateCDMInstance failed due to requesting unsupported version %d.",
+            cdm_interface_version);
+    return nullptr;
+  }
 #ifdef ENABLE_WMF
   if (!wmf::EnsureLibs()) {
     CK_LOGE("Required libraries were not found");
     return nullptr;
   }
 #endif
 
 #ifdef MOZILLA_OFFICIAL