Bug 1251184 - [quicktime] P2. Use external plugin if available over native playback. r=cpearce, a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 11 Mar 2016 22:42:02 +1100
changeset 324128 2865d848a1981e5b64f31fc377ce07288532cb33
parent 324127 76a57e4e398e2c7aa08bf7d0c108f21192760c7f
child 324129 3b5ab4d96da805e2cb9038dc49c5427513116af5
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, ritu
bugs1251184
milestone47.0a2
Bug 1251184 - [quicktime] P2. Use external plugin if available over native playback. r=cpearce, a=ritu While almost identical to video/mp4, quicktime files often use codecs that we don't support: in particular MPEG4 part 2 and amr audio. If a plugin exists and is enabled, prefer it to handle those files. We only do so when opening the file directly. Media in <video> element will always play natively. MozReview-Commit-ID: 1yPpzfDaCfT
dom/media/DecoderTraits.cpp
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -50,16 +50,18 @@
 
 #include "WaveDecoder.h"
 #include "WaveDemuxer.h"
 #include "WaveReader.h"
 
 #include "ADTSDecoder.h"
 #include "ADTSDemuxer.h"
 
+#include "nsPluginHost.h"
+
 namespace mozilla
 {
 
 template <class String>
 static bool
 CodecListContains(char const *const * aCodecs, const String& aCodec)
 {
   for (int32_t i = 0; aCodecs[i]; ++i) {
@@ -349,16 +351,28 @@ bool DecoderTraits::ShouldHandleMediaTyp
   if (IsWaveType(nsDependentCString(aMIMEType))) {
     // We should not return true for Wave types, since there are some
     // Wave codecs actually in use in the wild that we don't support, and
     // we should allow those to be handled by plugins or helper apps.
     // Furthermore people can play Wave files on most platforms by other
     // means.
     return false;
   }
+
+  // If an external plugin which can handle quicktime video is available
+  // (and not disabled), prefer it over native playback as there several
+  // codecs found in the wild that we do not handle.
+  if (nsDependentCString(aMIMEType).EqualsASCII("video/quicktime")) {
+    RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
+    if (pluginHost &&
+        pluginHost->HavePluginForType(nsDependentCString(aMIMEType))) {
+      return false;
+    }
+  }
+
   return CanHandleMediaType(aMIMEType, false, EmptyString()) != CANPLAY_NO;
 }
 
 /* static */
 CanPlayStatus
 DecoderTraits::CanHandleCodecsType(const char* aMIMEType,
                                    const nsAString& aRequestedCodecs)
 {