--- a/media/gmp-clearkey/0.1/ClearKeyCDM.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyCDM.cpp
@@ -1,29 +1,38 @@
#include "ClearKeyCDM.h"
#include "ClearKeyUtils.h"
using namespace cdm;
-ClearKeyCDM::ClearKeyCDM(Host_8* aHost)
+ClearKeyCDM::ClearKeyCDM(Host_9* aHost)
{
mHost = aHost;
mSessionManager = new ClearKeySessionManager(mHost);
}
void
ClearKeyCDM::Initialize(bool aAllowDistinctiveIdentifier,
bool aAllowPersistentState)
{
mSessionManager->Init(aAllowDistinctiveIdentifier,
aAllowPersistentState);
}
void
+ClearKeyCDM::GetStatusForPolicy(uint32_t aPromiseId,
+ const Policy& aPolicy)
+{
+ // MediaKeys::GetStatusForPolicy checks the keysystem and
+ // reject the promise with NS_ERROR_DOM_NOT_SUPPORTED_ERR without calling CDM.
+ // This function should never be called and is not supported.
+ assert(false);
+}
+void
ClearKeyCDM::SetServerCertificate(uint32_t aPromiseId,
const uint8_t* aServerCertificateData,
uint32_t aServerCertificateDataSize)
{
mSessionManager->SetServerCertificate(aPromiseId,
aServerCertificateData,
aServerCertificateDataSize);
}
@@ -179,19 +188,28 @@ ClearKeyCDM::OnQueryOutputProtectionStat
uint32_t aLinkMask,
uint32_t aOutputProtectionMask)
{
// This function should never be called and is not supported.
assert(false);
}
void
+ClearKeyCDM::OnStorageId(uint32_t aVersion,
+ const uint8_t* aStorageId,
+ uint32_t aStorageIdSize)
+{
+ // This function should never be called and is not supported.
+ assert(false);
+}
+
+void
ClearKeyCDM::Destroy()
{
mSessionManager->DecryptingComplete();
#ifdef ENABLE_WMF
// If we have called 'DeinitializeDecoder' mVideoDecoder will be null.
if (mVideoDecoder) {
mVideoDecoder->DecodingComplete();
}
#endif
delete this;
-}
\ No newline at end of file
+}
--- a/media/gmp-clearkey/0.1/ClearKeyCDM.h
+++ b/media/gmp-clearkey/0.1/ClearKeyCDM.h
@@ -8,33 +8,36 @@
#include "stddef.h"
#include "content_decryption_module.h"
#ifdef ENABLE_WMF
#include "WMFUtils.h"
#include "VideoDecoder.h"
#endif
-class ClearKeyCDM : public cdm::ContentDecryptionModule_8
+class ClearKeyCDM : public cdm::ContentDecryptionModule_9
{
private:
RefPtr<ClearKeySessionManager> mSessionManager;
#ifdef ENABLE_WMF
RefPtr<VideoDecoder> mVideoDecoder;
#endif
protected:
- cdm::Host_8* mHost;
+ cdm::Host_9* mHost;
public:
- explicit ClearKeyCDM(cdm::Host_8* mHost);
+ explicit ClearKeyCDM(cdm::Host_9* mHost);
void Initialize(bool aAllowDistinctiveIdentifier,
bool aAllowPersistentState) override;
+ void GetStatusForPolicy(uint32_t aPromiseId,
+ const cdm::Policy& aPolicy) override;
+
void SetServerCertificate(uint32_t aPromiseId,
const uint8_t* aServerCertificateData,
uint32_t aServerCertificateDataSize)
override;
void CreateSessionAndGenerateRequest(uint32_t aPromiseId,
cdm::SessionType aSessionType,
cdm::InitDataType aInitDataType,
@@ -87,12 +90,16 @@ public:
void OnPlatformChallengeResponse(
const cdm::PlatformChallengeResponse& aResponse) override;
void
OnQueryOutputProtectionStatus(cdm::QueryResult aResult,
uint32_t aLinkMask,
uint32_t aOutputProtectionMask) override;
+ void OnStorageId(uint32_t aVersion,
+ const uint8_t* aStorageId,
+ uint32_t aStorageIdSize) override;
+
void Destroy() override;
};
-#endif
\ No newline at end of file
+#endif
--- a/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp
@@ -96,17 +96,17 @@ ClearKeyPersistence::WriteIndex() {
WriteData(mHost,
filename,
data,
move(onIndexSuccess),
move(onIndexFail));
}
-ClearKeyPersistence::ClearKeyPersistence(Host_8* aHost)
+ClearKeyPersistence::ClearKeyPersistence(Host_9* aHost)
{
this->mHost = aHost;
}
void
ClearKeyPersistence::EnsureInitialized(bool aPersistentStateAllowed,
function<void()>&& aOnInitialized)
{
--- a/media/gmp-clearkey/0.1/ClearKeyPersistence.h
+++ b/media/gmp-clearkey/0.1/ClearKeyPersistence.h
@@ -36,30 +36,30 @@ enum PersistentKeyState {
UNINITIALIZED,
LOADING,
LOADED
};
class ClearKeyPersistence : public RefCounted
{
public:
- explicit ClearKeyPersistence(cdm::Host_8* aHost);
+ explicit ClearKeyPersistence(cdm::Host_9* aHost);
void EnsureInitialized(bool aPersistentStateAllowed,
std::function<void()>&& aOnInitialized);
bool IsLoaded() const;
std::string GetNewSessionId(cdm::SessionType aSessionType);
bool IsPersistentSessionId(const std::string& aSid);
void PersistentSessionRemoved(std::string& aSid);
private:
- cdm::Host_8* mHost = nullptr;
+ cdm::Host_9* mHost = nullptr;
PersistentKeyState mPersistentKeyState = PersistentKeyState::UNINITIALIZED;
std::set<uint32_t> mPersistentSessionIds;
void ReadAllRecordsFromIndex(std::function<void()>&& aOnComplete);
void WriteIndex();
};
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -28,17 +28,17 @@
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
using namespace std;
using namespace cdm;
-ClearKeySessionManager::ClearKeySessionManager(Host_8* aHost)
+ClearKeySessionManager::ClearKeySessionManager(Host_9* aHost)
: mDecryptionManager(ClearKeyDecryptionManager::Get())
{
CK_LOGD("ClearKeySessionManager ctor %p", this);
AddRef();
mHost = aHost;
mPersistence = new ClearKeyPersistence(mHost);
}
@@ -112,17 +112,17 @@ ClearKeySessionManager::CreateSession(ui
// initDataType must be "cenc", "keyids", or "webm".
if (aInitDataType != InitDataType::kCenc &&
aInitDataType != InitDataType::kKeyIds &&
aInitDataType != InitDataType::kWebM) {
string message = "initDataType is not supported by ClearKey";
mHost->OnRejectPromise(aPromiseId,
- Error::kNotSupportedError,
+ Exception::kExceptionNotSupportedError,
0,
message.c_str(),
message.size());
return;
}
string sessionId = mPersistence->GetNewSessionId(aSessionType);
@@ -132,17 +132,17 @@ ClearKeySessionManager::CreateSession(ui
aSessionType);
if (!session->Init(aInitDataType, aInitData, aInitDataSize)) {
CK_LOGD("Failed to initialize session: %s", sessionId.c_str());
const static char* message = "Failed to initialize session";
mHost->OnRejectPromise(aPromiseId,
- Error::kUnknownError,
+ Exception::kExceptionInvalidStateError,
0,
message,
strlen(message));
delete session;
return;
}
@@ -173,19 +173,17 @@ ClearKeySessionManager::CreateSession(ui
mHost->OnResolveNewSessionPromise(aPromiseId,
sessionId.c_str(),
sessionId.size());
mHost->OnSessionMessage(sessionId.c_str(),
sessionId.size(),
MessageType::kLicenseRequest,
request.c_str(),
- request.size(),
- nullptr,
- 0);
+ request.size());
}
void
ClearKeySessionManager::LoadSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength)
{
CK_LOGD("ClearKeySessionManager::LoadSession");
@@ -351,49 +349,49 @@ ClearKeySessionManager::UpdateSession(ui
CK_LOGD("Updating session: %s", sessionId.c_str());
auto itr = mSessions.find(sessionId);
if (itr == mSessions.end() || !(itr->second)) {
CK_LOGW("ClearKey CDM couldn't resolve session ID in UpdateSession.");
CK_LOGD("Unable to find session: %s", sessionId.c_str());
mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
nullptr,
0);
return;
}
ClearKeySession* session = itr->second;
// Verify the size of session response.
if (aResponseSize >= kMaxSessionResponseLength) {
CK_LOGW("Session response size is not within a reasonable size.");
CK_LOGD("Failed to parse response for session %s", sessionId.c_str());
mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
nullptr,
0);
return;
}
// Parse the response for any (key ID, key) pairs.
vector<KeyIdPair> keyPairs;
if (!ClearKeyUtils::ParseJWK(aResponse,
aResponseSize,
keyPairs,
session->Type())) {
CK_LOGW("ClearKey CDM failed to parse JSON Web Key.");
mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
nullptr,
0);
return;
}
vector<KeyInformation> keyInfos;
@@ -437,17 +435,17 @@ ClearKeySessionManager::UpdateSession(ui
function<void()> reject = [self, aPromiseId] ()
{
if (!self->mHost) {
return;
}
static const char* message = "Couldn't store cenc key init data";
self->mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidStateError,
+ Exception::kExceptionInvalidStateError,
0,
message,
strlen(message));
};
WriteData(mHost, sessionId, keydata, move(resolve), move(reject));
}
@@ -498,17 +496,17 @@ ClearKeySessionManager::CloseSession(uin
if (!mHost) {
return;
}
auto itr = mSessions.find(sessionId);
if (itr == mSessions.end()) {
CK_LOGW("ClearKey CDM couldn't close non-existent session.");
mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
nullptr,
0);
return;
}
ClearKeySession* session = itr->second;
@@ -558,17 +556,17 @@ ClearKeySessionManager::RemoveSession(ui
return;
}
auto itr = mSessions.find(sessionId);
if (itr == mSessions.end()) {
CK_LOGW("ClearKey CDM couldn't remove non-existent session.");
mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
nullptr,
0);
return;
}
ClearKeySession* session = itr->second;
@@ -596,34 +594,34 @@ ClearKeySessionManager::RemoveSession(ui
function<void()> reject = [self, aPromiseId] ()
{
if (!self->mHost) {
return;
}
static const char* message = "Could not remove session";
self->mHost->OnRejectPromise(aPromiseId,
- Error::kInvalidAccessError,
+ Exception::kExceptionTypeError,
0,
message,
strlen(message));
};
WriteData(mHost, sessionId, emptyKeydata, move(resolve), move(reject));
}
void
ClearKeySessionManager::SetServerCertificate(uint32_t aPromiseId,
const uint8_t* aServerCert,
uint32_t aServerCertSize)
{
// ClearKey CDM doesn't support this method by spec.
CK_LOGD("ClearKeySessionManager::SetServerCertificate");
mHost->OnRejectPromise(aPromiseId,
- Error::kNotSupportedError,
+ Exception::kExceptionNotSupportedError,
0,
nullptr /* message */,
0 /* messageLen */);
}
Status
ClearKeySessionManager::Decrypt(const InputBuffer& aBuffer,
DecryptedBlock* aDecryptedBlock)
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.h
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.h
@@ -31,17 +31,17 @@
#include <map>
#include <queue>
#include <set>
#include <string>
class ClearKeySessionManager final : public RefCounted
{
public:
- explicit ClearKeySessionManager(cdm::Host_8* aHost);
+ explicit ClearKeySessionManager(cdm::Host_9* aHost);
void Init(bool aDistinctiveIdentifierAllowed,
bool aPersistentStateAllowed);
void CreateSession(uint32_t aPromiseId,
cdm::InitDataType aInitDataType,
const uint8_t* aInitData,
uint32_t aInitDataSize,
@@ -86,17 +86,17 @@ private:
void ClearInMemorySessionData(ClearKeySession* aSession);
bool MaybeDeferTillInitialized(std::function<void()>&& aMaybeDefer);
void Serialize(const ClearKeySession* aSession,
std::vector<uint8_t>& aOutKeyData);
RefPtr<ClearKeyDecryptionManager> mDecryptionManager;
RefPtr<ClearKeyPersistence> mPersistence;
- cdm::Host_8* mHost = nullptr;
+ cdm::Host_9* mHost = nullptr;
std::set<KeyId> mKeyIds;
std::map<std::string, ClearKeySession*> mSessions;
std::queue<std::function<void()>> mDeferredInitialize;
};
#endif // __ClearKeyDecryptor_h__
--- a/media/gmp-clearkey/0.1/ClearKeyStorage.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyStorage.cpp
@@ -32,17 +32,17 @@ using namespace std;
class WriteRecordClient : public FileIOClient
{
public:
/*
* This function will take the memory ownership of the parameters and
* delete them when done.
*/
- static void Write(Host_8* aHost,
+ static void Write(Host_9* aHost,
string& aRecordName,
const vector<uint8_t>& aData,
function<void()>&& aOnSuccess,
function<void()>&& aOnFailure)
{
WriteRecordClient* client = new WriteRecordClient(aData,
move(aOnSuccess),
move(aOnFailure));
@@ -77,17 +77,17 @@ private:
explicit WriteRecordClient(const vector<uint8_t>& aData,
function<void()>&& aOnSuccess,
function<void()>&& aOnFailure)
: mFileIO(nullptr)
, mOnSuccess(move(aOnSuccess))
, mOnFailure(move(aOnFailure))
, mData(aData) {}
- void Do(const string& aName, Host_8* aHost)
+ void Do(const string& aName, Host_9* aHost)
{
// Initialize the FileIO.
mFileIO = aHost->CreateFileIO(this);
mFileIO->Open(aName.c_str(), aName.size());
}
void Done(cdm::FileIOClient::Status aStatus)
{
@@ -113,17 +113,17 @@ private:
function<void()> mOnSuccess;
function<void()> mOnFailure;
const vector<uint8_t> mData;
};
void
-WriteData(Host_8* aHost,
+WriteData(Host_9* aHost,
string& aRecordName,
const vector<uint8_t>& aData,
function<void()>&& aOnSuccess,
function<void()>&& aOnFailure)
{
WriteRecordClient::Write(aHost,
aRecordName,
aData,
@@ -133,17 +133,17 @@ WriteData(Host_8* aHost,
class ReadRecordClient : public FileIOClient
{
public:
/*
* This function will take the memory ownership of the parameters and
* delete them when done.
*/
- static void Read(Host_8* aHost,
+ static void Read(Host_9* aHost,
string& aRecordName,
function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
function<void()>&& aOnFailure)
{
(new ReadRecordClient(move(aOnSuccess), move(aOnFailure)))->
Do(aRecordName, aHost);
}
@@ -174,17 +174,17 @@ public:
private:
explicit ReadRecordClient(function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
function<void()>&& aOnFailure)
: mFileIO(nullptr)
, mOnSuccess(move(aOnSuccess))
, mOnFailure(move(aOnFailure))
{}
- void Do(const string& aName, Host_8* aHost)
+ void Do(const string& aName, Host_9* aHost)
{
mFileIO = aHost->CreateFileIO(this);
mFileIO->Open(aName.c_str(), aName.size());
}
void Done(cdm::FileIOClient::Status aStatus,
const uint8_t* aData,
uint32_t aDataSize)
@@ -209,17 +209,17 @@ private:
FileIO* mFileIO = nullptr;
function<void(const uint8_t*, uint32_t)> mOnSuccess;
function<void()> mOnFailure;
};
void
-ReadData(Host_8* mHost,
+ReadData(Host_9* mHost,
string& aRecordName,
function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
function<void()>&& aOnFailure)
{
ReadRecordClient::Read(mHost,
aRecordName,
move(aOnSuccess),
move(aOnFailure));
--- a/media/gmp-clearkey/0.1/ClearKeyStorage.h
+++ b/media/gmp-clearkey/0.1/ClearKeyStorage.h
@@ -23,21 +23,21 @@
#include <vector>
#include "ClearKeySessionManager.h"
#define IO_SUCCEEDED(x) ((x) == cdm::FileIOClient::Status::kSuccess)
#define IO_FAILED(x) ((x) != cdm::FileIOClient::Status::kSuccess)
// Writes data to a file and fires the appropriate callback when complete.
-void WriteData(cdm::Host_8* aHost,
+void WriteData(cdm::Host_9* aHost,
std::string& aRecordName,
const std::vector<uint8_t>& aData,
std::function<void()>&& aOnSuccess,
std::function<void()>&& aOnFailure);
// Reads data from a file and fires the appropriate callback when complete.
-void ReadData(cdm::Host_8* aHost,
+void ReadData(cdm::Host_9* aHost,
std::string& aRecordName,
std::function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
std::function<void()>&& aOnFailure);
#endif // __ClearKeyStorage_h__
--- a/media/gmp-clearkey/0.1/VideoDecoder.cpp
+++ b/media/gmp-clearkey/0.1/VideoDecoder.cpp
@@ -22,17 +22,17 @@
#include "ClearKeyDecryptionManager.h"
#include "ClearKeyUtils.h"
#include "VideoDecoder.h"
#include "mozilla/CheckedInt.h"
using namespace wmf;
using namespace cdm;
-VideoDecoder::VideoDecoder(Host_8 *aHost)
+VideoDecoder::VideoDecoder(Host_9 *aHost)
: mHost(aHost)
, mHasShutdown(false)
{
CK_LOGD("VideoDecoder created");
// We drop the ref in DecodingComplete().
AddRef();
--- a/media/gmp-clearkey/0.1/VideoDecoder.h
+++ b/media/gmp-clearkey/0.1/VideoDecoder.h
@@ -25,17 +25,17 @@
// on Unix systems.
#include "stddef.h"
#include "content_decryption_module.h"
#include "WMFH264Decoder.h"
class VideoDecoder : public RefCounted
{
public:
- explicit VideoDecoder(cdm::Host_8 *aHost);
+ explicit VideoDecoder(cdm::Host_9 *aHost);
cdm::Status InitDecode(const cdm::VideoDecoderConfig& aConfig);
cdm::Status Decode(const cdm::InputBuffer& aEncryptedBuffer,
cdm::VideoFrame* aVideoFrame);
void Reset();
@@ -59,17 +59,17 @@ private:
HRESULT SampleToVideoFrame(IMFSample* aSample,
int32_t aPictureWidth,
int32_t aPictureHeight,
int32_t aStride,
int32_t aFrameHeight,
cdm::VideoFrame* aVideoFrame);
- cdm::Host_8* mHost;
+ cdm::Host_9* mHost;
wmf::AutoPtr<wmf::WMFH264Decoder> mDecoder;
std::queue<wmf::CComPtr<IMFSample>> mOutputQueue;
bool mHasShutdown;
};
#endif // __VideoDecoder_h__
--- a/media/gmp-clearkey/0.1/gmp-clearkey.cpp
+++ b/media/gmp-clearkey/0.1/gmp-clearkey.cpp
@@ -51,17 +51,17 @@ void* CreateCdmInstance(int cdm_interfac
const char* key_system,
uint32_t key_system_size,
GetCdmHostFunc get_cdm_host_func,
void* user_data)
{
CK_LOGE("ClearKey CreateCDMInstance");
- if (cdm_interface_version != cdm::ContentDecryptionModule_8::kVersion) {
+ if (cdm_interface_version != cdm::ContentDecryptionModule_9::kVersion) {
CK_LOGE("ClearKey CreateCDMInstance failed due to requesting unsupported version %d.",
cdm_interface_version);
return nullptr;
}
#ifdef ENABLE_WMF
if (!wmf::EnsureLibs()) {
CK_LOGE("Required libraries were not found");
return nullptr;
@@ -70,17 +70,17 @@ void* CreateCdmInstance(int cdm_interfac
#ifdef MOZILLA_OFFICIAL
// Test that we're able to read the host files.
if (!sCanReadHostVerificationFiles) {
return nullptr;
}
#endif
- cdm::Host_8* host = static_cast<cdm::Host_8*>(
+ cdm::Host_9* host = static_cast<cdm::Host_9*>(
get_cdm_host_func(cdm_interface_version, user_data));
ClearKeyCDM* clearKey = new ClearKeyCDM(host);
CK_LOGE("Created ClearKeyCDM instance!");
return clearKey;
}
--- a/media/gmp-clearkey/0.1/manifest.json.in
+++ b/media/gmp-clearkey/0.1/manifest.json.in
@@ -1,13 +1,13 @@
{
"name": "clearkey",
"description": "ClearKey Gecko Media Plugin",
"version": "1",
"x-cdm-module-versions": "4",
- "x-cdm-interface-versions": "8",
- "x-cdm-host-versions": "8",
+ "x-cdm-interface-versions": "9",
+ "x-cdm-host-versions": "9",
#ifdef ENABLE_WMF
"x-cdm-codecs": "avc1"
#else
"x-cdm-codecs": ""
#endif
}
\ No newline at end of file