Bug 1266336 - Check sCDMWrapper before creating video decoder - r=cpearce a=ritu
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 05 May 2016 11:37:22 +1000
changeset 332760 636655e9507907508fa1b4edd197a56c211acc4a
parent 332759 8aa028f3da509c4b1b47857defac32d1ded82ea2
child 332761 74518dbeb5d54a615e6f399bfef4ca81b0441ac2
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, ritu
bugs1266336
milestone48.0a2
Bug 1266336 - Check sCDMWrapper before creating video decoder - r=cpearce a=ritu Ensure that there is a CDM before creating a video decoder that relies on that CDM. This is mainly to prevent using the Widevine video decoder alone, without decryption. MozReview-Commit-ID: 7p49CnmV2r7
dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
--- a/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
@@ -119,17 +119,23 @@ WidevineAdapter::GMPGetAPI(const char* a
     decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
 
     cdm->Initialize(false, /* allow_distinctive_identifier */
                     false /* allow_persistent_state */);
 
     *aPluginAPI = decryptor;
 
   } else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
-    *aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI), RefPtr<CDMWrapper>(sCDMWrapper));
+    if (!sCDMWrapper) {
+      Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p No cdm for video decoder",
+          aAPIName, aHostAPI, aPluginAPI, this);
+      return GMPGenericErr;
+    }
+    *aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
+                                           RefPtr<CDMWrapper>(sCDMWrapper));
 
   }
   return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
 }
 
 void
 WidevineAdapter::GMPShutdown()
 {