diff --git a/dom/media/eme/MediaKeySession.cpp b/dom/media/eme/MediaKeySession.cpp index 4b852dbc9946..2bc63e1f2849 100644 --- a/dom/media/eme/MediaKeySession.cpp +++ b/dom/media/eme/MediaKeySession.cpp @@ -209,11 +209,12 @@ MediaKeySession::GenerateRequest(const nsAString& aInitDataType, aInitDataType, data); EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() sent, " - "promiseId=%d initData(base64)='%s'", + "promiseId=%d initData(base64)='%s' initDataType='%s'", this, NS_ConvertUTF16toUTF8(mSessionId).get(), pid, - base64InitData.get()); + base64InitData.get(), + NS_ConvertUTF16toUTF8(aInitDataType).get()); return promise.forget(); } diff --git a/dom/media/eme/MediaKeySystemAccess.cpp b/dom/media/eme/MediaKeySystemAccess.cpp index 4494f400742e..e66df5b3f25c 100644 --- a/dom/media/eme/MediaKeySystemAccess.cpp +++ b/dom/media/eme/MediaKeySystemAccess.cpp @@ -441,9 +441,12 @@ GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService, if (aCandidate.mInitDataTypes.WasPassed()) { nsTArray initDataTypes; for (const nsString& candidate : aCandidate.mInitDataTypes.Value()) { + // All supported keySystems can handle "cenc" initDataType. + // ClearKey also supports "keyids" and "webm" initDataTypes. if (candidate.EqualsLiteral("cenc")) { initDataTypes.AppendElement(candidate); - } else if (candidate.EqualsLiteral("keyids") && + } else if ((candidate.EqualsLiteral("keyids") || + candidate.EqualsLiteral("webm)")) && aKeySystem.EqualsLiteral("org.w3.clearkey")) { initDataTypes.AppendElement(candidate); } diff --git a/media/gmp-clearkey/0.1/ClearKeySession.cpp b/media/gmp-clearkey/0.1/ClearKeySession.cpp index 8dcad9afa1f1..f7d9ef646e64 100644 --- a/media/gmp-clearkey/0.1/ClearKeySession.cpp +++ b/media/gmp-clearkey/0.1/ClearKeySession.cpp @@ -69,6 +69,11 @@ ClearKeySession::Init(uint32_t aCreateSessionToken, mCallback->RejectPromise(aPromiseId, kGMPAbortError, message, strlen(message)); return; } + } else if (aInitDataType == "webm" && aInitDataSize == 16) { + // "webm" initData format is simply the raw bytes of the keyId. + vector keyId; + keyId.assign(aInitData, aInitData+aInitDataSize); + mKeyIds.push_back(keyId); } if (!mKeyIds.size()) { diff --git a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp index 587a27b90d7f..e6d5bd07ebff 100644 --- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp +++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp @@ -102,10 +102,13 @@ ClearKeySessionManager::CreateSession(uint32_t aCreateSessionToken, CK_LOGD("ClearKeySessionManager::CreateSession type:%s", aInitDataType); string initDataType(aInitDataType, aInitDataType + aInitDataTypeSize); - // initDataType must be "cenc" or "keyids". - if (initDataType != "cenc" && initDataType != "keyids") { + // initDataType must be "cenc", "keyids", or "webm". + if (initDataType != "cenc" && + initDataType != "keyids" && + initDataType != "webm") { + string message = "'" + initDataType + "' is an initDataType unsupported by ClearKey"; mCallback->RejectPromise(aPromiseId, kGMPNotSupportedError, - nullptr /* message */, 0 /* messageLen */); + message.c_str(), message.size()); return; }