mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1232527 - Call into WMF PDM to determine if WMF can decode instead of using GMPVideoDecoderTrialCreator. r=jwwang
Resurrect WMFDecoderModule::HasAAC() and HasH264(), and use those in MediaKeySystemAccess.cpp to figure out whether we gmp-clearkey can decode, rather than assuming Vista and later is always able to decode, as that's not a valid assumption; Vista may not have the required Platfor Update installed, or we may be on Windows N or KN without the Media Feature Pack.
This commit is contained in:
parent
7832fcf916
commit
7cf59679be
@ -33,6 +33,9 @@
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "gmp-audio-decode.h"
|
||||
#include "gmp-video-decode.h"
|
||||
#ifdef XP_WIN
|
||||
#include "WMFDecoderModule.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
#define PRIMETIME_EME_SUPPORTED 1
|
||||
@ -316,7 +319,16 @@ GMPDecryptsAndDecodesAAC(mozIGeckoMediaPluginService* aGMPS,
|
||||
return HaveGMPFor(aGMPS,
|
||||
NS_ConvertUTF16toUTF8(aKeySystem),
|
||||
NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
|
||||
NS_LITERAL_CSTRING("aac"));
|
||||
NS_LITERAL_CSTRING("aac"))
|
||||
#ifdef XP_WIN
|
||||
// Clearkey on Windows advertises that it can decode in its GMP info
|
||||
// file, but uses Windows Media Foundation to decode. That's not present
|
||||
// on Windows XP, and on some Vista, Windows N, and KN variants without
|
||||
// certain services packs. So for ClearKey we must check that WMF will
|
||||
// work.
|
||||
&& (!aKeySystem.EqualsLiteral("org.w3.clearkey") || WMFDecoderModule::HasAAC())
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -329,7 +341,16 @@ GMPDecryptsAndDecodesH264(mozIGeckoMediaPluginService* aGMPS,
|
||||
return HaveGMPFor(aGMPS,
|
||||
NS_ConvertUTF16toUTF8(aKeySystem),
|
||||
NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
NS_LITERAL_CSTRING("h264"));
|
||||
NS_LITERAL_CSTRING("h264"))
|
||||
#ifdef XP_WIN
|
||||
// Clearkey on Windows advertises that it can decode in its GMP info
|
||||
// file, but uses Windows Media Foundation to decode. That's not present
|
||||
// on Windows XP, and on some Vista, Windows N, and KN variants without
|
||||
// certain services packs. So for ClearKey we must check that WMF will
|
||||
// work.
|
||||
&& (!aKeySystem.EqualsLiteral("org.w3.clearkey") || WMFDecoderModule::HasH264())
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
// If this keysystem's CDM explicitly says it doesn't support decoding,
|
||||
@ -352,9 +373,12 @@ GMPDecryptsAndGeckoDecodesH264(mozIGeckoMediaPluginService* aGMPService,
|
||||
NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
NS_LITERAL_CSTRING("h264"))
|
||||
#ifdef XP_WIN
|
||||
// Clearkey on Windows XP can't decode, but advertises that it can
|
||||
// in its GMP info file.
|
||||
|| (aKeySystem.EqualsLiteral("org.w3.clearkey") && !IsVistaOrLater())
|
||||
// Clearkey on Windows advertises that it can decode in its GMP info
|
||||
// file, but uses Windows Media Foundation to decode. That's not present
|
||||
// on Windows XP, and on some Vista, Windows N, and KN variants without
|
||||
// certain services packs. So don't try to use gmp-clearkey for decoding
|
||||
// if we don't have a decoder here.
|
||||
|| (aKeySystem.EqualsLiteral("org.w3.clearkey") && !WMFDecoderModule::HasH264())
|
||||
#endif
|
||||
) && MP4Decoder::CanHandleMediaType(aContentType);
|
||||
}
|
||||
@ -374,9 +398,12 @@ GMPDecryptsAndGeckoDecodesAAC(mozIGeckoMediaPluginService* aGMPService,
|
||||
NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
|
||||
NS_LITERAL_CSTRING("aac"))
|
||||
#ifdef XP_WIN
|
||||
// Clearkey on Windows XP can't decode, but advertises that it can
|
||||
// in its GMP info file.
|
||||
|| (aKeySystem.EqualsLiteral("org.w3.clearkey") && !IsVistaOrLater())
|
||||
// Clearkey on Windows advertises that it can decode in its GMP info
|
||||
// file, but uses Windows Media Foundation to decode. That's not present
|
||||
// on Windows XP, and on some Vista, Windows N, and KN variants without
|
||||
// certain services packs. So don't try to use gmp-clearkey for decoding
|
||||
// if we don't have a decoder here.
|
||||
|| (aKeySystem.EqualsLiteral("org.w3.clearkey") && !WMFDecoderModule::HasAAC())
|
||||
#endif
|
||||
) && MP4Decoder::CanHandleMediaType(aContentType);
|
||||
}
|
||||
|
@ -73,19 +73,6 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
Request(aPromise, aKeySystem, aConfigs, RequestType::Initial);
|
||||
}
|
||||
|
||||
static bool
|
||||
ShouldTrialCreateGMP(const nsAString& aKeySystem)
|
||||
{
|
||||
// Trial create where the CDM has a Windows Media Foundation decoder.
|
||||
#ifdef XP_WIN
|
||||
return Preferences::GetBool("media.gmp.trial-create.enabled", false) &&
|
||||
aKeySystem.EqualsLiteral("org.w3.clearkey") &&
|
||||
IsVistaOrLater();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
@ -179,13 +166,6 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
MediaKeySystemAccess::IsSupported(keySystem, aConfigs)) {
|
||||
RefPtr<MediaKeySystemAccess> access(
|
||||
new MediaKeySystemAccess(mWindow, keySystem, NS_ConvertUTF8toUTF16(cdmVersion), config));
|
||||
if (ShouldTrialCreateGMP(keySystem)) {
|
||||
// Ensure we have tried creating a GMPVideoDecoder for this
|
||||
// keySystem, and that we can use it to decode. This ensures that we only
|
||||
// report that we support this keySystem when the CDM us usable.
|
||||
mTrialCreator->MaybeAwaitTrialCreate(keySystem, access, aPromise, mWindow);
|
||||
return;
|
||||
}
|
||||
aPromise->MaybeResolve(access);
|
||||
return;
|
||||
}
|
||||
|
@ -163,17 +163,29 @@ CanCreateWMFDecoder()
|
||||
return result.value();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
WMFDecoderModule::HasH264()
|
||||
{
|
||||
return CanCreateWMFDecoder<CLSID_CMSH264DecoderMFT>();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
WMFDecoderModule::HasAAC()
|
||||
{
|
||||
return CanCreateWMFDecoder<CLSID_CMSAACDecMFT>();
|
||||
}
|
||||
|
||||
bool
|
||||
WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType) const
|
||||
{
|
||||
if ((aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
||||
aMimeType.EqualsLiteral("audio/mp4")) &&
|
||||
CanCreateWMFDecoder<CLSID_CMSAACDecMFT>()) {
|
||||
WMFDecoderModule::HasAAC()) {
|
||||
return true;
|
||||
}
|
||||
if ((aMimeType.EqualsLiteral("video/avc") ||
|
||||
aMimeType.EqualsLiteral("video/mp4")) &&
|
||||
CanCreateWMFDecoder<CLSID_CMSH264DecoderMFT>()) {
|
||||
WMFDecoderModule::HasH264()) {
|
||||
return true;
|
||||
}
|
||||
if (aMimeType.EqualsLiteral("audio/mpeg") &&
|
||||
|
@ -42,6 +42,15 @@ public:
|
||||
// Called from any thread, must call init first
|
||||
static int GetNumDecoderThreads();
|
||||
static bool LowLatencyMFTEnabled();
|
||||
|
||||
// Accessors that report whether we have the required MFTs available
|
||||
// on the system to play various codecs. Windows Vista doesn't have the
|
||||
// H.264/AAC decoders if the "Platform Update Supplement for Windows Vista"
|
||||
// is not installed, and Window N and KN variants also require a "Media
|
||||
// Feature Pack" to be installed. Windows XP doesn't have WMF.
|
||||
static bool HasAAC();
|
||||
static bool HasH264();
|
||||
|
||||
private:
|
||||
bool mWMFInitialized;
|
||||
};
|
||||
|
@ -50,16 +50,6 @@ ClearKeySessionManager::~ClearKeySessionManager()
|
||||
CK_LOGD("ClearKeySessionManager dtor %p", this);
|
||||
}
|
||||
|
||||
static bool
|
||||
ShouldBeAbleToDecode()
|
||||
{
|
||||
#if !defined(ENABLE_WMF)
|
||||
return false;
|
||||
#else
|
||||
return IsWindowsVistaOrGreater();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
CanDecode()
|
||||
{
|
||||
@ -75,17 +65,12 @@ ClearKeySessionManager::Init(GMPDecryptorCallback* aCallback)
|
||||
{
|
||||
CK_LOGD("ClearKeySessionManager::Init");
|
||||
mCallback = aCallback;
|
||||
if (ShouldBeAbleToDecode()) {
|
||||
if (!CanDecode()) {
|
||||
const char* err = "EME plugin can't load system decoder!";
|
||||
mCallback->SessionError(nullptr, 0, kGMPAbortError, 0, err, strlen(err));
|
||||
} else {
|
||||
mCallback->SetCapabilities(GMP_EME_CAP_DECRYPT_AND_DECODE_AUDIO |
|
||||
GMP_EME_CAP_DECRYPT_AND_DECODE_VIDEO);
|
||||
}
|
||||
} else {
|
||||
if (!CanDecode()) {
|
||||
mCallback->SetCapabilities(GMP_EME_CAP_DECRYPT_AUDIO |
|
||||
GMP_EME_CAP_DECRYPT_VIDEO);
|
||||
} else {
|
||||
mCallback->SetCapabilities(GMP_EME_CAP_DECRYPT_AND_DECODE_AUDIO |
|
||||
GMP_EME_CAP_DECRYPT_AND_DECODE_VIDEO);
|
||||
}
|
||||
ClearKeyPersistence::EnsureInitialized();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user