Bug 1295886: Plug in Android FLAC decoder.
MozReview-Commit-ID: B5pOZIEGssO
--- a/dom/media/flac/FlacDecoder.cpp
+++ b/dom/media/flac/FlacDecoder.cpp
@@ -27,22 +27,17 @@ FlacDecoder::CreateStateMachine()
RefPtr<MediaDecoderReader> reader =
new MediaFormatReader(this, new FlacDemuxer(GetResource()));
return new MediaDecoderStateMachine(this, reader);
}
/* static */ bool
FlacDecoder::IsEnabled()
{
-#ifdef MOZ_FFVPX
return MediaPrefs::FlacEnabled();
-#else
- // Until bug 1295886 is fixed.
- return false;
-#endif
}
/* static */ bool
FlacDecoder::CanHandleMediaType(const nsACString& aType,
const nsAString& aCodecs)
{
return IsEnabled() &&
(aType.EqualsASCII("audio/flac") || aType.EqualsASCII("audio/x-flac") ||
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -31,16 +31,21 @@ using media::TimeUnit;
namespace mozilla {
mozilla::LazyLogModule sAndroidDecoderModuleLog("AndroidDecoderModule");
static const char*
TranslateMimeType(const nsACString& aMimeType)
{
+ // By adding the log, android native app passed audio/raw to get the decoder.
+ if (aMimeType.EqualsLiteral("audio/flac")) {
+ return "audio/raw";
+ }
+
if (VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8)) {
return "video/x-vnd.on2.vp8";
} else if (VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9)) {
return "video/x-vnd.on2.vp9";
}
return PromiseFlatCString(aMimeType).get();
}
@@ -61,17 +66,18 @@ AndroidDecoderModule::SupportsMimeType(c
DecoderDoctorDiagnostics* aDiagnostics) const
{
if (!AndroidBridge::Bridge() ||
AndroidBridge::Bridge()->GetAPIVersion() < 16) {
return false;
}
if (aMimeType.EqualsLiteral("video/mp4") ||
- aMimeType.EqualsLiteral("video/avc")) {
+ aMimeType.EqualsLiteral("video/avc") ||
+ aMimeType.EqualsLiteral("audio/flac")) {
return true;
}
// When checking "audio/x-wav", CreateDecoder can cause a JNI ERROR by
// Accessing a stale local reference leading to a SIGSEGV crash.
// To avoid this we check for wav types here.
if (aMimeType.EqualsLiteral("audio/x-wav") ||
aMimeType.EqualsLiteral("audio/wave; codecs=1") ||
@@ -116,25 +122,24 @@ AndroidDecoderModule::CreateVideoDecoder
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
AndroidDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
const AudioInfo& config = aParams.AudioConfig();
- MOZ_ASSERT(config.mBitDepth == 16, "We only handle 16-bit audio!");
MediaFormat::LocalRef format;
LOG("CreateAudioFormat with mimeType=%s, mRate=%d, channels=%d",
config.mMimeType.Data(), config.mRate, config.mChannels);
NS_ENSURE_SUCCESS(MediaFormat::CreateAudioFormat(
- config.mMimeType,
+ TranslateMimeType(config.mMimeType),
config.mRate,
config.mChannels,
&format), nullptr);
RefPtr<MediaDataDecoder> decoder = MediaPrefs::PDMAndroidRemoteCodecEnabled() ?
RemoteDataDecoder::CreateAudioDecoder(config, format, aParams.mCallback) :
MediaCodecDataDecoder::CreateAudioDecoder(config, format, aParams.mCallback);