Bug 1159300 - Don't use decrypting Gecko Media Plugins for non-encrypted playback. r=cpearce, a=sledru
authorEdwin Flores <edwin@mozilla.com>
Thu, 30 Apr 2015 00:52:29 -0400
changeset 260333 28521384c589
parent 260332 8a61f534f496
child 260334 d262c6789549
push id754
push userryanvm@gmail.com
push date2015-04-30 21:03 +0000
treeherdermozilla-release@d262c6789549 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, sledru
bugs1159300
milestone38.0
Bug 1159300 - Don't use decrypting Gecko Media Plugins for non-encrypted playback. r=cpearce, a=sledru
dom/media/gmp/GMPParent.cpp
dom/media/gmp/GMPParent.h
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -56,16 +56,17 @@ extern PRLogModuleInfo* GetGMPLog();
 namespace gmp {
 
 GMPParent::GMPParent()
   : mState(GMPStateNotLoaded)
   , mProcess(nullptr)
   , mDeleteProcessOnlyOnUnload(false)
   , mAbnormalShutdownInProgress(false)
   , mIsBlockingDeletion(false)
+  , mCanDecrypt(false)
   , mAsyncShutdownRequired(false)
   , mAsyncShutdownInProgress(false)
 {
   // Use the parent address to identify it.
   // We could use any unique-to-the-parent value.
   mPluginId.AppendInt(reinterpret_cast<uint64_t>(this));
 }
 
@@ -989,41 +990,50 @@ GMPParent::ReadGMPMetaData()
         nsCCharSeparatedTokenizer tagTokens(ts, ':');
         while (tagTokens.hasMoreTokens()) {
           const nsDependentCSubstring tag(tagTokens.nextToken());
           cap->mAPITags.AppendElement(tag);
         }
       }
     }
 
+    if (cap->mAPIName.EqualsLiteral(GMP_API_DECRYPTOR) ||
+        cap->mAPIName.EqualsLiteral(GMP_API_DECRYPTOR_COMPAT)) {
+      mCanDecrypt = true;
+
 #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
-    if (cap->mAPIName.EqualsLiteral(GMP_API_DECRYPTOR) &&
-        !mozilla::SandboxInfo::Get().CanSandboxMedia()) {
-      printf_stderr("GMPParent::ReadGMPMetaData: Plugin \"%s\" is an EME CDM"
-                    " but this system can't sandbox it; not loading.\n",
-                    mDisplayName.get());
-      delete cap;
-      return NS_ERROR_FAILURE;
+      if (!mozilla::SandboxInfo::Get().CanSandboxMedia()) {
+        printf_stderr("GMPParent::ReadGMPMetaData: Plugin \"%s\" is an EME CDM"
+                      " but this system can't sandbox it; not loading.\n",
+                      mDisplayName.get());
+        delete cap;
+        return NS_ERROR_FAILURE;
+      }
+#endif
     }
-#endif
 
     mCapabilities.AppendElement(cap);
   }
 
   if (mCapabilities.IsEmpty()) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 bool
 GMPParent::CanBeSharedCrossNodeIds() const
 {
-  return mNodeId.IsEmpty();
+  return mNodeId.IsEmpty() &&
+    // XXX bug 1159300 hack -- maybe remove after openh264 1.4
+    // We don't want to use CDM decoders for non-encrypted playback
+    // just yet; especially not for WebRTC. Don't allow CDMs to be used
+    // without a node ID.
+    !mCanDecrypt;
 }
 
 bool
 GMPParent::CanBeUsedFrom(const nsACString& aNodeId) const
 {
   return (mNodeId.IsEmpty() && State() == GMPStateNotLoaded) ||
          mNodeId == aNodeId;
 }
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -190,16 +190,18 @@ private:
   nsCString mVersion;
   nsCString mPluginId;
   nsTArray<nsAutoPtr<GMPCapability>> mCapabilities;
   GMPProcessParent* mProcess;
   bool mDeleteProcessOnlyOnUnload;
   bool mAbnormalShutdownInProgress;
   bool mIsBlockingDeletion;
 
+  bool mCanDecrypt;
+
   nsTArray<nsRefPtr<GMPVideoDecoderParent>> mVideoDecoders;
   nsTArray<nsRefPtr<GMPVideoEncoderParent>> mVideoEncoders;
   nsTArray<nsRefPtr<GMPDecryptorParent>> mDecryptors;
   nsTArray<nsRefPtr<GMPAudioDecoderParent>> mAudioDecoders;
   nsTArray<nsRefPtr<GMPTimerParent>> mTimers;
   nsTArray<nsRefPtr<GMPStorageParent>> mStorage;
   nsCOMPtr<nsIThread> mGMPThread;
   nsCOMPtr<nsITimer> mAsyncShutdownTimeout; // GMP Thread only.