Bug 1200059 - Make Adobe Primetime EME usable on MacOSX if available. r=edwin, a=sylvestre

This commit is contained in:
Chris Pearce 2015-08-31 16:08:03 +12:00
Родитель 4b9f1b3265
Коммит f2e187ede1
6 изменённых файлов: 48 добавлений и 29 удалений

Просмотреть файл

@ -89,7 +89,6 @@ ParseKeySystem(const nsAString& aExpectedKeySystem,
static const char16_t* sKeySystems[] = {
MOZ_UTF16("org.w3.clearkey"),
MOZ_UTF16("com.adobe.access"),
MOZ_UTF16("com.adobe.primetime"),
};

Просмотреть файл

@ -90,7 +90,7 @@ private:
static TrialCreateState GetCreateTrialState(const nsAString& aKeySystem);
struct TrialCreateData {
TrialCreateData(const nsAString& aKeySystem)
explicit TrialCreateData(const nsAString& aKeySystem)
: mKeySystem(aKeySystem)
, mStatus(GetCreateTrialState(aKeySystem))
{}
@ -141,7 +141,7 @@ public:
class Callback : public GetGMPVideoDecoderCallback
{
public:
Callback(TestGMPVideoDecoder* aInstance)
explicit Callback(TestGMPVideoDecoder* aInstance)
: mInstance(aInstance)
{}
~Callback() {}

Просмотреть файл

@ -15,6 +15,9 @@
#include "mozilla/WindowsVersion.h"
#include "WMFDecoderModule.h"
#endif
#ifdef XP_MACOSX
#include "nsCocoaFeatures.h"
#endif
#include "nsContentCID.h"
#include "nsServiceManagerUtils.h"
#include "mozIGeckoMediaPluginService.h"
@ -28,6 +31,10 @@
#include "nsDirectoryServiceDefs.h"
#include "nsXULAppAPI.h"
#if defined(XP_WIN) || defined(XP_MACOSX)
#define PRIMETIME_EME_SUPPORTED 1
#endif
namespace mozilla {
namespace dom {
@ -173,8 +180,7 @@ EnsureMinCDMVersion(mozIGeckoMediaPluginService* aGMPService,
}
#ifdef XP_WIN
if (aKeySystem.EqualsLiteral("com.adobe.access") ||
aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
// Verify that anti-virus hasn't "helpfully" deleted the Adobe GMP DLL,
// as we suspect may happen (Bug 1160382).
bool somethingMissing = false;
@ -231,21 +237,27 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
#ifdef PRIMETIME_EME_SUPPORTED
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
}
#ifdef XP_WIN
if ((aKeySystem.EqualsLiteral("com.adobe.access") ||
aKeySystem.EqualsLiteral("com.adobe.primetime"))) {
// Win Vista and later only.
if (!IsVistaOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version not met for Adobe EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
#endif
#ifdef XP_MACOSX
if (!nsCocoaFeatures::OnLionOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version not met for Adobe EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
#endif
if (!EMEVoucherFileExists()) {
// The system doesn't have the codecs that Adobe EME relies
// on installed, or doesn't have a voucher for the plugin-container.
// Gecko doesn't have a voucher file for the plugin-container.
// Adobe EME isn't going to work, so don't advertise that it will.
aOutMessage = NS_LITERAL_CSTRING("Plugin-container voucher not present");
return MediaKeySystemStatus::Cdm_not_supported;

Просмотреть файл

@ -13,6 +13,9 @@
#ifdef XP_WIN
#include "mozilla/WindowsVersion.h"
#endif
#ifdef XP_MACOSX
#include "nsCocoaFeatures.h"
#endif
#include "nsPrintfCString.h"
namespace mozilla {
@ -74,6 +77,23 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
Request(aPromise, aKeySystem, options, RequestType::Initial);
}
static bool
ShouldTrialCreateGMP(const nsAString& aKeySystem)
{
// Trial create where the CDM has a decoder;
// * ClearKey and Primetime on Windows Vista and later.
// * Primetime on MacOSX Lion and later.
return
#ifdef XP_WIN
IsVistaOrLater();
#elif defined(XP_MACOSX)
aKeySystem.EqualsLiteral("com.adobe.primetime") &&
nsCocoaFeatures::OnLionOrLater();
#else
false;
#endif
}
void
MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
const nsAString& aKeySystem,
@ -164,16 +184,14 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
MediaKeySystemAccess::IsSupported(keySystem, aOptions)) {
nsRefPtr<MediaKeySystemAccess> access(
new MediaKeySystemAccess(mWindow, keySystem, NS_ConvertUTF8toUTF16(cdmVersion)));
#ifdef XP_WIN
if (IsVistaOrLater()) {
// On Windows, ensure we have tried creating a GMPVideoDecoder for this
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 (i.e.
// all system libraries required are installed).
// report that we support this keySystem when the CDM us usable.
mTrialCreator->MaybeAwaitTrialCreate(keySystem, access, aPromise, mWindow);
return;
}
#endif
aPromise->MaybeResolve(access);
return;
}

Просмотреть файл

@ -6,9 +6,7 @@
#define mozilla_dom_MediaKeySystemAccessManager_h
#include "mozilla/dom/MediaKeySystemAccess.h"
#ifdef XP_WIN
#include "mozilla/dom/GMPVideoDecoderTrialCreator.h"
#endif
#include "nsIObserver.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupportsImpl.h"
@ -79,9 +77,7 @@ private:
nsCOMPtr<nsPIDOMWindow> mWindow;
bool mAddedObservers;
#ifdef XP_WIN
nsRefPtr<GMPVideoDecoderTrialCreator> mTrialCreator;
#endif
};
} // namespace dom

Просмотреть файл

@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
'GMPVideoDecoderTrialCreator.h',
'MediaEncryptedEvent.h',
'MediaKeyError.h',
'MediaKeyMessageEvent.h',
@ -29,6 +30,7 @@ UNIFIED_SOURCES += [
'CDMProxy.cpp',
'DetailedPromise.cpp',
'EMEUtils.cpp',
'GMPVideoDecoderTrialCreator.cpp',
'MediaEncryptedEvent.cpp',
'MediaKeyError.cpp',
'MediaKeyMessageEvent.cpp',
@ -39,14 +41,6 @@ UNIFIED_SOURCES += [
'MediaKeySystemAccessManager.cpp',
]
if CONFIG['OS_ARCH'] == 'WINNT':
UNIFIED_SOURCES += [
'GMPVideoDecoderTrialCreator.cpp',
]
EXPORTS.mozilla.dom += [
'GMPVideoDecoderTrialCreator.h',
]
FINAL_LIBRARY = 'xul'
FAIL_ON_WARNINGS = True