Bug 1251184: [quicktime] P2. Use external plugin if available over native playback. r?cpearce
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
--- 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)
{