Bug 1195723: [flac] P9. Hook up flac decoder and demuxer. r?kamidphish
MozReview-Commit-ID: 5Md6mcZkME
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -48,16 +48,19 @@
#include "WaveDecoder.h"
#include "WaveDemuxer.h"
#include "WaveReader.h"
#include "ADTSDecoder.h"
#include "ADTSDemuxer.h"
+#include "FlacDecoder.h"
+#include "FlacDemuxer.h"
+
#include "nsPluginHost.h"
#include "MediaPrefs.h"
namespace mozilla
{
template <class String>
static bool
@@ -315,16 +318,23 @@ IsAACSupportedType(const nsACString& aTy
static bool
IsWAVSupportedType(const nsACString& aType,
const nsAString& aCodecs = EmptyString())
{
return WaveDecoder::CanHandleMediaType(aType, aCodecs);
}
+static bool
+IsFlacSupportedType(const nsACString& aType,
+ const nsAString& aCodecs = EmptyString())
+{
+ return FlacDecoder::CanHandleMediaType(aType, aCodecs);
+}
+
/* static */
bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType,
DecoderDoctorDiagnostics* aDiagnostics)
{
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.
@@ -395,16 +405,19 @@ DecoderTraits::CanHandleCodecsType(const
}
#endif
if (IsMP3SupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
return CANPLAY_YES;
}
if (IsAACSupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
return CANPLAY_YES;
}
+ if (IsFlacSupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
+ return CANPLAY_YES;
+ }
#ifdef MOZ_OMX_DECODER
if (IsOmxSupportedType(nsDependentCString(aMIMEType))) {
if (nsDependentCString(aMIMEType).EqualsASCII("audio/mpeg")) {
codecList = gMpegAudioCodecs;
#ifdef MOZ_OMX_WEBM_DECODER
} else if (nsDependentCString(aMIMEType).EqualsASCII("audio/webm") ||
nsDependentCString(aMIMEType).EqualsASCII("video/webm")) {
codecList = gOMXWebMCodecs;
@@ -488,16 +501,19 @@ DecoderTraits::CanHandleMediaType(const
}
#endif
if (IsMP3SupportedType(nsDependentCString(aMIMEType))) {
return CANPLAY_MAYBE;
}
if (IsAACSupportedType(nsDependentCString(aMIMEType))) {
return CANPLAY_MAYBE;
}
+ if (IsFlacSupportedType(nsDependentCString(aMIMEType))) {
+ return CANPLAY_MAYBE;
+ }
#ifdef MOZ_OMX_DECODER
if (IsOmxSupportedType(nsDependentCString(aMIMEType))) {
return CANPLAY_MAYBE;
}
#endif
#ifdef MOZ_DIRECTSHOW
if (DirectShowDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), nullptr)) {
return CANPLAY_MAYBE;
@@ -545,16 +561,20 @@ InstantiateDecoder(const nsACString& aTy
if (IsOggSupportedType(aType)) {
decoder = new OggDecoder(aOwner);
return decoder.forget();
}
if (IsWaveType(aType)) {
decoder = new WaveDecoder(aOwner);
return decoder.forget();
}
+ if (IsFlacSupportedType(aType)) {
+ decoder = new FlacDecoder(aOwner);
+ return decoder.forget();
+ }
#ifdef MOZ_OMX_DECODER
if (IsOmxSupportedType(aType)) {
// we are discouraging Web and App developers from using those formats in
// gB2GOnlyTypes, thus we only allow them to be played on WebApps.
if (IsB2GSupportOnlyType(aType)) {
dom::HTMLMediaElement* element = aOwner->GetMediaElement();
if (!element) {
return nullptr;
@@ -629,16 +649,19 @@ MediaDecoderReader* DecoderTraits::Creat
decoderReader = new MediaFormatReader(aDecoder, new mp3::MP3Demuxer(aDecoder->GetResource()));
} else
if (IsAACSupportedType(aType)) {
decoderReader = new MediaFormatReader(aDecoder, new ADTSDemuxer(aDecoder->GetResource()));
} else
if (IsWAVSupportedType(aType)) {
decoderReader = new MediaFormatReader(aDecoder, new WAVDemuxer(aDecoder->GetResource()));
} else
+ if (IsFlacSupportedType(aType)) {
+ decoderReader = new MediaFormatReader(aDecoder, new FlacDemuxer(aDecoder->GetResource()));
+ } else
#ifdef MOZ_RAW
if (IsRawType(aType)) {
decoderReader = new RawReader(aDecoder);
} else
#endif
if (IsOggSupportedType(aType)) {
decoderReader = MediaPrefs::OggFormatReader() ?
static_cast<MediaDecoderReader*>(new MediaFormatReader(aDecoder, new OggDemuxer(aDecoder->GetResource()))) :
@@ -696,15 +719,16 @@ bool DecoderTraits::IsSupportedInVideoDo
#ifdef MOZ_ANDROID_OMX
(MediaDecoder::IsAndroidMediaPluginEnabled() && IsAndroidMediaType(aType)) ||
#endif
#ifdef MOZ_FMP4
IsMP4SupportedType(aType, /* DecoderDoctorDiagnostics* */ nullptr) ||
#endif
IsMP3SupportedType(aType) ||
IsAACSupportedType(aType) ||
+ IsFlacSupportedType(aType) ||
#ifdef MOZ_DIRECTSHOW
IsDirectShowSupportedType(aType) ||
#endif
false;
}
} // namespace mozilla
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -543,16 +543,17 @@ pref("media.mediasource.mp4.enabled", tr
pref("media.mediasource.webm.enabled", false);
#else
pref("media.mediasource.webm.enabled", true);
#endif
pref("media.mediasource.webm.audio.enabled", true);
// Use new MediaFormatReader architecture for plain ogg.
pref("media.format-reader.ogg", true);
+pref("media.flac.enabled", true);
pref("media.benchmark.vp9.threshold", 150);
pref("media.benchmark.frames", 300);
pref("media.benchmark.timeout", 1000);
#ifdef MOZ_WEBSPEECH
pref("media.webspeech.recognition.enable", false);
pref("media.webspeech.synth.enabled", false);