mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189196 - Rename MediaKeySystemOptions to MediaKeySystemConfiguration and update WebIDL. r=bz
This commit is contained in:
parent
3206bf3e85
commit
c4ca666bcf
@ -2853,52 +2853,9 @@ Navigator::GetUserAgent(nsPIDOMWindow* aWindow, nsIURI* aURI,
|
||||
#ifdef MOZ_EME
|
||||
already_AddRefed<Promise>
|
||||
Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
const Optional<Sequence<MediaKeySystemOptions>>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsAutoCString logMsg;
|
||||
logMsg.AppendPrintf("Navigator::RequestMediaKeySystemAccess(keySystem='%s' options=[",
|
||||
NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
if (aOptions.WasPassed()) {
|
||||
const Sequence<MediaKeySystemOptions>& options = aOptions.Value();
|
||||
for (size_t i = 0; i < options.Length(); i++) {
|
||||
const MediaKeySystemOptions& op = options[i];
|
||||
if (i > 0) {
|
||||
logMsg.AppendLiteral(",");
|
||||
}
|
||||
logMsg.AppendLiteral("{");
|
||||
logMsg.AppendPrintf("stateful='%s'",
|
||||
MediaKeysRequirementValues::strings[(size_t)op.mStateful].value);
|
||||
|
||||
logMsg.AppendPrintf(", uniqueIdentifier='%s'",
|
||||
MediaKeysRequirementValues::strings[(size_t)op.mUniqueidentifier].value);
|
||||
|
||||
if (!op.mAudioCapability.IsEmpty()) {
|
||||
logMsg.AppendPrintf(", audioCapability='%s'",
|
||||
NS_ConvertUTF16toUTF8(op.mAudioCapability).get());
|
||||
}
|
||||
if (!op.mAudioType.IsEmpty()) {
|
||||
logMsg.AppendPrintf(", audioType='%s'",
|
||||
NS_ConvertUTF16toUTF8(op.mAudioType).get());
|
||||
}
|
||||
if (!op.mInitDataType.IsEmpty()) {
|
||||
logMsg.AppendPrintf(", initDataType='%s'",
|
||||
NS_ConvertUTF16toUTF8(op.mInitDataType).get());
|
||||
}
|
||||
if (!op.mVideoCapability.IsEmpty()) {
|
||||
logMsg.AppendPrintf(", videoCapability='%s'",
|
||||
NS_ConvertUTF16toUTF8(op.mVideoCapability).get());
|
||||
}
|
||||
if (!op.mVideoType.IsEmpty()) {
|
||||
logMsg.AppendPrintf(", videoType='%s'",
|
||||
NS_ConvertUTF16toUTF8(op.mVideoType).get());
|
||||
}
|
||||
logMsg.AppendLiteral("}");
|
||||
}
|
||||
}
|
||||
logMsg.AppendPrintf("])");
|
||||
EME_LOG(logMsg.get());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
|
||||
RefPtr<DetailedPromise> promise =
|
||||
DetailedPromise::Create(go, aRv,
|
||||
@ -2913,7 +2870,7 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
mMediaKeySystemAccessManager = new MediaKeySystemAccessManager(mWindow);
|
||||
}
|
||||
|
||||
mMediaKeySystemAccessManager->Request(promise, aKeySystem, aOptions);
|
||||
mMediaKeySystemAccessManager->Request(promise, aKeySystem, aConfigs);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ public:
|
||||
#ifdef MOZ_EME
|
||||
already_AddRefed<Promise>
|
||||
RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
const Optional<Sequence<MediaKeySystemOptions>>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig,
|
||||
ErrorResult& aRv);
|
||||
private:
|
||||
RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager;
|
||||
|
@ -52,10 +52,12 @@ NS_INTERFACE_MAP_END
|
||||
|
||||
MediaKeySystemAccess::MediaKeySystemAccess(nsPIDOMWindow* aParent,
|
||||
const nsAString& aKeySystem,
|
||||
const nsAString& aCDMVersion)
|
||||
const nsAString& aCDMVersion,
|
||||
const MediaKeySystemConfiguration& aConfig)
|
||||
: mParent(aParent)
|
||||
, mKeySystem(aKeySystem)
|
||||
, mCDMVersion(aCDMVersion)
|
||||
, mConfig(aConfig)
|
||||
{
|
||||
}
|
||||
|
||||
@ -81,6 +83,12 @@ MediaKeySystemAccess::GetKeySystem(nsString& aOutKeySystem) const
|
||||
ConstructKeySystem(mKeySystem, mCDMVersion, aOutKeySystem);
|
||||
}
|
||||
|
||||
void
|
||||
MediaKeySystemAccess::GetConfiguration(MediaKeySystemConfiguration& aConfig)
|
||||
{
|
||||
aConfig = mConfig;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
MediaKeySystemAccess::CreateMediaKeys(ErrorResult& aRv)
|
||||
{
|
||||
@ -376,15 +384,11 @@ GMPDecryptsAndGeckoDecodesAAC(mozIGeckoMediaPluginService* aGMPService,
|
||||
static bool
|
||||
IsSupported(mozIGeckoMediaPluginService* aGMPService,
|
||||
const nsAString& aKeySystem,
|
||||
const MediaKeySystemOptions& aConfig)
|
||||
const MediaKeySystemConfiguration& aConfig)
|
||||
{
|
||||
if (!aConfig.mInitDataType.EqualsLiteral("cenc")) {
|
||||
return false;
|
||||
}
|
||||
if (!aConfig.mAudioCapability.IsEmpty() ||
|
||||
!aConfig.mVideoCapability.IsEmpty()) {
|
||||
// Don't support any capabilities until we know we have a CDM with
|
||||
// capabilities...
|
||||
// Backwards compatibility with legacy MediaKeySystemConfiguration method.
|
||||
if (!aConfig.mInitDataType.IsEmpty() &&
|
||||
!aConfig.mInitDataType.EqualsLiteral("cenc")) {
|
||||
return false;
|
||||
}
|
||||
if (!aConfig.mAudioType.IsEmpty() &&
|
||||
@ -405,7 +409,7 @@ IsSupported(mozIGeckoMediaPluginService* aGMPService,
|
||||
/* static */
|
||||
bool
|
||||
MediaKeySystemAccess::IsSupported(const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions)
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs)
|
||||
{
|
||||
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
||||
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
||||
@ -419,7 +423,7 @@ MediaKeySystemAccess::IsSupported(const nsAString& aKeySystem,
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const MediaKeySystemOptions& config : aOptions) {
|
||||
for (const MediaKeySystemConfiguration& config : aConfigs) {
|
||||
if (mozilla::dom::IsSupported(mps, aKeySystem, config)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ public:
|
||||
public:
|
||||
explicit MediaKeySystemAccess(nsPIDOMWindow* aParent,
|
||||
const nsAString& aKeySystem,
|
||||
const nsAString& aCDMVersion);
|
||||
const nsAString& aCDMVersion,
|
||||
const MediaKeySystemConfiguration& aConfig);
|
||||
|
||||
protected:
|
||||
~MediaKeySystemAccess();
|
||||
@ -43,6 +44,8 @@ public:
|
||||
|
||||
void GetKeySystem(nsString& aRetVal) const;
|
||||
|
||||
void GetConfiguration(MediaKeySystemConfiguration& aConfig);
|
||||
|
||||
already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
|
||||
|
||||
|
||||
@ -53,7 +56,7 @@ public:
|
||||
nsACString& aOutCdmVersion);
|
||||
|
||||
static bool IsSupported(const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions);
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs);
|
||||
|
||||
static void NotifyObservers(nsIDOMWindow* aWindow,
|
||||
const nsAString& aKeySystem,
|
||||
@ -67,6 +70,7 @@ private:
|
||||
nsCOMPtr<nsPIDOMWindow> mParent;
|
||||
const nsString mKeySystem;
|
||||
const nsString mCDMVersion;
|
||||
const MediaKeySystemConfiguration mConfig;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -63,16 +63,14 @@ MediaKeySystemAccessManager::~MediaKeySystemAccessManager()
|
||||
void
|
||||
MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Optional<Sequence<MediaKeySystemOptions>>& aOptions)
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs)
|
||||
{
|
||||
if (aKeySystem.IsEmpty() || (aOptions.WasPassed() && aOptions.Value().IsEmpty())) {
|
||||
if (aKeySystem.IsEmpty() || aConfigs.IsEmpty()) {
|
||||
aPromise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
|
||||
NS_LITERAL_CSTRING("Invalid keysystem type or invalid options sequence"));
|
||||
return;
|
||||
}
|
||||
Sequence<MediaKeySystemOptions> optionsNotPassed;
|
||||
const auto& options = aOptions.WasPassed() ? aOptions.Value() : optionsNotPassed;
|
||||
Request(aPromise, aKeySystem, options, RequestType::Initial);
|
||||
Request(aPromise, aKeySystem, aConfigs, RequestType::Initial);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -91,7 +89,7 @@ ShouldTrialCreateGMP(const nsAString& aKeySystem)
|
||||
void
|
||||
MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
RequestType aType)
|
||||
{
|
||||
EME_LOG("MediaKeySystemAccessManager::Request %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
@ -145,7 +143,7 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
// has had a new plugin added. AwaitInstall() sets a timer to fail if the
|
||||
// update/download takes too long or fails.
|
||||
if (aType == RequestType::Initial &&
|
||||
AwaitInstall(aPromise, aKeySystem, aOptions)) {
|
||||
AwaitInstall(aPromise, aKeySystem, aConfigs)) {
|
||||
// Notify chrome that we're going to wait for the CDM to download/update.
|
||||
// Note: If we're re-trying, we don't re-send the notificaiton,
|
||||
// as chrome is already displaying the "we can't play, updating"
|
||||
@ -174,10 +172,11 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
return;
|
||||
}
|
||||
|
||||
if (aOptions.IsEmpty() ||
|
||||
MediaKeySystemAccess::IsSupported(keySystem, aOptions)) {
|
||||
MediaKeySystemConfiguration config;
|
||||
if (aConfigs.IsEmpty() ||
|
||||
MediaKeySystemAccess::IsSupported(keySystem, aConfigs)) {
|
||||
RefPtr<MediaKeySystemAccess> access(
|
||||
new MediaKeySystemAccess(mWindow, keySystem, NS_ConvertUTF8toUTF16(cdmVersion)));
|
||||
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
|
||||
@ -195,11 +194,11 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
|
||||
MediaKeySystemAccessManager::PendingRequest::PendingRequest(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
nsITimer* aTimer)
|
||||
: mPromise(aPromise)
|
||||
, mKeySystem(aKeySystem)
|
||||
, mOptions(aOptions)
|
||||
, mConfigs(aConfigs)
|
||||
, mTimer(aTimer)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
|
||||
@ -208,7 +207,7 @@ MediaKeySystemAccessManager::PendingRequest::PendingRequest(DetailedPromise* aPr
|
||||
MediaKeySystemAccessManager::PendingRequest::PendingRequest(const PendingRequest& aOther)
|
||||
: mPromise(aOther.mPromise)
|
||||
, mKeySystem(aOther.mKeySystem)
|
||||
, mOptions(aOther.mOptions)
|
||||
, mConfigs(aOther.mConfigs)
|
||||
, mTimer(aOther.mTimer)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
|
||||
@ -238,7 +237,7 @@ MediaKeySystemAccessManager::PendingRequest::RejectPromise(const nsCString& aRea
|
||||
bool
|
||||
MediaKeySystemAccessManager::AwaitInstall(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions)
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs)
|
||||
{
|
||||
EME_LOG("MediaKeySystemAccessManager::AwaitInstall %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
|
||||
@ -253,7 +252,7 @@ MediaKeySystemAccessManager::AwaitInstall(DetailedPromise* aPromise,
|
||||
return false;
|
||||
}
|
||||
|
||||
mRequests.AppendElement(PendingRequest(aPromise, aKeySystem, aOptions, timer));
|
||||
mRequests.AppendElement(PendingRequest(aPromise, aKeySystem, aConfigs, timer));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -261,7 +260,7 @@ void
|
||||
MediaKeySystemAccessManager::RetryRequest(PendingRequest& aRequest)
|
||||
{
|
||||
aRequest.CancelTimer();
|
||||
Request(aRequest.mPromise, aRequest.mKeySystem, aRequest.mOptions, RequestType::Subsequent);
|
||||
Request(aRequest.mPromise, aRequest.mKeySystem, aRequest.mConfigs, RequestType::Subsequent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -30,14 +30,14 @@ public:
|
||||
|
||||
void Request(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Optional<Sequence<MediaKeySystemOptions>>& aOptions);
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
struct PendingRequest {
|
||||
PendingRequest(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig,
|
||||
nsITimer* aTimer);
|
||||
PendingRequest(const PendingRequest& aOther);
|
||||
~PendingRequest();
|
||||
@ -46,7 +46,7 @@ public:
|
||||
|
||||
RefPtr<DetailedPromise> mPromise;
|
||||
const nsString mKeySystem;
|
||||
const Sequence<MediaKeySystemOptions> mOptions;
|
||||
const Sequence<MediaKeySystemConfiguration> mConfigs;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
};
|
||||
|
||||
@ -59,7 +59,7 @@ private:
|
||||
|
||||
void Request(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig,
|
||||
RequestType aType);
|
||||
|
||||
~MediaKeySystemAccessManager();
|
||||
@ -68,7 +68,7 @@ private:
|
||||
|
||||
bool AwaitInstall(DetailedPromise* aPromise,
|
||||
const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemOptions>& aOptions);
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig);
|
||||
|
||||
void RetryRequest(PendingRequest& aRequest);
|
||||
|
||||
|
@ -10,25 +10,31 @@
|
||||
* W3C liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
enum MediaKeysRequirement {
|
||||
"required",
|
||||
"optional",
|
||||
"disallowed"
|
||||
dictionary MediaKeySystemMediaCapability {
|
||||
DOMString contentType = "";
|
||||
// TODO: robustness
|
||||
};
|
||||
|
||||
dictionary MediaKeySystemOptions {
|
||||
dictionary MediaKeySystemConfiguration {
|
||||
DOMString label = "";
|
||||
sequence<DOMString> initDataTypes;
|
||||
sequence<MediaKeySystemMediaCapability> audioCapabilities;
|
||||
sequence<MediaKeySystemMediaCapability> videoCapabilities;
|
||||
|
||||
// TODO: distinctiveIdentifier, persistentState, sessionTypes
|
||||
|
||||
// For backwards compatibility with implementations using old
|
||||
// MediaKeySystemOptions paradigm...
|
||||
DOMString initDataType = "";
|
||||
DOMString audioType = "";
|
||||
DOMString audioCapability = "";
|
||||
DOMString videoType = "";
|
||||
DOMString videoCapability = "";
|
||||
MediaKeysRequirement uniqueidentifier = "optional";
|
||||
MediaKeysRequirement stateful = "optional";
|
||||
};
|
||||
|
||||
[Pref="media.eme.apiVisible"]
|
||||
interface MediaKeySystemAccess {
|
||||
readonly attribute DOMString keySystem;
|
||||
[NewObject]
|
||||
MediaKeySystemConfiguration getConfiguration();
|
||||
[NewObject]
|
||||
Promise<MediaKeys> createMediaKeys();
|
||||
};
|
||||
|
@ -447,7 +447,7 @@ partial interface Navigator {
|
||||
[Pref="media.eme.apiVisible", NewObject]
|
||||
Promise<MediaKeySystemAccess>
|
||||
requestMediaKeySystemAccess(DOMString keySystem,
|
||||
optional sequence<MediaKeySystemOptions> supportedConfigurations);
|
||||
sequence<MediaKeySystemConfiguration> supportedConfigurations);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user