Bug 1211812 - Add pref to select GMP to use for unencrypted decoding. r=jwwang

This commit is contained in:
Chris Pearce 2015-10-08 20:40:09 +13:00
parent 315fca7c60
commit 70498d2115
9 changed files with 66 additions and 2 deletions

View File

@ -1825,6 +1825,11 @@ pref("ui.key.menuAccessKeyFocuses", true);
pref("media.eme.enabled", true);
pref("media.eme.apiVisible", true);
// If decoding-via-gmp is turned on for <video>, default to using
// Adobe's GMP for decoding.
pref("media.fragmented-mp4.gmp.aac", 2);
pref("media.fragmented-mp4.gmp.h264", 2);
// Whether we should run a test-pattern through EME GMPs before assuming they'll
// decode H.264.
pref("media.gmp.trial-create.enabled", true);

View File

@ -96,6 +96,7 @@ PDMFactory::Init()
#ifdef MOZ_FFMPEG
FFmpegRuntimeLinker::Link();
#endif
GMPDecoderModule::Init();
}
PDMFactory::PDMFactory()

View File

@ -24,7 +24,7 @@ EMEAudioCallbackAdapter::Error(GMPErr aErr)
void
EMEAudioDecoder::InitTags(nsTArray<nsCString>& aTags)
{
GMPAudioDecoder::InitTags(aTags);
aTags.AppendElement(NS_LITERAL_CSTRING("aac"));
aTags.AppendElement(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
}

View File

@ -26,7 +26,7 @@ EMEVideoCallbackAdapter::Error(GMPErr aErr)
void
EMEVideoDecoder::InitTags(nsTArray<nsCString>& aTags)
{
GMPVideoDecoder::InitTags(aTags);
aTags.AppendElement(NS_LITERAL_CSTRING("h264"));
aTags.AppendElement(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
}

View File

@ -7,6 +7,7 @@
#include "GMPAudioDecoder.h"
#include "nsServiceManagerUtils.h"
#include "MediaInfo.h"
#include "GMPDecoderModule.h"
namespace mozilla {
@ -125,6 +126,11 @@ void
GMPAudioDecoder::InitTags(nsTArray<nsCString>& aTags)
{
aTags.AppendElement(NS_LITERAL_CSTRING("aac"));
const Maybe<nsCString> gmp(
GMPDecoderModule::PreferredGMP(NS_LITERAL_CSTRING("audio/mp4a-latm")));
if (gmp.isSome()) {
aTags.AppendElement(gmp.value());
}
}
nsCString

View File

@ -10,6 +10,7 @@
#include "MediaDataDecoderProxy.h"
#include "mozIGeckoMediaPluginService.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Preferences.h"
namespace mozilla {
@ -86,4 +87,41 @@ GMPDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
}
}
static uint32_t sPreferredAacGmp = 0;
static uint32_t sPreferredH264Gmp = 0;
/* static */
void
GMPDecoderModule::Init()
{
Preferences::AddUintVarCache(&sPreferredAacGmp,
"media.fragmented-mp4.gmp.aac", 0);
Preferences::AddUintVarCache(&sPreferredH264Gmp,
"media.fragmented-mp4.gmp.h264", 0);
}
/* static */
const Maybe<nsCString>
GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
{
Maybe<nsCString> rv;
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
switch (sPreferredAacGmp) {
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
default: break;
}
}
if (aMimeType.EqualsLiteral("video/avc")) {
switch (sPreferredH264Gmp) {
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
default: break;
}
}
return rv;
}
} // namespace mozilla

View File

@ -8,6 +8,7 @@
#define GMPDecoderModule_h_
#include "PlatformDecoderModule.h"
#include "mozilla/Maybe.h"
namespace mozilla {
@ -41,6 +42,11 @@ public:
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("video/avc");
}
static void Init();
static const Maybe<nsCString> PreferredGMP(const nsACString& aMimeType);
};
} // namespace mozilla

View File

@ -9,6 +9,7 @@
#include "mozilla/Endian.h"
#include "prsystem.h"
#include "MediaData.h"
#include "GMPDecoderModule.h"
namespace mozilla {
@ -107,6 +108,11 @@ void
GMPVideoDecoder::InitTags(nsTArray<nsCString>& aTags)
{
aTags.AppendElement(NS_LITERAL_CSTRING("h264"));
const Maybe<nsCString> gmp(
GMPDecoderModule::PreferredGMP(NS_LITERAL_CSTRING("video/avc")));
if (gmp.isSome()) {
aTags.AppendElement(gmp.value());
}
}
nsCString

View File

@ -322,6 +322,8 @@ pref("media.directshow.enabled", true);
pref("media.fragmented-mp4.enabled", true);
pref("media.fragmented-mp4.ffmpeg.enabled", false);
pref("media.fragmented-mp4.gmp.enabled", false);
pref("media.fragmented-mp4.gmp.aac", 0);
pref("media.fragmented-mp4.gmp.h264", 0);
// Specifies whether the fragmented MP4 parser uses a test decoder that
// just outputs blank frames/audio instead of actually decoding. The blank
// decoder works on all platforms.