2014-11-18 09:13:02 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/MediaKeySystemAccess.h"
|
|
|
|
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "nsContentTypeParser.h"
|
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
#include "MP4Decoder.h"
|
|
|
|
#endif
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "mozilla/WindowsVersion.h"
|
2015-04-30 09:52:01 +00:00
|
|
|
#include "WMFDecoderModule.h"
|
2014-11-18 09:13:02 +00:00
|
|
|
#endif
|
|
|
|
#include "nsContentCID.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "mozIGeckoMediaPluginService.h"
|
|
|
|
#include "VideoUtils.h"
|
2015-02-13 19:52:42 +00:00
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "nsIObserverService.h"
|
2015-02-20 01:37:55 +00:00
|
|
|
#include "mozilla/EMEUtils.h"
|
2015-04-30 09:52:14 +00:00
|
|
|
#include "GMPUtils.h"
|
2015-05-08 01:36:40 +00:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2014-11-18 09:13:02 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess,
|
|
|
|
mParent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeySystemAccess)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
MediaKeySystemAccess::MediaKeySystemAccess(nsPIDOMWindow* aParent,
|
|
|
|
const nsAString& aKeySystem)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mKeySystem(aKeySystem)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaKeySystemAccess::~MediaKeySystemAccess()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
MediaKeySystemAccess::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-11-18 09:13:02 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return MediaKeySystemAccessBinding::Wrap(aCx, this, aGivenProto);
|
2014-11-18 09:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPIDOMWindow*
|
|
|
|
MediaKeySystemAccess::GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MediaKeySystemAccess::GetKeySystem(nsString& aRetVal) const
|
|
|
|
{
|
|
|
|
aRetVal = mKeySystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
MediaKeySystemAccess::CreateMediaKeys(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRefPtr<MediaKeys> keys(new MediaKeys(mParent, mKeySystem));
|
|
|
|
return keys->Init(aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
HaveGMPFor(mozIGeckoMediaPluginService* aGMPService,
|
|
|
|
const nsCString& aKeySystem,
|
|
|
|
const nsCString& aAPI,
|
|
|
|
const nsCString& aTag = EmptyCString())
|
|
|
|
{
|
|
|
|
nsTArray<nsCString> tags;
|
|
|
|
tags.AppendElement(aKeySystem);
|
|
|
|
if (!aTag.IsEmpty()) {
|
|
|
|
tags.AppendElement(aTag);
|
|
|
|
}
|
|
|
|
bool hasPlugin = false;
|
|
|
|
if (NS_FAILED(aGMPService->HasPluginForAPI(aAPI,
|
|
|
|
&tags,
|
|
|
|
&hasPlugin))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return hasPlugin;
|
|
|
|
}
|
|
|
|
|
2015-05-08 01:36:40 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
static bool
|
2015-06-26 15:06:21 +00:00
|
|
|
AdobePluginFileExists(const nsACString& aVersionStr,
|
|
|
|
const nsAString& aFilename)
|
2015-05-08 01:36:40 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFile> path;
|
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(path));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = path->Append(NS_LITERAL_STRING("gmp-eme-adobe"));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = path->AppendNative(aVersionStr);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-26 15:06:21 +00:00
|
|
|
rv = path->Append(aFilename);
|
2015-05-08 01:36:40 +00:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool exists = false;
|
|
|
|
return NS_SUCCEEDED(path->Exists(&exists)) && exists;
|
|
|
|
}
|
2015-06-26 15:06:21 +00:00
|
|
|
|
|
|
|
static bool
|
|
|
|
AdobePluginDLLExists(const nsACString& aVersionStr)
|
|
|
|
{
|
|
|
|
return AdobePluginFileExists(aVersionStr, NS_LITERAL_STRING("eme-adobe.dll"));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
AdobePluginVoucherExists(const nsACString& aVersionStr)
|
|
|
|
{
|
|
|
|
return AdobePluginFileExists(aVersionStr, NS_LITERAL_STRING("eme-adobe.voucher"));
|
|
|
|
}
|
2015-05-08 01:36:40 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-20 01:38:08 +00:00
|
|
|
static MediaKeySystemStatus
|
|
|
|
EnsureMinCDMVersion(mozIGeckoMediaPluginService* aGMPService,
|
|
|
|
const nsAString& aKeySystem,
|
2015-02-24 14:03:56 +00:00
|
|
|
int32_t aMinCdmVersion,
|
|
|
|
bool aCheckForV6=false)
|
2015-02-20 01:38:08 +00:00
|
|
|
{
|
|
|
|
nsTArray<nsCString> tags;
|
|
|
|
tags.AppendElement(NS_ConvertUTF16toUTF8(aKeySystem));
|
2015-02-24 14:03:56 +00:00
|
|
|
bool hasPlugin;
|
2015-02-20 01:38:08 +00:00
|
|
|
nsAutoCString versionStr;
|
|
|
|
if (NS_FAILED(aGMPService->GetPluginVersionForAPI(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR),
|
2015-03-26 09:58:43 +00:00
|
|
|
&tags,
|
2015-02-24 14:03:56 +00:00
|
|
|
&hasPlugin,
|
2015-06-25 20:05:41 +00:00
|
|
|
versionStr)) ||
|
|
|
|
// XXX to be removed later in bug 1147692
|
|
|
|
(aCheckForV6 && !hasPlugin &&
|
|
|
|
NS_FAILED(aGMPService->GetPluginVersionForAPI(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT),
|
|
|
|
&tags,
|
|
|
|
&hasPlugin,
|
|
|
|
versionStr)))) {
|
2015-02-20 01:38:08 +00:00
|
|
|
return MediaKeySystemStatus::Error;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:03:56 +00:00
|
|
|
if (!hasPlugin) {
|
|
|
|
return MediaKeySystemStatus::Cdm_not_installed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aMinCdmVersion == NO_CDM_VERSION) {
|
|
|
|
return MediaKeySystemStatus::Available;
|
|
|
|
}
|
|
|
|
|
2015-02-20 01:38:08 +00:00
|
|
|
nsresult rv;
|
|
|
|
int32_t version = versionStr.ToInteger(&rv);
|
|
|
|
if (NS_FAILED(rv) || version < 0 || aMinCdmVersion > version) {
|
|
|
|
return MediaKeySystemStatus::Cdm_insufficient_version;
|
|
|
|
}
|
|
|
|
|
2015-05-08 01:36:40 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (aKeySystem.EqualsLiteral("com.adobe.access") ||
|
|
|
|
aKeySystem.EqualsLiteral("com.adobe.primetime")) {
|
|
|
|
// Verify that anti-virus hasn't "helpfully" deleted the Adobe GMP DLL,
|
|
|
|
// as we suspect may happen (Bug 1160382).
|
2015-06-26 15:06:21 +00:00
|
|
|
if (!AdobePluginDLLExists(versionStr) ||
|
|
|
|
!AdobePluginVoucherExists(versionStr)) {
|
|
|
|
NS_WARNING("Adobe EME plugin or voucher disappeared from disk!");
|
2015-05-08 01:36:40 +00:00
|
|
|
// Reset the prefs that Firefox's GMP downloader sets, so that
|
|
|
|
// Firefox will try to download the plugin next time the updater runs.
|
|
|
|
Preferences::ClearUser("media.gmp-eme-adobe.lastUpdate");
|
|
|
|
Preferences::ClearUser("media.gmp-eme-adobe.version");
|
|
|
|
return MediaKeySystemStatus::Cdm_not_installed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-20 01:38:08 +00:00
|
|
|
return MediaKeySystemStatus::Available;
|
|
|
|
}
|
|
|
|
|
2014-11-18 09:13:02 +00:00
|
|
|
/* static */
|
2015-02-13 19:52:42 +00:00
|
|
|
MediaKeySystemStatus
|
2015-02-20 01:38:08 +00:00
|
|
|
MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
|
|
|
|
int32_t aMinCdmVersion)
|
2014-11-18 09:13:02 +00:00
|
|
|
{
|
2015-02-13 19:52:42 +00:00
|
|
|
MOZ_ASSERT(Preferences::GetBool("media.eme.enabled", false));
|
2014-11-18 09:13:02 +00:00
|
|
|
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
|
|
|
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
|
|
|
if (NS_WARN_IF(!mps)) {
|
2015-02-13 19:52:42 +00:00
|
|
|
return MediaKeySystemStatus::Error;
|
2014-11-18 09:13:02 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:52:42 +00:00
|
|
|
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
|
|
|
|
if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) {
|
|
|
|
return MediaKeySystemStatus::Cdm_disabled;
|
|
|
|
}
|
2015-02-20 01:38:08 +00:00
|
|
|
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion);
|
2014-11-18 09:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2015-02-04 20:36:44 +00:00
|
|
|
if ((aKeySystem.EqualsLiteral("com.adobe.access") ||
|
2015-02-13 19:52:42 +00:00
|
|
|
aKeySystem.EqualsLiteral("com.adobe.primetime"))) {
|
|
|
|
// Win Vista and later only.
|
|
|
|
if (!IsVistaOrLater()) {
|
|
|
|
return MediaKeySystemStatus::Cdm_not_supported;
|
|
|
|
}
|
2015-02-17 17:50:16 +00:00
|
|
|
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
|
2015-02-13 19:52:42 +00:00
|
|
|
return MediaKeySystemStatus::Cdm_disabled;
|
|
|
|
}
|
2015-05-08 01:36:32 +00:00
|
|
|
if (!MP4Decoder::CanCreateH264Decoder() ||
|
|
|
|
!MP4Decoder::CanCreateAACDecoder() ||
|
2015-04-30 09:52:14 +00:00
|
|
|
!EMEVoucherFileExists()) {
|
2015-04-30 09:52:01 +00:00
|
|
|
// The system doesn't have the codecs that Adobe EME relies
|
2015-04-30 09:52:14 +00:00
|
|
|
// on installed, or doesn't have a voucher for the plugin-container.
|
|
|
|
// Adobe EME isn't going to work, so don't advertise that it will.
|
2015-04-30 09:52:01 +00:00
|
|
|
return MediaKeySystemStatus::Cdm_not_supported;
|
|
|
|
}
|
2015-02-24 14:03:56 +00:00
|
|
|
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, true);
|
2014-11-18 09:13:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-13 19:52:42 +00:00
|
|
|
return MediaKeySystemStatus::Cdm_not_supported;
|
2014-11-18 09:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsPlayableWithGMP(mozIGeckoMediaPluginService* aGMPS,
|
|
|
|
const nsAString& aKeySystem,
|
|
|
|
const nsAString& aContentType)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
nsContentTypeParser parser(aContentType);
|
|
|
|
nsAutoString mimeType;
|
|
|
|
nsresult rv = parser.GetType(mimeType);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mimeType.EqualsLiteral("audio/mp4") &&
|
|
|
|
!mimeType.EqualsLiteral("audio/x-m4a") &&
|
|
|
|
!mimeType.EqualsLiteral("video/mp4")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString codecs;
|
|
|
|
parser.GetParameter("codecs", codecs);
|
|
|
|
|
|
|
|
NS_ConvertUTF16toUTF8 mimeTypeUTF8(mimeType);
|
|
|
|
bool hasAAC = false;
|
|
|
|
bool hasH264 = false;
|
|
|
|
bool hasMP3 = false;
|
|
|
|
if (!MP4Decoder::CanHandleMediaType(mimeTypeUTF8,
|
|
|
|
codecs,
|
|
|
|
hasAAC,
|
|
|
|
hasH264,
|
|
|
|
hasMP3) ||
|
|
|
|
hasMP3) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-26 09:58:43 +00:00
|
|
|
return (!hasAAC ||
|
2015-06-25 20:05:41 +00:00
|
|
|
!(HaveGMPFor(aGMPS,
|
|
|
|
NS_ConvertUTF16toUTF8(aKeySystem),
|
|
|
|
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR),
|
|
|
|
NS_LITERAL_CSTRING("aac")) ||
|
|
|
|
// XXX remove later in bug 1147692
|
|
|
|
HaveGMPFor(aGMPS,
|
|
|
|
NS_ConvertUTF16toUTF8(aKeySystem),
|
|
|
|
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT),
|
|
|
|
NS_LITERAL_CSTRING("aac")))) &&
|
2015-03-26 09:58:43 +00:00
|
|
|
(!hasH264 ||
|
2015-06-25 20:05:41 +00:00
|
|
|
!(HaveGMPFor(aGMPS,
|
|
|
|
NS_ConvertUTF16toUTF8(aKeySystem),
|
|
|
|
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR),
|
|
|
|
NS_LITERAL_CSTRING("h264")) ||
|
|
|
|
// XXX remove later in bug 1147692
|
|
|
|
HaveGMPFor(aGMPS,
|
|
|
|
NS_ConvertUTF16toUTF8(aKeySystem),
|
|
|
|
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT),
|
|
|
|
NS_LITERAL_CSTRING("h264"))));
|
2014-11-18 09:13:02 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
MediaKeySystemAccess::IsSupported(const nsAString& aKeySystem,
|
|
|
|
const Sequence<MediaKeySystemOptions>& aOptions)
|
|
|
|
{
|
|
|
|
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
|
|
|
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
|
|
|
if (NS_WARN_IF(!mps)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < aOptions.Length(); i++) {
|
|
|
|
const MediaKeySystemOptions& options = aOptions[i];
|
|
|
|
if (!options.mInitDataType.EqualsLiteral("cenc")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!options.mAudioCapability.IsEmpty() ||
|
|
|
|
!options.mVideoCapability.IsEmpty()) {
|
|
|
|
// Don't support any capabilites until we know we have a CDM with
|
|
|
|
// capabilities...
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!options.mAudioType.IsEmpty() &&
|
|
|
|
!IsPlayableWithGMP(mps, aKeySystem, options.mAudioType)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!options.mVideoType.IsEmpty() &&
|
|
|
|
!IsPlayableWithGMP(mps, aKeySystem, options.mVideoType)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Our sandbox provides an origin specific unique identifier, and the
|
|
|
|
// ability to persist data. We don't yet have a way to turn those off
|
|
|
|
// and on for specific GMPs/CDMs, so we don't check the uniqueidentifier
|
|
|
|
// and stateful attributes here.
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:52:42 +00:00
|
|
|
/* static */
|
|
|
|
void
|
2015-02-16 21:25:11 +00:00
|
|
|
MediaKeySystemAccess::NotifyObservers(nsIDOMWindow* aWindow,
|
|
|
|
const nsAString& aKeySystem,
|
2015-02-13 19:52:42 +00:00
|
|
|
MediaKeySystemStatus aStatus)
|
|
|
|
{
|
|
|
|
RequestMediaKeySystemAccessNotification data;
|
|
|
|
data.mKeySystem = aKeySystem;
|
|
|
|
data.mStatus = aStatus;
|
|
|
|
nsAutoString json;
|
|
|
|
data.ToJSON(json);
|
|
|
|
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
|
|
|
if (obs) {
|
2015-02-16 21:25:11 +00:00
|
|
|
obs->NotifyObservers(aWindow, "mediakeys-request", json.get());
|
2015-02-13 19:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 09:13:02 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|