mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 18:07:31 +09:00
Merge remote-tracking branch 'origin/master' into custom
This commit is contained in:
commit
650b24e108
9 changed files with 353 additions and 173 deletions
|
|
@ -46,7 +46,7 @@ void* GetCdmHost(int aHostInterfaceVersion, void* aUserData)
|
||||||
Log("GetCdmHostFunc(%d, %p)", aHostInterfaceVersion, aUserData);
|
Log("GetCdmHostFunc(%d, %p)", aHostInterfaceVersion, aUserData);
|
||||||
WidevineDecryptor* decryptor = reinterpret_cast<WidevineDecryptor*>(aUserData);
|
WidevineDecryptor* decryptor = reinterpret_cast<WidevineDecryptor*>(aUserData);
|
||||||
MOZ_ASSERT(decryptor);
|
MOZ_ASSERT(decryptor);
|
||||||
return static_cast<cdm::Host_8*>(decryptor);
|
return static_cast<cdm::Host_9*>(decryptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STRINGIFY(s) _STRINGIFY(s)
|
#define STRINGIFY(s) _STRINGIFY(s)
|
||||||
|
|
@ -106,8 +106,8 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
|
||||||
|
|
||||||
WidevineDecryptor* decryptor = new WidevineDecryptor();
|
WidevineDecryptor* decryptor = new WidevineDecryptor();
|
||||||
|
|
||||||
auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>(
|
auto cdm = reinterpret_cast<cdm::ContentDecryptionModule_9*>(
|
||||||
create(cdm::ContentDecryptionModule::kVersion,
|
create(cdm::ContentDecryptionModule_9::kVersion,
|
||||||
kEMEKeySystemWidevine.get(),
|
kEMEKeySystemWidevine.get(),
|
||||||
kEMEKeySystemWidevine.Length(),
|
kEMEKeySystemWidevine.Length(),
|
||||||
&GetCdmHost,
|
&GetCdmHost,
|
||||||
|
|
@ -161,8 +161,8 @@ WidevineAdapter::Supports(int32_t aModuleVersion,
|
||||||
int32_t aHostVersion)
|
int32_t aHostVersion)
|
||||||
{
|
{
|
||||||
return aModuleVersion == CDM_MODULE_VERSION &&
|
return aModuleVersion == CDM_MODULE_VERSION &&
|
||||||
aInterfaceVersion == cdm::ContentDecryptionModule::kVersion &&
|
aInterfaceVersion == cdm::ContentDecryptionModule_9::kVersion &&
|
||||||
aHostVersion == cdm::Host_8::kVersion;
|
aHostVersion == cdm::Host_9::kVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ WidevineDecryptor::CreateSession(uint32_t aCreateSessionToken,
|
||||||
} else {
|
} else {
|
||||||
// Invalid init data type
|
// Invalid init data type
|
||||||
const char* errorMsg = "Invalid init data type when creating session.";
|
const char* errorMsg = "Invalid init data type when creating session.";
|
||||||
OnRejectPromise(aPromiseId, kNotSupportedError, 0, errorMsg, sizeof(errorMsg));
|
OnRejectPromise(aPromiseId, kExceptionNotSupportedError, 0, errorMsg, sizeof(errorMsg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mPromiseIdToNewSessionTokens[aPromiseId] = aCreateSessionToken;
|
mPromiseIdToNewSessionTokens[aPromiseId] = aCreateSessionToken;
|
||||||
|
|
@ -301,6 +301,12 @@ WidevineDecryptor::GetCurrentWallTime()
|
||||||
return base::Time::Now().ToDoubleT();
|
return base::Time::Now().ToDoubleT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WidevineDecryptor::OnResolveKeyStatusPromise(uint32_t aPromiseId,
|
||||||
|
cdm::KeyStatus aKeyStatus) {
|
||||||
|
//TODO: The callback of GetStatusForPolicy. See Mozilla bug 1404230.
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WidevineDecryptor::OnResolveNewSessionPromise(uint32_t aPromiseId,
|
WidevineDecryptor::OnResolveNewSessionPromise(uint32_t aPromiseId,
|
||||||
const char* aSessionId,
|
const char* aSessionId,
|
||||||
|
|
@ -333,41 +339,59 @@ WidevineDecryptor::OnResolvePromise(uint32_t aPromiseId)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GMPDOMException
|
static GMPDOMException
|
||||||
ToGMPDOMException(cdm::Error aError)
|
ConvertCDMExceptionToGMPDOMException(cdm::Exception aException)
|
||||||
{
|
{
|
||||||
switch (aError) {
|
switch (aException) {
|
||||||
case kNotSupportedError: return kGMPNotSupportedError;
|
case kExceptionNotSupportedError: return kGMPNotSupportedError;
|
||||||
case kInvalidStateError: return kGMPInvalidStateError;
|
case kExceptionInvalidStateError: return kGMPInvalidStateError;
|
||||||
case kInvalidAccessError:
|
case kExceptionTypeError: return kGMPTypeError;
|
||||||
// Note: Chrome converts kInvalidAccessError to TypeError, since the
|
case kExceptionQuotaExceededError: return kGMPQuotaExceededError;
|
||||||
// Chromium CDM API doesn't have a type error enum value. The EME spec
|
|
||||||
// requires TypeError in some places, so we do the same conversion.
|
|
||||||
// See bug 1313202.
|
|
||||||
return kGMPTypeError;
|
|
||||||
case kQuotaExceededError: return kGMPQuotaExceededError;
|
|
||||||
case kUnknownError: return kGMPInvalidModificationError; // Note: Unique placeholder.
|
case kUnknownError: return kGMPInvalidModificationError; // Note: Unique placeholder.
|
||||||
case kClientError: return kGMPAbortError; // Note: Unique placeholder.
|
case kClientError: return kGMPAbortError; // Note: Unique placeholder.
|
||||||
case kOutputError: return kGMPSecurityError; // Note: Unique placeholder.
|
case kOutputError: return kGMPSecurityError; // Note: Unique placeholder.
|
||||||
};
|
};
|
||||||
return kGMPTimeoutError; // Note: Unique placeholder.
|
return kGMPInvalidStateError; // Note: Unique placeholder.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Align with spec, the Exceptions used by CDM to reject promises .
|
||||||
|
// https://w3c.github.io/encrypted-media/#exceptions
|
||||||
|
cdm::Exception
|
||||||
|
ConvertCDMErrorToCDMException(cdm::Error error) {
|
||||||
|
switch (error) {
|
||||||
|
case cdm::kNotSupportedError:
|
||||||
|
return cdm::Exception::kExceptionNotSupportedError;
|
||||||
|
case cdm::kInvalidStateError:
|
||||||
|
return cdm::Exception::kExceptionInvalidStateError;
|
||||||
|
case cdm::kInvalidAccessError:
|
||||||
|
return cdm::Exception::kExceptionTypeError;
|
||||||
|
case cdm::kQuotaExceededError:
|
||||||
|
return cdm::Exception::kExceptionQuotaExceededError;
|
||||||
|
|
||||||
|
case cdm::kUnknownError:
|
||||||
|
case cdm::kClientError:
|
||||||
|
case cdm::kOutputError:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cdm::Exception::kExceptionInvalidStateError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WidevineDecryptor::OnRejectPromise(uint32_t aPromiseId,
|
WidevineDecryptor::OnRejectPromise(uint32_t aPromiseId,
|
||||||
Error aError,
|
cdm::Exception aException,
|
||||||
uint32_t aSystemCode,
|
uint32_t aSystemCode,
|
||||||
const char* aErrorMessage,
|
const char* aErrorMessage,
|
||||||
uint32_t aErrorMessageSize)
|
uint32_t aErrorMessageSize)
|
||||||
{
|
{
|
||||||
if (!mCallback) {
|
if (!mCallback) {
|
||||||
Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s) FAIL; !mCallback",
|
Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s) FAIL; !mCallback",
|
||||||
aPromiseId, (int)aError, aSystemCode, aErrorMessage);
|
aPromiseId, (int)aException, aSystemCode, aErrorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s)",
|
Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s)",
|
||||||
aPromiseId, (int)aError, aSystemCode, aErrorMessage);
|
aPromiseId, (int)aException, aSystemCode, aErrorMessage);
|
||||||
mCallback->RejectPromise(aPromiseId,
|
mCallback->RejectPromise(aPromiseId,
|
||||||
ToGMPDOMException(aError),
|
ConvertCDMExceptionToGMPDOMException(aException),
|
||||||
!aErrorMessageSize ? "" : aErrorMessage,
|
!aErrorMessageSize ? "" : aErrorMessage,
|
||||||
aErrorMessageSize);
|
aErrorMessageSize);
|
||||||
}
|
}
|
||||||
|
|
@ -386,11 +410,9 @@ ToGMPMessageType(MessageType message_type)
|
||||||
void
|
void
|
||||||
WidevineDecryptor::OnSessionMessage(const char* aSessionId,
|
WidevineDecryptor::OnSessionMessage(const char* aSessionId,
|
||||||
uint32_t aSessionIdSize,
|
uint32_t aSessionIdSize,
|
||||||
MessageType aMessageType,
|
cdm::MessageType aMessageType,
|
||||||
const char* aMessage,
|
const char* aMessage,
|
||||||
uint32_t aMessageSize,
|
uint32_t aMessageSize)
|
||||||
const char* aLegacyDestinationUrl,
|
|
||||||
uint32_t aLegacyDestinationUrlLength)
|
|
||||||
{
|
{
|
||||||
if (!mCallback) {
|
if (!mCallback) {
|
||||||
Log("Decryptor::OnSessionMessage() FAIL; !mCallback");
|
Log("Decryptor::OnSessionMessage() FAIL; !mCallback");
|
||||||
|
|
@ -478,28 +500,6 @@ WidevineDecryptor::OnSessionClosed(const char* aSessionId,
|
||||||
mCallback->SessionClosed(aSessionId, aSessionIdSize);
|
mCallback->SessionClosed(aSessionId, aSessionIdSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
WidevineDecryptor::OnLegacySessionError(const char* aSessionId,
|
|
||||||
uint32_t aSessionIdLength,
|
|
||||||
Error aError,
|
|
||||||
uint32_t aSystemCode,
|
|
||||||
const char* aErrorMessage,
|
|
||||||
uint32_t aErrorMessageLength)
|
|
||||||
{
|
|
||||||
if (!mCallback) {
|
|
||||||
Log("Decryptor::OnLegacySessionError(sid=%s, error=%d) FAIL; !mCallback",
|
|
||||||
aSessionId, (int)aError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log("Decryptor::OnLegacySessionError(sid=%s, error=%d)", aSessionId, (int)aError);
|
|
||||||
mCallback->SessionError(aSessionId,
|
|
||||||
aSessionIdLength,
|
|
||||||
ToGMPDOMException(aError),
|
|
||||||
aSystemCode,
|
|
||||||
aErrorMessage,
|
|
||||||
aErrorMessageLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WidevineDecryptor::SendPlatformChallenge(const char* aServiceId,
|
WidevineDecryptor::SendPlatformChallenge(const char* aServiceId,
|
||||||
uint32_t aServiceIdSize,
|
uint32_t aServiceIdSize,
|
||||||
|
|
@ -538,4 +538,17 @@ WidevineDecryptor::CreateFileIO(FileIOClient* aClient)
|
||||||
return new WidevineFileIO(aClient);
|
return new WidevineFileIO(aClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WidevineDecryptor::RequestStorageId(uint32_t aVersion)
|
||||||
|
{
|
||||||
|
Log("Decryptor::RequestStorageId() aVersion = %u", aVersion);
|
||||||
|
if (aVersion >= 0x80000000) {
|
||||||
|
mCDM->OnStorageId(aVersion, nullptr, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Need to provide a menaingful buffer instead of a dummy one.
|
||||||
|
mCDM->OnStorageId(aVersion, new uint8_t[1024*1024], 1024 * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
class WidevineDecryptor : public GMPDecryptor
|
class WidevineDecryptor : public GMPDecryptor
|
||||||
, public cdm::Host_8
|
, public cdm::Host_9
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -69,16 +69,19 @@ public:
|
||||||
void DecryptingComplete() override;
|
void DecryptingComplete() override;
|
||||||
|
|
||||||
|
|
||||||
// cdm::Host_8
|
// cdm::Host_9 implementation
|
||||||
cdm::Buffer* Allocate(uint32_t aCapacity) override;
|
cdm::Buffer* Allocate(uint32_t aCapacity) override;
|
||||||
void SetTimer(int64_t aDelayMs, void* aContext) override;
|
void SetTimer(int64_t aDelayMs, void* aContext) override;
|
||||||
cdm::Time GetCurrentWallTime() override;
|
cdm::Time GetCurrentWallTime() override;
|
||||||
|
// cdm::Host_9 interface
|
||||||
|
void OnResolveKeyStatusPromise(uint32_t aPromiseId,
|
||||||
|
cdm::KeyStatus aKeyStatus) override;
|
||||||
void OnResolveNewSessionPromise(uint32_t aPromiseId,
|
void OnResolveNewSessionPromise(uint32_t aPromiseId,
|
||||||
const char* aSessionId,
|
const char* aSessionId,
|
||||||
uint32_t aSessionIdSize) override;
|
uint32_t aSessionIdSize) override;
|
||||||
void OnResolvePromise(uint32_t aPromiseId) override;
|
void OnResolvePromise(uint32_t aPromiseId) override;
|
||||||
void OnRejectPromise(uint32_t aPromiseId,
|
void OnRejectPromise(uint32_t aPromiseId,
|
||||||
cdm::Error aError,
|
cdm::Exception aException,
|
||||||
uint32_t aSystemCode,
|
uint32_t aSystemCode,
|
||||||
const char* aErrorMessage,
|
const char* aErrorMessage,
|
||||||
uint32_t aErrorMessageSize) override;
|
uint32_t aErrorMessageSize) override;
|
||||||
|
|
@ -86,9 +89,7 @@ public:
|
||||||
uint32_t aSessionIdSize,
|
uint32_t aSessionIdSize,
|
||||||
cdm::MessageType aMessageType,
|
cdm::MessageType aMessageType,
|
||||||
const char* aMessage,
|
const char* aMessage,
|
||||||
uint32_t aMessageSize,
|
uint32_t aMessageSize) override;
|
||||||
const char* aLegacyDestinationUrl,
|
|
||||||
uint32_t aLegacyDestinationUrlLength) override;
|
|
||||||
void OnSessionKeysChange(const char* aSessionId,
|
void OnSessionKeysChange(const char* aSessionId,
|
||||||
uint32_t aSessionIdSize,
|
uint32_t aSessionIdSize,
|
||||||
bool aHasAdditionalUsableKey,
|
bool aHasAdditionalUsableKey,
|
||||||
|
|
@ -99,12 +100,6 @@ public:
|
||||||
cdm::Time aNewExpiryTime) override;
|
cdm::Time aNewExpiryTime) override;
|
||||||
void OnSessionClosed(const char* aSessionId,
|
void OnSessionClosed(const char* aSessionId,
|
||||||
uint32_t aSessionIdSize) override;
|
uint32_t aSessionIdSize) override;
|
||||||
void OnLegacySessionError(const char* aSessionId,
|
|
||||||
uint32_t aSessionId_length,
|
|
||||||
cdm::Error aError,
|
|
||||||
uint32_t aSystemCode,
|
|
||||||
const char* aErrorMessage,
|
|
||||||
uint32_t aErrorMessageLength) override;
|
|
||||||
void SendPlatformChallenge(const char* aServiceId,
|
void SendPlatformChallenge(const char* aServiceId,
|
||||||
uint32_t aServiceIdSize,
|
uint32_t aServiceIdSize,
|
||||||
const char* aChallenge,
|
const char* aChallenge,
|
||||||
|
|
@ -113,6 +108,9 @@ public:
|
||||||
void QueryOutputProtectionStatus() override;
|
void QueryOutputProtectionStatus() override;
|
||||||
void OnDeferredInitializationDone(cdm::StreamType aStreamType,
|
void OnDeferredInitializationDone(cdm::StreamType aStreamType,
|
||||||
cdm::Status aDecoderStatus) override;
|
cdm::Status aDecoderStatus) override;
|
||||||
|
// cdm::Host_9 interface
|
||||||
|
// NOTE: the interface has changed upstream.
|
||||||
|
void RequestStorageId(uint32_t aVersion) override;
|
||||||
cdm::FileIO* CreateFileIO(cdm::FileIOClient* aClient) override;
|
cdm::FileIO* CreateFileIO(cdm::FileIOClient* aClient) override;
|
||||||
|
|
||||||
GMPDecryptorCallback* Callback() const { return mCallback; }
|
GMPDecryptorCallback* Callback() const { return mCallback; }
|
||||||
|
|
@ -120,7 +118,7 @@ public:
|
||||||
private:
|
private:
|
||||||
~WidevineDecryptor();
|
~WidevineDecryptor();
|
||||||
RefPtr<CDMWrapper> mCDM;
|
RefPtr<CDMWrapper> mCDM;
|
||||||
cdm::ContentDecryptionModule_8* CDM() { return mCDM->GetCDM(); }
|
cdm::ContentDecryptionModule_9* CDM() { return mCDM->GetCDM(); }
|
||||||
|
|
||||||
GMPDecryptorCallback* mCallback;
|
GMPDecryptorCallback* mCallback;
|
||||||
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
|
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ ToGMPErr(cdm::Status aStatus)
|
||||||
case cdm::kSuccess: return GMPNoErr;
|
case cdm::kSuccess: return GMPNoErr;
|
||||||
case cdm::kNeedMoreData: return GMPGenericErr;
|
case cdm::kNeedMoreData: return GMPGenericErr;
|
||||||
case cdm::kNoKey: return GMPNoKeyErr;
|
case cdm::kNoKey: return GMPNoKeyErr;
|
||||||
case cdm::kSessionError: return GMPGenericErr;
|
case cdm::kInitializationError: return GMPGenericErr;
|
||||||
case cdm::kDecryptError: return GMPCryptoErr;
|
case cdm::kDecryptError: return GMPCryptoErr;
|
||||||
case cdm::kDecodeError: return GMPDecodeErr;
|
case cdm::kDecodeError: return GMPDecodeErr;
|
||||||
case cdm::kDeferredInitialization: return GMPGenericErr;
|
case cdm::kDeferredInitialization: return GMPGenericErr;
|
||||||
|
|
@ -77,7 +77,7 @@ void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
|
||||||
aInputBuffer.timestamp = aTimestamp;
|
aInputBuffer.timestamp = aTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDMWrapper::CDMWrapper(cdm::ContentDecryptionModule_8* aCDM,
|
CDMWrapper::CDMWrapper(cdm::ContentDecryptionModule_9* aCDM,
|
||||||
WidevineDecryptor* aDecryptor)
|
WidevineDecryptor* aDecryptor)
|
||||||
: mCDM(aCDM)
|
: mCDM(aCDM)
|
||||||
, mDecryptor(aDecryptor)
|
, mDecryptor(aDecryptor)
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,16 @@ class CDMWrapper {
|
||||||
public:
|
public:
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMWrapper)
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMWrapper)
|
||||||
|
|
||||||
explicit CDMWrapper(cdm::ContentDecryptionModule_8* aCDM,
|
explicit CDMWrapper(cdm::ContentDecryptionModule_9* aCDM,
|
||||||
WidevineDecryptor* aDecryptor);
|
WidevineDecryptor* aDecryptor);
|
||||||
cdm::ContentDecryptionModule_8* GetCDM() const { return mCDM; }
|
cdm::ContentDecryptionModule_9* GetCDM() const { return mCDM; }
|
||||||
|
void OnStorageId(uint32_t aVersion, const uint8_t* aStorageId,
|
||||||
|
uint32_t aStorageIdSize) {
|
||||||
|
mCDM->OnStorageId(aVersion, aStorageId, aStorageIdSize);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
~CDMWrapper();
|
~CDMWrapper();
|
||||||
cdm::ContentDecryptionModule_8* mCDM;
|
cdm::ContentDecryptionModule_9* mCDM;
|
||||||
RefPtr<WidevineDecryptor> mDecryptor;
|
RefPtr<WidevineDecryptor> mDecryptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ private:
|
||||||
|
|
||||||
~WidevineVideoDecoder();
|
~WidevineVideoDecoder();
|
||||||
|
|
||||||
cdm::ContentDecryptionModule_8* CDM() const {
|
cdm::ContentDecryptionModule_9* CDM() const {
|
||||||
// CDM should only be accessed before 'DecodingComplete'.
|
// CDM should only be accessed before 'DecodingComplete'.
|
||||||
MOZ_ASSERT(mCDMWrapper);
|
MOZ_ASSERT(mCDMWrapper);
|
||||||
// CDMWrapper ensure the CDM is non-null, no need to check again.
|
// CDMWrapper ensure the CDM is non-null, no need to check again.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef CDM_CONTENT_DECRYPTION_MODULE_H_
|
#ifndef CDM_CONTENT_DECRYPTION_MODULE_H_
|
||||||
#define CDM_CONTENT_DECRYPTION_MODULE_H_
|
#define CDM_CONTENT_DECRYPTION_MODULE_H_
|
||||||
|
|
||||||
|
#include "content_decryption_module_export.h"
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
|
|
@ -14,25 +16,21 @@ typedef __int64 int64_t;
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define CDM_EXPORT so that functionality implemented by the CDM module
|
// Define CDM_CLASS_API to export class types. We have to add visibility
|
||||||
// can be exported to consumers.
|
// attributes to make sure virtual tables in CDM consumer and CDM implementation
|
||||||
#if defined(WIN32)
|
// are the same. Generally, it was always a good idea, as there're no guarantees
|
||||||
|
// about that for the internal symbols, but it has only become a practical issue
|
||||||
#if defined(CDM_IMPLEMENTATION)
|
// after introduction of LTO devirtualization. See more details on
|
||||||
#define CDM_EXPORT __declspec(dllexport)
|
// https://crbug.com/609564#c35
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define CDM_CLASS_API [[clang::lto_visibility_public]]
|
||||||
#else
|
#else
|
||||||
#define CDM_EXPORT __declspec(dllimport)
|
#define CDM_CLASS_API
|
||||||
#endif // defined(CDM_IMPLEMENTATION)
|
|
||||||
|
|
||||||
#else // defined(WIN32)
|
|
||||||
|
|
||||||
#if defined(CDM_IMPLEMENTATION)
|
|
||||||
#define CDM_EXPORT __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define CDM_EXPORT
|
|
||||||
#endif
|
#endif
|
||||||
|
#else // defined(_WIN32)
|
||||||
#endif // defined(WIN32)
|
#define CDM_CLASS_API __attribute__((visibility("default")))
|
||||||
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
// The version number must be rolled when the exported functions are updated!
|
// The version number must be rolled when the exported functions are updated!
|
||||||
// If the CDM and the adapter use different versions of these functions, the
|
// If the CDM and the adapter use different versions of these functions, the
|
||||||
|
|
@ -48,9 +46,9 @@ typedef __int64 int64_t;
|
||||||
#define BUILD_ENTRYPOINT_NO_EXPANSION(name, version) name##_##version
|
#define BUILD_ENTRYPOINT_NO_EXPANSION(name, version) name##_##version
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
CDM_EXPORT void INITIALIZE_CDM_MODULE();
|
CDM_API void INITIALIZE_CDM_MODULE();
|
||||||
|
|
||||||
CDM_EXPORT void DeinitializeCdmModule();
|
CDM_API void DeinitializeCdmModule();
|
||||||
|
|
||||||
// Returns a pointer to the requested CDM Host interface upon success.
|
// Returns a pointer to the requested CDM Host interface upon success.
|
||||||
// Returns NULL if the requested CDM Host interface is not supported.
|
// Returns NULL if the requested CDM Host interface is not supported.
|
||||||
|
|
@ -65,28 +63,28 @@ typedef void* (*GetCdmHostFunc)(int host_interface_version, void* user_data);
|
||||||
// |cdm_interface_version|.
|
// |cdm_interface_version|.
|
||||||
// Caller retains ownership of arguments and must call Destroy() on the returned
|
// Caller retains ownership of arguments and must call Destroy() on the returned
|
||||||
// object.
|
// object.
|
||||||
CDM_EXPORT void* CreateCdmInstance(
|
CDM_API void* CreateCdmInstance(
|
||||||
int cdm_interface_version,
|
int cdm_interface_version,
|
||||||
const char* key_system, uint32_t key_system_size,
|
const char* key_system, uint32_t key_system_size,
|
||||||
GetCdmHostFunc get_cdm_host_func, void* user_data);
|
GetCdmHostFunc get_cdm_host_func, void* user_data);
|
||||||
|
|
||||||
CDM_EXPORT const char* GetCdmVersion();
|
CDM_API const char* GetCdmVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cdm {
|
namespace cdm {
|
||||||
|
|
||||||
class AudioFrames;
|
class CDM_CLASS_API AudioFrames;
|
||||||
class DecryptedBlock;
|
class CDM_CLASS_API DecryptedBlock;
|
||||||
class VideoFrame;
|
class CDM_CLASS_API VideoFrame;
|
||||||
|
|
||||||
class Host_7;
|
class CDM_CLASS_API Host_8;
|
||||||
class Host_8;
|
class CDM_CLASS_API Host_9;
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
kSuccess = 0,
|
kSuccess = 0,
|
||||||
kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample.
|
kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample.
|
||||||
kNoKey, // The required decryption key is not available.
|
kNoKey, // The required decryption key is not available.
|
||||||
kSessionError, // Session management error.
|
kInitializationError, // Initialization error.
|
||||||
kDecryptError, // Decryption failed.
|
kDecryptError, // Decryption failed.
|
||||||
kDecodeError, // Error decoding audio or video.
|
kDecodeError, // Error decoding audio or video.
|
||||||
kDeferredInitialization // Decoder is not ready for initialization.
|
kDeferredInitialization // Decoder is not ready for initialization.
|
||||||
|
|
@ -97,6 +95,7 @@ enum Status {
|
||||||
// The following starts with the list of DOM4 exceptions from:
|
// The following starts with the list of DOM4 exceptions from:
|
||||||
// http://www.w3.org/TR/dom/#domexception
|
// http://www.w3.org/TR/dom/#domexception
|
||||||
// Some DOM4 exceptions are not included as they are not expected to be used.
|
// Some DOM4 exceptions are not included as they are not expected to be used.
|
||||||
|
// Should only be used on Host_8 and before.
|
||||||
enum Error {
|
enum Error {
|
||||||
kNotSupportedError = 9,
|
kNotSupportedError = 9,
|
||||||
kInvalidStateError = 11,
|
kInvalidStateError = 11,
|
||||||
|
|
@ -113,8 +112,20 @@ enum Error {
|
||||||
kOutputError = 101
|
kOutputError = 101
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time is defined as the number of seconds since the
|
// Exceptions used by the CDM to reject promises.
|
||||||
// Epoch (00:00:00 UTC, January 1, 1970).
|
// https://w3c.github.io/encrypted-media/#exceptions
|
||||||
|
enum Exception {
|
||||||
|
kExceptionTypeError,
|
||||||
|
kExceptionNotSupportedError,
|
||||||
|
kExceptionInvalidStateError,
|
||||||
|
kExceptionQuotaExceededError
|
||||||
|
};
|
||||||
|
|
||||||
|
// Time is defined as the number of seconds since the Epoch
|
||||||
|
// (00:00:00 UTC, January 1, 1970), not including any added leap second.
|
||||||
|
// Also see Time definition in spec: https://w3c.github.io/encrypted-media/#time
|
||||||
|
// Note that Time is defined in millisecond accuracy in the spec but in second
|
||||||
|
// accuracy here.
|
||||||
typedef double Time;
|
typedef double Time;
|
||||||
|
|
||||||
// An input buffer can be split into several continuous subsamples.
|
// An input buffer can be split into several continuous subsamples.
|
||||||
|
|
@ -151,13 +162,13 @@ struct SubsampleEntry {
|
||||||
// unencrypted.
|
// unencrypted.
|
||||||
struct InputBuffer {
|
struct InputBuffer {
|
||||||
InputBuffer()
|
InputBuffer()
|
||||||
: data(NULL),
|
: data(nullptr),
|
||||||
data_size(0),
|
data_size(0),
|
||||||
key_id(NULL),
|
key_id(nullptr),
|
||||||
key_id_size(0),
|
key_id_size(0),
|
||||||
iv(NULL),
|
iv(nullptr),
|
||||||
iv_size(0),
|
iv_size(0),
|
||||||
subsamples(NULL),
|
subsamples(nullptr),
|
||||||
num_subsamples(0),
|
num_subsamples(0),
|
||||||
timestamp(0) {}
|
timestamp(0) {}
|
||||||
|
|
||||||
|
|
@ -188,7 +199,7 @@ struct AudioDecoderConfig {
|
||||||
channel_count(0),
|
channel_count(0),
|
||||||
bits_per_channel(0),
|
bits_per_channel(0),
|
||||||
samples_per_second(0),
|
samples_per_second(0),
|
||||||
extra_data(NULL),
|
extra_data(nullptr),
|
||||||
extra_data_size(0) {}
|
extra_data_size(0) {}
|
||||||
|
|
||||||
AudioCodec codec;
|
AudioCodec codec;
|
||||||
|
|
@ -214,10 +225,25 @@ enum AudioFormat {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php
|
// Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php
|
||||||
|
// Values are chosen to be consistent with Chromium's VideoPixelFormat values.
|
||||||
enum VideoFormat {
|
enum VideoFormat {
|
||||||
kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting.
|
kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting.
|
||||||
kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
|
kYv12 = 1, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
|
||||||
kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
|
kI420 = 2, // 12bpp YUV planar 1x1 Y, 2x2 UV samples.
|
||||||
|
|
||||||
|
// In the following formats, each sample uses 16-bit in storage, while the
|
||||||
|
// sample value is stored in the least significant N bits where N is
|
||||||
|
// specified by the number after "P". For example, for YUV420P9, each Y, U,
|
||||||
|
// and V sample is stored in the least significant 9 bits in a 2-byte block.
|
||||||
|
kYUV420P9 = 16,
|
||||||
|
kYUV420P10 = 17,
|
||||||
|
kYUV422P9 = 18,
|
||||||
|
kYUV422P10 = 19,
|
||||||
|
kYUV444P9 = 20,
|
||||||
|
kYUV444P10 = 21,
|
||||||
|
kYUV420P12 = 22,
|
||||||
|
kYUV422P12 = 23,
|
||||||
|
kYUV444P12 = 24,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Size {
|
struct Size {
|
||||||
|
|
@ -245,14 +271,19 @@ struct VideoDecoderConfig {
|
||||||
kH264ProfileHigh,
|
kH264ProfileHigh,
|
||||||
kH264ProfileHigh10,
|
kH264ProfileHigh10,
|
||||||
kH264ProfileHigh422,
|
kH264ProfileHigh422,
|
||||||
kH264ProfileHigh444Predictive
|
kH264ProfileHigh444Predictive,
|
||||||
|
// VP9 Profiles are only passed in starting from CDM_9.
|
||||||
|
kVP9Profile0,
|
||||||
|
kVP9Profile1,
|
||||||
|
kVP9Profile2,
|
||||||
|
kVP9Profile3
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoDecoderConfig()
|
VideoDecoderConfig()
|
||||||
: codec(kUnknownVideoCodec),
|
: codec(kUnknownVideoCodec),
|
||||||
profile(kUnknownVideoCodecProfile),
|
profile(kUnknownVideoCodecProfile),
|
||||||
format(kUnknownVideoFormat),
|
format(kUnknownVideoFormat),
|
||||||
extra_data(NULL),
|
extra_data(nullptr),
|
||||||
extra_data_size(0) {}
|
extra_data_size(0) {}
|
||||||
|
|
||||||
VideoCodec codec;
|
VideoCodec codec;
|
||||||
|
|
@ -294,7 +325,7 @@ struct PlatformChallengeResponse {
|
||||||
|
|
||||||
// Used when passing arrays of binary data. Does not own the referenced data.
|
// Used when passing arrays of binary data. Does not own the referenced data.
|
||||||
struct BinaryData {
|
struct BinaryData {
|
||||||
BinaryData() : data(NULL), length(0) {}
|
BinaryData() : data(nullptr), length(0) {}
|
||||||
const uint8_t* data;
|
const uint8_t* data;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
@ -316,7 +347,10 @@ enum KeyStatus {
|
||||||
// should be 0 when |status| == kUsable.
|
// should be 0 when |status| == kUsable.
|
||||||
struct KeyInformation {
|
struct KeyInformation {
|
||||||
KeyInformation()
|
KeyInformation()
|
||||||
: key_id(NULL), key_id_size(0), status(kInternalError), system_code(0) {}
|
: key_id(nullptr),
|
||||||
|
key_id_size(0),
|
||||||
|
status(kInternalError),
|
||||||
|
system_code(0) {}
|
||||||
const uint8_t* key_id;
|
const uint8_t* key_id;
|
||||||
uint32_t key_id_size;
|
uint32_t key_id_size;
|
||||||
KeyStatus status;
|
KeyStatus status;
|
||||||
|
|
@ -372,6 +406,24 @@ enum MessageType {
|
||||||
kLicenseRelease = 2
|
kLicenseRelease = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum HdcpVersion {
|
||||||
|
kHdcpVersionNone,
|
||||||
|
kHdcpVersion1_0,
|
||||||
|
kHdcpVersion1_1,
|
||||||
|
kHdcpVersion1_2,
|
||||||
|
kHdcpVersion1_3,
|
||||||
|
kHdcpVersion1_4,
|
||||||
|
kHdcpVersion2_0,
|
||||||
|
kHdcpVersion2_1,
|
||||||
|
kHdcpVersion2_2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Policy {
|
||||||
|
Policy() : min_hdcp_version(kHdcpVersionNone) {}
|
||||||
|
|
||||||
|
HdcpVersion min_hdcp_version;
|
||||||
|
};
|
||||||
|
|
||||||
// FileIO interface provides a way for the CDM to store data in a file in
|
// FileIO interface provides a way for the CDM to store data in a file in
|
||||||
// persistent storage. This interface aims only at providing basic read/write
|
// persistent storage. This interface aims only at providing basic read/write
|
||||||
// capabilities and should not be used as a full fledged file IO API.
|
// capabilities and should not be used as a full fledged file IO API.
|
||||||
|
|
@ -381,7 +433,7 @@ enum MessageType {
|
||||||
// Note to implementors of this interface:
|
// Note to implementors of this interface:
|
||||||
// Per-origin storage and the ability for users to clear it are important.
|
// Per-origin storage and the ability for users to clear it are important.
|
||||||
// See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo.
|
// See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo.
|
||||||
class FileIO {
|
class CDM_CLASS_API FileIO {
|
||||||
public:
|
public:
|
||||||
// Opens the file with |file_name| for read and write.
|
// Opens the file with |file_name| for read and write.
|
||||||
// FileIOClient::OnOpenComplete() will be called after the opening
|
// FileIOClient::OnOpenComplete() will be called after the opening
|
||||||
|
|
@ -389,8 +441,9 @@ class FileIO {
|
||||||
// - When the file is opened by a CDM instance, it will be classified as "in
|
// - When the file is opened by a CDM instance, it will be classified as "in
|
||||||
// use". In this case other CDM instances in the same domain may receive
|
// use". In this case other CDM instances in the same domain may receive
|
||||||
// kInUse status when trying to open it.
|
// kInUse status when trying to open it.
|
||||||
// - |file_name| must not contain forward slash ('/') or backslash ('\'), and
|
// - |file_name| must only contain letters (A-Za-z), digits(0-9), or "._-".
|
||||||
// must not start with an underscore ('_').
|
// It must not start with an underscore ('_'), and must be at least 1
|
||||||
|
// character and no more than 256 characters long.
|
||||||
virtual void Open(const char* file_name, uint32_t file_name_size) = 0;
|
virtual void Open(const char* file_name, uint32_t file_name_size) = 0;
|
||||||
|
|
||||||
// Reads the contents of the file. FileIOClient::OnReadComplete() will be
|
// Reads the contents of the file. FileIOClient::OnReadComplete() will be
|
||||||
|
|
@ -421,7 +474,7 @@ class FileIO {
|
||||||
// When kError is returned, the FileIO object could be in an error state. All
|
// When kError is returned, the FileIO object could be in an error state. All
|
||||||
// following calls (other than Close()) could return kError. The CDM should
|
// following calls (other than Close()) could return kError. The CDM should
|
||||||
// still call Close() to destroy the FileIO object.
|
// still call Close() to destroy the FileIO object.
|
||||||
class FileIOClient {
|
class CDM_CLASS_API FileIOClient {
|
||||||
public:
|
public:
|
||||||
enum Status {
|
enum Status {
|
||||||
kSuccess = 0,
|
kSuccess = 0,
|
||||||
|
|
@ -462,186 +515,7 @@ class FileIOClient {
|
||||||
// provided in CreateCdmInstance() to allocate any Buffer that needs to
|
// provided in CreateCdmInstance() to allocate any Buffer that needs to
|
||||||
// be passed back to the caller. Implementations must call Buffer::Destroy()
|
// be passed back to the caller. Implementations must call Buffer::Destroy()
|
||||||
// when a Buffer is created that will never be returned to the caller.
|
// when a Buffer is created that will never be returned to the caller.
|
||||||
class ContentDecryptionModule_7 {
|
class CDM_CLASS_API ContentDecryptionModule_8 {
|
||||||
public:
|
|
||||||
static const int kVersion = 7;
|
|
||||||
typedef Host_7 Host;
|
|
||||||
|
|
||||||
// SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(),
|
|
||||||
// UpdateSession(), CloseSession(), and RemoveSession() all accept a
|
|
||||||
// |promise_id|, which must be passed to the completion Host method
|
|
||||||
// (e.g. Host::OnResolveNewSessionPromise()).
|
|
||||||
|
|
||||||
// Provides a server certificate to be used to encrypt messages to the
|
|
||||||
// license server. The CDM must respond by calling either
|
|
||||||
// Host::OnResolvePromise() or Host::OnRejectPromise().
|
|
||||||
virtual void SetServerCertificate(uint32_t promise_id,
|
|
||||||
const uint8_t* server_certificate_data,
|
|
||||||
uint32_t server_certificate_data_size) = 0;
|
|
||||||
|
|
||||||
// Creates a session given |session_type|, |init_data_type|, and |init_data|.
|
|
||||||
// The CDM must respond by calling either Host::OnResolveNewSessionPromise()
|
|
||||||
// or Host::OnRejectPromise().
|
|
||||||
virtual void CreateSessionAndGenerateRequest(uint32_t promise_id,
|
|
||||||
SessionType session_type,
|
|
||||||
const char* init_data_type,
|
|
||||||
uint32_t init_data_type_size,
|
|
||||||
const uint8_t* init_data,
|
|
||||||
uint32_t init_data_size) = 0;
|
|
||||||
|
|
||||||
// Loads the session of type |session_type| specified by |session_id|.
|
|
||||||
// The CDM must respond by calling either Host::OnResolveNewSessionPromise()
|
|
||||||
// or Host::OnRejectPromise(). If the session is not found, call
|
|
||||||
// Host::OnResolveNewSessionPromise() with session_id = NULL.
|
|
||||||
virtual void LoadSession(uint32_t promise_id,
|
|
||||||
SessionType session_type,
|
|
||||||
const char* session_id,
|
|
||||||
uint32_t session_id_size) = 0;
|
|
||||||
|
|
||||||
// Updates the session with |response|. The CDM must respond by calling
|
|
||||||
// either Host::OnResolvePromise() or Host::OnRejectPromise().
|
|
||||||
virtual void UpdateSession(uint32_t promise_id,
|
|
||||||
const char* session_id,
|
|
||||||
uint32_t session_id_size,
|
|
||||||
const uint8_t* response,
|
|
||||||
uint32_t response_size) = 0;
|
|
||||||
|
|
||||||
// Requests that the CDM close the session. The CDM must respond by calling
|
|
||||||
// either Host::OnResolvePromise() or Host::OnRejectPromise() when the request
|
|
||||||
// has been processed. This may be before the session is closed. Once the
|
|
||||||
// session is closed, Host::OnSessionClosed() must also be called.
|
|
||||||
virtual void CloseSession(uint32_t promise_id,
|
|
||||||
const char* session_id,
|
|
||||||
uint32_t session_id_size) = 0;
|
|
||||||
|
|
||||||
// Removes any stored session data associated with this session. Will only be
|
|
||||||
// called for persistent sessions. The CDM must respond by calling either
|
|
||||||
// Host::OnResolvePromise() or Host::OnRejectPromise() when the request has
|
|
||||||
// been processed.
|
|
||||||
virtual void RemoveSession(uint32_t promise_id,
|
|
||||||
const char* session_id,
|
|
||||||
uint32_t session_id_size) = 0;
|
|
||||||
|
|
||||||
// Performs scheduled operation with |context| when the timer fires.
|
|
||||||
virtual void TimerExpired(void* context) = 0;
|
|
||||||
|
|
||||||
// Decrypts the |encrypted_buffer|.
|
|
||||||
//
|
|
||||||
// Returns kSuccess if decryption succeeded, in which case the callee
|
|
||||||
// should have filled the |decrypted_buffer| and passed the ownership of
|
|
||||||
// |data| in |decrypted_buffer| to the caller.
|
|
||||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
|
||||||
// to decrypt.
|
|
||||||
// Returns kDecryptError if any other error happened.
|
|
||||||
// If the return value is not kSuccess, |decrypted_buffer| should be ignored
|
|
||||||
// by the caller.
|
|
||||||
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
|
|
||||||
DecryptedBlock* decrypted_buffer) = 0;
|
|
||||||
|
|
||||||
// Initializes the CDM audio decoder with |audio_decoder_config|. This
|
|
||||||
// function must be called before DecryptAndDecodeSamples() is called.
|
|
||||||
//
|
|
||||||
// Returns kSuccess if the |audio_decoder_config| is supported and the CDM
|
|
||||||
// audio decoder is successfully initialized.
|
|
||||||
// Returns kSessionError if |audio_decoder_config| is not supported. The CDM
|
|
||||||
// may still be able to do Decrypt().
|
|
||||||
// Returns kDeferredInitialization if the CDM is not ready to initialize the
|
|
||||||
// decoder at this time. Must call Host::OnDeferredInitializationDone() once
|
|
||||||
// initialization is complete.
|
|
||||||
virtual Status InitializeAudioDecoder(
|
|
||||||
const AudioDecoderConfig& audio_decoder_config) = 0;
|
|
||||||
|
|
||||||
// Initializes the CDM video decoder with |video_decoder_config|. This
|
|
||||||
// function must be called before DecryptAndDecodeFrame() is called.
|
|
||||||
//
|
|
||||||
// Returns kSuccess if the |video_decoder_config| is supported and the CDM
|
|
||||||
// video decoder is successfully initialized.
|
|
||||||
// Returns kSessionError if |video_decoder_config| is not supported. The CDM
|
|
||||||
// may still be able to do Decrypt().
|
|
||||||
// Returns kDeferredInitialization if the CDM is not ready to initialize the
|
|
||||||
// decoder at this time. Must call Host::OnDeferredInitializationDone() once
|
|
||||||
// initialization is complete.
|
|
||||||
virtual Status InitializeVideoDecoder(
|
|
||||||
const VideoDecoderConfig& video_decoder_config) = 0;
|
|
||||||
|
|
||||||
// De-initializes the CDM decoder and sets it to an uninitialized state. The
|
|
||||||
// caller can initialize the decoder again after this call to re-initialize
|
|
||||||
// it. This can be used to reconfigure the decoder if the configuration
|
|
||||||
// changes.
|
|
||||||
virtual void DeinitializeDecoder(StreamType decoder_type) = 0;
|
|
||||||
|
|
||||||
// Resets the CDM decoder to an initialized clean state. All internal buffers
|
|
||||||
// MUST be flushed.
|
|
||||||
virtual void ResetDecoder(StreamType decoder_type) = 0;
|
|
||||||
|
|
||||||
// Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a
|
|
||||||
// |video_frame|. Upon end-of-stream, the caller should call this function
|
|
||||||
// repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
|
|
||||||
// |video_frame| (|format| == kEmptyVideoFrame) is produced.
|
|
||||||
//
|
|
||||||
// Returns kSuccess if decryption and decoding both succeeded, in which case
|
|
||||||
// the callee will have filled the |video_frame| and passed the ownership of
|
|
||||||
// |frame_buffer| in |video_frame| to the caller.
|
|
||||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
|
||||||
// to decrypt.
|
|
||||||
// Returns kNeedMoreData if more data was needed by the decoder to generate
|
|
||||||
// a decoded frame (e.g. during initialization and end-of-stream).
|
|
||||||
// Returns kDecryptError if any decryption error happened.
|
|
||||||
// Returns kDecodeError if any decoding error happened.
|
|
||||||
// If the return value is not kSuccess, |video_frame| should be ignored by
|
|
||||||
// the caller.
|
|
||||||
virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer,
|
|
||||||
VideoFrame* video_frame) = 0;
|
|
||||||
|
|
||||||
// Decrypts the |encrypted_buffer| and decodes the decrypted buffer into
|
|
||||||
// |audio_frames|. Upon end-of-stream, the caller should call this function
|
|
||||||
// repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
|
|
||||||
// |audio_frames| is produced.
|
|
||||||
//
|
|
||||||
// Returns kSuccess if decryption and decoding both succeeded, in which case
|
|
||||||
// the callee will have filled |audio_frames| and passed the ownership of
|
|
||||||
// |data| in |audio_frames| to the caller.
|
|
||||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
|
||||||
// to decrypt.
|
|
||||||
// Returns kNeedMoreData if more data was needed by the decoder to generate
|
|
||||||
// audio samples (e.g. during initialization and end-of-stream).
|
|
||||||
// Returns kDecryptError if any decryption error happened.
|
|
||||||
// Returns kDecodeError if any decoding error happened.
|
|
||||||
// If the return value is not kSuccess, |audio_frames| should be ignored by
|
|
||||||
// the caller.
|
|
||||||
virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer,
|
|
||||||
AudioFrames* audio_frames) = 0;
|
|
||||||
|
|
||||||
// Called by the host after a platform challenge was initiated via
|
|
||||||
// Host::SendPlatformChallenge().
|
|
||||||
virtual void OnPlatformChallengeResponse(
|
|
||||||
const PlatformChallengeResponse& response) = 0;
|
|
||||||
|
|
||||||
// Called by the host after a call to Host::QueryOutputProtectionStatus(). The
|
|
||||||
// |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask|
|
|
||||||
// is a bit mask of OutputProtectionMethods. If |result| is kQueryFailed,
|
|
||||||
// then |link_mask| and |output_protection_mask| are undefined and should
|
|
||||||
// be ignored.
|
|
||||||
virtual void OnQueryOutputProtectionStatus(
|
|
||||||
QueryResult result,
|
|
||||||
uint32_t link_mask,
|
|
||||||
uint32_t output_protection_mask) = 0;
|
|
||||||
|
|
||||||
// Destroys the object in the same context as it was created.
|
|
||||||
virtual void Destroy() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ContentDecryptionModule_7() {}
|
|
||||||
virtual ~ContentDecryptionModule_7() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ContentDecryptionModule interface that all CDMs need to implement.
|
|
||||||
// The interface is versioned for backward compatibility.
|
|
||||||
// Note: ContentDecryptionModule implementations must use the allocator
|
|
||||||
// provided in CreateCdmInstance() to allocate any Buffer that needs to
|
|
||||||
// be passed back to the caller. Implementations must call Buffer::Destroy()
|
|
||||||
// when a Buffer is created that will never be returned to the caller.
|
|
||||||
class ContentDecryptionModule_8 {
|
|
||||||
public:
|
public:
|
||||||
static const int kVersion = 8;
|
static const int kVersion = 8;
|
||||||
typedef Host_8 Host;
|
typedef Host_8 Host;
|
||||||
|
|
@ -823,10 +697,217 @@ class ContentDecryptionModule_8 {
|
||||||
virtual ~ContentDecryptionModule_8() {}
|
virtual ~ContentDecryptionModule_8() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ContentDecryptionModule_8 ContentDecryptionModule;
|
// ContentDecryptionModule interface that all CDMs need to implement.
|
||||||
|
// The interface is versioned for backward compatibility.
|
||||||
|
// Note: ContentDecryptionModule implementations must use the allocator
|
||||||
|
// provided in CreateCdmInstance() to allocate any Buffer that needs to
|
||||||
|
// be passed back to the caller. Implementations must call Buffer::Destroy()
|
||||||
|
// when a Buffer is created that will never be returned to the caller.
|
||||||
|
class CDM_CLASS_API ContentDecryptionModule_9 {
|
||||||
|
public:
|
||||||
|
static const int kVersion = 9;
|
||||||
|
typedef Host_9 Host;
|
||||||
|
|
||||||
|
// Initializes the CDM instance, providing information about permitted
|
||||||
|
// functionalities.
|
||||||
|
// If |allow_distinctive_identifier| is false, messages from the CDM,
|
||||||
|
// such as message events, must not contain a Distinctive Identifier,
|
||||||
|
// even in an encrypted form.
|
||||||
|
// If |allow_persistent_state| is false, the CDM must not attempt to
|
||||||
|
// persist state. Calls to CreateFileIO() will fail.
|
||||||
|
virtual void Initialize(bool allow_distinctive_identifier,
|
||||||
|
bool allow_persistent_state) = 0;
|
||||||
|
|
||||||
|
// Gets the key status if the CDM has a hypothetical key with the |policy|.
|
||||||
|
// The CDM must respond by calling either Host::OnResolveKeyStatusPromise()
|
||||||
|
// with the result key status or Host::OnRejectPromise() if an unexpected
|
||||||
|
// error happened or this method is not supported.
|
||||||
|
virtual void GetStatusForPolicy(uint32_t promise_id,
|
||||||
|
const Policy& policy) = 0;
|
||||||
|
|
||||||
|
// SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(),
|
||||||
|
// UpdateSession(), CloseSession(), and RemoveSession() all accept a
|
||||||
|
// |promise_id|, which must be passed to the completion Host method
|
||||||
|
// (e.g. Host::OnResolveNewSessionPromise()).
|
||||||
|
|
||||||
|
// Provides a server certificate to be used to encrypt messages to the
|
||||||
|
// license server. The CDM must respond by calling either
|
||||||
|
// Host::OnResolvePromise() or Host::OnRejectPromise().
|
||||||
|
virtual void SetServerCertificate(uint32_t promise_id,
|
||||||
|
const uint8_t* server_certificate_data,
|
||||||
|
uint32_t server_certificate_data_size) = 0;
|
||||||
|
|
||||||
|
// Creates a session given |session_type|, |init_data_type|, and |init_data|.
|
||||||
|
// The CDM must respond by calling either Host::OnResolveNewSessionPromise()
|
||||||
|
// or Host::OnRejectPromise().
|
||||||
|
virtual void CreateSessionAndGenerateRequest(uint32_t promise_id,
|
||||||
|
SessionType session_type,
|
||||||
|
InitDataType init_data_type,
|
||||||
|
const uint8_t* init_data,
|
||||||
|
uint32_t init_data_size) = 0;
|
||||||
|
|
||||||
|
// Loads the session of type |session_type| specified by |session_id|.
|
||||||
|
// The CDM must respond by calling either Host::OnResolveNewSessionPromise()
|
||||||
|
// or Host::OnRejectPromise(). If the session is not found, call
|
||||||
|
// Host::OnResolveNewSessionPromise() with session_id = NULL.
|
||||||
|
virtual void LoadSession(uint32_t promise_id,
|
||||||
|
SessionType session_type,
|
||||||
|
const char* session_id,
|
||||||
|
uint32_t session_id_size) = 0;
|
||||||
|
|
||||||
|
// Updates the session with |response|. The CDM must respond by calling
|
||||||
|
// either Host::OnResolvePromise() or Host::OnRejectPromise().
|
||||||
|
virtual void UpdateSession(uint32_t promise_id,
|
||||||
|
const char* session_id,
|
||||||
|
uint32_t session_id_size,
|
||||||
|
const uint8_t* response,
|
||||||
|
uint32_t response_size) = 0;
|
||||||
|
|
||||||
|
// Requests that the CDM close the session. The CDM must respond by calling
|
||||||
|
// either Host::OnResolvePromise() or Host::OnRejectPromise() when the request
|
||||||
|
// has been processed. This may be before the session is closed. Once the
|
||||||
|
// session is closed, Host::OnSessionClosed() must also be called.
|
||||||
|
virtual void CloseSession(uint32_t promise_id,
|
||||||
|
const char* session_id,
|
||||||
|
uint32_t session_id_size) = 0;
|
||||||
|
|
||||||
|
// Removes any stored session data associated with this session. Will only be
|
||||||
|
// called for persistent sessions. The CDM must respond by calling either
|
||||||
|
// Host::OnResolvePromise() or Host::OnRejectPromise() when the request has
|
||||||
|
// been processed.
|
||||||
|
virtual void RemoveSession(uint32_t promise_id,
|
||||||
|
const char* session_id,
|
||||||
|
uint32_t session_id_size) = 0;
|
||||||
|
|
||||||
|
// Performs scheduled operation with |context| when the timer fires.
|
||||||
|
virtual void TimerExpired(void* context) = 0;
|
||||||
|
|
||||||
|
// Decrypts the |encrypted_buffer|.
|
||||||
|
//
|
||||||
|
// Returns kSuccess if decryption succeeded, in which case the callee
|
||||||
|
// should have filled the |decrypted_buffer| and passed the ownership of
|
||||||
|
// |data| in |decrypted_buffer| to the caller.
|
||||||
|
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||||
|
// to decrypt.
|
||||||
|
// Returns kDecryptError if any other error happened.
|
||||||
|
// If the return value is not kSuccess, |decrypted_buffer| should be ignored
|
||||||
|
// by the caller.
|
||||||
|
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
|
||||||
|
DecryptedBlock* decrypted_buffer) = 0;
|
||||||
|
|
||||||
|
// Initializes the CDM audio decoder with |audio_decoder_config|. This
|
||||||
|
// function must be called before DecryptAndDecodeSamples() is called.
|
||||||
|
//
|
||||||
|
// Returns kSuccess if the |audio_decoder_config| is supported and the CDM
|
||||||
|
// audio decoder is successfully initialized.
|
||||||
|
// Returns kInitializationError if |audio_decoder_config| is not supported.
|
||||||
|
// The CDM may still be able to do Decrypt().
|
||||||
|
// Returns kDeferredInitialization if the CDM is not ready to initialize the
|
||||||
|
// decoder at this time. Must call Host::OnDeferredInitializationDone() once
|
||||||
|
// initialization is complete.
|
||||||
|
virtual Status InitializeAudioDecoder(
|
||||||
|
const AudioDecoderConfig& audio_decoder_config) = 0;
|
||||||
|
|
||||||
|
// Initializes the CDM video decoder with |video_decoder_config|. This
|
||||||
|
// function must be called before DecryptAndDecodeFrame() is called.
|
||||||
|
//
|
||||||
|
// Returns kSuccess if the |video_decoder_config| is supported and the CDM
|
||||||
|
// video decoder is successfully initialized.
|
||||||
|
// Returns kInitializationError if |video_decoder_config| is not supported.
|
||||||
|
// The CDM may still be able to do Decrypt().
|
||||||
|
// Returns kDeferredInitialization if the CDM is not ready to initialize the
|
||||||
|
// decoder at this time. Must call Host::OnDeferredInitializationDone() once
|
||||||
|
// initialization is complete.
|
||||||
|
virtual Status InitializeVideoDecoder(
|
||||||
|
const VideoDecoderConfig& video_decoder_config) = 0;
|
||||||
|
|
||||||
|
// De-initializes the CDM decoder and sets it to an uninitialized state. The
|
||||||
|
// caller can initialize the decoder again after this call to re-initialize
|
||||||
|
// it. This can be used to reconfigure the decoder if the configuration
|
||||||
|
// changes.
|
||||||
|
virtual void DeinitializeDecoder(StreamType decoder_type) = 0;
|
||||||
|
|
||||||
|
// Resets the CDM decoder to an initialized clean state. All internal buffers
|
||||||
|
// MUST be flushed.
|
||||||
|
virtual void ResetDecoder(StreamType decoder_type) = 0;
|
||||||
|
|
||||||
|
// Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a
|
||||||
|
// |video_frame|. Upon end-of-stream, the caller should call this function
|
||||||
|
// repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
|
||||||
|
// |video_frame| (|format| == kEmptyVideoFrame) is produced.
|
||||||
|
//
|
||||||
|
// Returns kSuccess if decryption and decoding both succeeded, in which case
|
||||||
|
// the callee will have filled the |video_frame| and passed the ownership of
|
||||||
|
// |frame_buffer| in |video_frame| to the caller.
|
||||||
|
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||||
|
// to decrypt.
|
||||||
|
// Returns kNeedMoreData if more data was needed by the decoder to generate
|
||||||
|
// a decoded frame (e.g. during initialization and end-of-stream).
|
||||||
|
// Returns kDecryptError if any decryption error happened.
|
||||||
|
// Returns kDecodeError if any decoding error happened.
|
||||||
|
// If the return value is not kSuccess, |video_frame| should be ignored by
|
||||||
|
// the caller.
|
||||||
|
virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer,
|
||||||
|
VideoFrame* video_frame) = 0;
|
||||||
|
|
||||||
|
// Decrypts the |encrypted_buffer| and decodes the decrypted buffer into
|
||||||
|
// |audio_frames|. Upon end-of-stream, the caller should call this function
|
||||||
|
// repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
|
||||||
|
// |audio_frames| is produced.
|
||||||
|
//
|
||||||
|
// Returns kSuccess if decryption and decoding both succeeded, in which case
|
||||||
|
// the callee will have filled |audio_frames| and passed the ownership of
|
||||||
|
// |data| in |audio_frames| to the caller.
|
||||||
|
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||||
|
// to decrypt.
|
||||||
|
// Returns kNeedMoreData if more data was needed by the decoder to generate
|
||||||
|
// audio samples (e.g. during initialization and end-of-stream).
|
||||||
|
// Returns kDecryptError if any decryption error happened.
|
||||||
|
// Returns kDecodeError if any decoding error happened.
|
||||||
|
// If the return value is not kSuccess, |audio_frames| should be ignored by
|
||||||
|
// the caller.
|
||||||
|
virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer,
|
||||||
|
AudioFrames* audio_frames) = 0;
|
||||||
|
|
||||||
|
// Called by the host after a platform challenge was initiated via
|
||||||
|
// Host::SendPlatformChallenge().
|
||||||
|
virtual void OnPlatformChallengeResponse(
|
||||||
|
const PlatformChallengeResponse& response) = 0;
|
||||||
|
|
||||||
|
// Called by the host after a call to Host::QueryOutputProtectionStatus(). The
|
||||||
|
// |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask|
|
||||||
|
// is a bit mask of OutputProtectionMethods. If |result| is kQueryFailed,
|
||||||
|
// then |link_mask| and |output_protection_mask| are undefined and should
|
||||||
|
// be ignored.
|
||||||
|
virtual void OnQueryOutputProtectionStatus(
|
||||||
|
QueryResult result,
|
||||||
|
uint32_t link_mask,
|
||||||
|
uint32_t output_protection_mask) = 0;
|
||||||
|
|
||||||
|
// Called by the host after a call to Host::RequestStorageId(). If the
|
||||||
|
// version of the storage ID requested is available, |storage_id| and
|
||||||
|
// |storage_id_size| are set appropriately. |version| will be the same as
|
||||||
|
// what was requested, unless 0 (latest) was requested, in which case
|
||||||
|
// |version| will be the actual version number for the |storage_id| returned.
|
||||||
|
// If the requested version is not available, null/zero will be provided as
|
||||||
|
// |storage_id| and |storage_id_size|, respectively, and |version| should be
|
||||||
|
// ignored.
|
||||||
|
virtual void OnStorageId(uint32_t version,
|
||||||
|
const uint8_t* storage_id,
|
||||||
|
uint32_t storage_id_size) = 0;
|
||||||
|
|
||||||
|
// Destroys the object in the same context as it was created.
|
||||||
|
virtual void Destroy() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ContentDecryptionModule_9() {}
|
||||||
|
virtual ~ContentDecryptionModule_9() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef ContentDecryptionModule_9 ContentDecryptionModule;
|
||||||
|
|
||||||
// Represents a buffer created by Allocator implementations.
|
// Represents a buffer created by Allocator implementations.
|
||||||
class Buffer {
|
class CDM_CLASS_API Buffer {
|
||||||
public:
|
public:
|
||||||
// Destroys the buffer in the same context as it was created.
|
// Destroys the buffer in the same context as it was created.
|
||||||
virtual void Destroy() = 0;
|
virtual void Destroy() = 0;
|
||||||
|
|
@ -845,144 +926,7 @@ class Buffer {
|
||||||
void operator=(const Buffer&);
|
void operator=(const Buffer&);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Host_7 {
|
class CDM_CLASS_API Host_8 {
|
||||||
public:
|
|
||||||
static const int kVersion = 7;
|
|
||||||
|
|
||||||
// Returns a Buffer* containing non-zero members upon success, or NULL on
|
|
||||||
// failure. The caller owns the Buffer* after this call. The buffer is not
|
|
||||||
// guaranteed to be zero initialized. The capacity of the allocated Buffer
|
|
||||||
// is guaranteed to be not less than |capacity|.
|
|
||||||
virtual Buffer* Allocate(uint32_t capacity) = 0;
|
|
||||||
|
|
||||||
// Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
|
|
||||||
// from now with |context|.
|
|
||||||
virtual void SetTimer(int64_t delay_ms, void* context) = 0;
|
|
||||||
|
|
||||||
// Returns the current wall time in seconds.
|
|
||||||
virtual Time GetCurrentWallTime() = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when a session is created or loaded and the value for the
|
|
||||||
// MediaKeySession's sessionId attribute is available (|session_id|).
|
|
||||||
// This must be called before OnSessionMessage() or
|
|
||||||
// OnSessionKeysChange() is called for the same session. |session_id_size|
|
|
||||||
// should not include null termination.
|
|
||||||
// When called in response to LoadSession(), the |session_id| must be the
|
|
||||||
// same as the |session_id| passed in LoadSession(), or NULL if the
|
|
||||||
// session could not be loaded.
|
|
||||||
virtual void OnResolveNewSessionPromise(uint32_t promise_id,
|
|
||||||
const char* session_id,
|
|
||||||
uint32_t session_id_size) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when a session is updated or released.
|
|
||||||
virtual void OnResolvePromise(uint32_t promise_id) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when an error occurs as a result of one of the
|
|
||||||
// ContentDecryptionModule calls that accept a |promise_id|.
|
|
||||||
// |error| must be specified, |error_message| and |system_code|
|
|
||||||
// are optional. |error_message_size| should not include null termination.
|
|
||||||
virtual void OnRejectPromise(uint32_t promise_id,
|
|
||||||
Error error,
|
|
||||||
uint32_t system_code,
|
|
||||||
const char* error_message,
|
|
||||||
uint32_t error_message_size) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when it has a message for session |session_id|.
|
|
||||||
// Size parameters should not include null termination.
|
|
||||||
// |legacy_destination_url| is only for supporting the prefixed EME API and
|
|
||||||
// is ignored by unprefixed EME. It should only be non-null if |message_type|
|
|
||||||
// is kLicenseRenewal.
|
|
||||||
virtual void OnSessionMessage(const char* session_id,
|
|
||||||
uint32_t session_id_size,
|
|
||||||
MessageType message_type,
|
|
||||||
const char* message,
|
|
||||||
uint32_t message_size,
|
|
||||||
const char* legacy_destination_url,
|
|
||||||
uint32_t legacy_destination_url_length) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when there has been a change in keys or their status for
|
|
||||||
// session |session_id|. |has_additional_usable_key| should be set if a
|
|
||||||
// key is newly usable (e.g. new key available, previously expired key has
|
|
||||||
// been renewed, etc.) and the browser should attempt to resume playback.
|
|
||||||
// |key_ids| is the list of key ids for this session along with their
|
|
||||||
// current status. |key_ids_count| is the number of entries in |key_ids|.
|
|
||||||
// Size parameter for |session_id| should not include null termination.
|
|
||||||
virtual void OnSessionKeysChange(const char* session_id,
|
|
||||||
uint32_t session_id_size,
|
|
||||||
bool has_additional_usable_key,
|
|
||||||
const KeyInformation* keys_info,
|
|
||||||
uint32_t keys_info_count) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when there has been a change in the expiration time for
|
|
||||||
// session |session_id|. This can happen as the result of an Update() call
|
|
||||||
// or some other event. If this happens as a result of a call to Update(),
|
|
||||||
// it must be called before resolving the Update() promise. |new_expiry_time|
|
|
||||||
// can be 0 to represent "undefined". Size parameter should not include
|
|
||||||
// null termination.
|
|
||||||
virtual void OnExpirationChange(const char* session_id,
|
|
||||||
uint32_t session_id_size,
|
|
||||||
Time new_expiry_time) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when session |session_id| is closed. Size
|
|
||||||
// parameter should not include null termination.
|
|
||||||
virtual void OnSessionClosed(const char* session_id,
|
|
||||||
uint32_t session_id_size) = 0;
|
|
||||||
|
|
||||||
// Called by the CDM when an error occurs in session |session_id|
|
|
||||||
// unrelated to one of the ContentDecryptionModule calls that accept a
|
|
||||||
// |promise_id|. |error| must be specified, |error_message| and
|
|
||||||
// |system_code| are optional. Length parameters should not include null
|
|
||||||
// termination.
|
|
||||||
// Note:
|
|
||||||
// - This method is only for supporting prefixed EME API.
|
|
||||||
// - This method will be ignored by unprefixed EME. All errors reported
|
|
||||||
// in this method should probably also be reported by one of other methods.
|
|
||||||
virtual void OnLegacySessionError(
|
|
||||||
const char* session_id, uint32_t session_id_length,
|
|
||||||
Error error,
|
|
||||||
uint32_t system_code,
|
|
||||||
const char* error_message, uint32_t error_message_length) = 0;
|
|
||||||
|
|
||||||
// The following are optional methods that may not be implemented on all
|
|
||||||
// platforms.
|
|
||||||
|
|
||||||
// Sends a platform challenge for the given |service_id|. |challenge| is at
|
|
||||||
// most 256 bits of data to be signed. Once the challenge has been completed,
|
|
||||||
// the host will call ContentDecryptionModule::OnPlatformChallengeResponse()
|
|
||||||
// with the signed challenge response and platform certificate. Size
|
|
||||||
// parameters should not include null termination.
|
|
||||||
virtual void SendPlatformChallenge(const char* service_id,
|
|
||||||
uint32_t service_id_size,
|
|
||||||
const char* challenge,
|
|
||||||
uint32_t challenge_size) = 0;
|
|
||||||
|
|
||||||
// Attempts to enable output protection (e.g. HDCP) on the display link. The
|
|
||||||
// |desired_protection_mask| is a bit mask of OutputProtectionMethods. No
|
|
||||||
// status callback is issued, the CDM must call QueryOutputProtectionStatus()
|
|
||||||
// periodically to ensure the desired protections are applied.
|
|
||||||
virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0;
|
|
||||||
|
|
||||||
// Requests the current output protection status. Once the host has the status
|
|
||||||
// it will call ContentDecryptionModule::OnQueryOutputProtectionStatus().
|
|
||||||
virtual void QueryOutputProtectionStatus() = 0;
|
|
||||||
|
|
||||||
// Must be called by the CDM if it returned kDeferredInitialization during
|
|
||||||
// InitializeAudioDecoder() or InitializeVideoDecoder().
|
|
||||||
virtual void OnDeferredInitializationDone(StreamType stream_type,
|
|
||||||
Status decoder_status) = 0;
|
|
||||||
|
|
||||||
// Creates a FileIO object from the host to do file IO operation. Returns NULL
|
|
||||||
// if a FileIO object cannot be obtained. Once a valid FileIO object is
|
|
||||||
// returned, |client| must be valid until FileIO::Close() is called. The
|
|
||||||
// CDM can call this method multiple times to operate on different files.
|
|
||||||
virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Host_7() {}
|
|
||||||
virtual ~Host_7() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Host_8 {
|
|
||||||
public:
|
public:
|
||||||
static const int kVersion = 8;
|
static const int kVersion = 8;
|
||||||
|
|
||||||
|
|
@ -996,7 +940,7 @@ class Host_8 {
|
||||||
// from now with |context|.
|
// from now with |context|.
|
||||||
virtual void SetTimer(int64_t delay_ms, void* context) = 0;
|
virtual void SetTimer(int64_t delay_ms, void* context) = 0;
|
||||||
|
|
||||||
// Returns the current wall time in seconds.
|
// Returns the current wall time.
|
||||||
virtual Time GetCurrentWallTime() = 0;
|
virtual Time GetCurrentWallTime() = 0;
|
||||||
|
|
||||||
// Called by the CDM when a session is created or loaded and the value for the
|
// Called by the CDM when a session is created or loaded and the value for the
|
||||||
|
|
@ -1054,8 +998,10 @@ class Host_8 {
|
||||||
// session |session_id|. This can happen as the result of an Update() call
|
// session |session_id|. This can happen as the result of an Update() call
|
||||||
// or some other event. If this happens as a result of a call to Update(),
|
// or some other event. If this happens as a result of a call to Update(),
|
||||||
// it must be called before resolving the Update() promise. |new_expiry_time|
|
// it must be called before resolving the Update() promise. |new_expiry_time|
|
||||||
// can be 0 to represent "undefined". Size parameter should not include
|
// represents the time after which the key(s) in the session will no longer
|
||||||
// null termination.
|
// be usable for decryption. It can be 0 if no such time exists or if the
|
||||||
|
// license explicitly never expires. Size parameter should not include null
|
||||||
|
// termination.
|
||||||
virtual void OnExpirationChange(const char* session_id,
|
virtual void OnExpirationChange(const char* session_id,
|
||||||
uint32_t session_id_size,
|
uint32_t session_id_size,
|
||||||
Time new_expiry_time) = 0;
|
Time new_expiry_time) = 0;
|
||||||
|
|
@ -1119,8 +1065,141 @@ class Host_8 {
|
||||||
virtual ~Host_8() {}
|
virtual ~Host_8() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CDM_CLASS_API Host_9 {
|
||||||
|
public:
|
||||||
|
static const int kVersion = 9;
|
||||||
|
|
||||||
|
// Returns a Buffer* containing non-zero members upon success, or NULL on
|
||||||
|
// failure. The caller owns the Buffer* after this call. The buffer is not
|
||||||
|
// guaranteed to be zero initialized. The capacity of the allocated Buffer
|
||||||
|
// is guaranteed to be not less than |capacity|.
|
||||||
|
virtual Buffer* Allocate(uint32_t capacity) = 0;
|
||||||
|
|
||||||
|
// Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
|
||||||
|
// from now with |context|.
|
||||||
|
virtual void SetTimer(int64_t delay_ms, void* context) = 0;
|
||||||
|
|
||||||
|
// Returns the current wall time.
|
||||||
|
virtual Time GetCurrentWallTime() = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when a key status is available in response to
|
||||||
|
// GetStatusForPolicy().
|
||||||
|
virtual void OnResolveKeyStatusPromise(uint32_t promise_id,
|
||||||
|
KeyStatus key_status) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when a session is created or loaded and the value for the
|
||||||
|
// MediaKeySession's sessionId attribute is available (|session_id|).
|
||||||
|
// This must be called before OnSessionMessage() or
|
||||||
|
// OnSessionKeysChange() is called for the same session. |session_id_size|
|
||||||
|
// should not include null termination.
|
||||||
|
// When called in response to LoadSession(), the |session_id| must be the
|
||||||
|
// same as the |session_id| passed in LoadSession(), or NULL if the
|
||||||
|
// session could not be loaded.
|
||||||
|
virtual void OnResolveNewSessionPromise(uint32_t promise_id,
|
||||||
|
const char* session_id,
|
||||||
|
uint32_t session_id_size) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when a session is updated or released.
|
||||||
|
virtual void OnResolvePromise(uint32_t promise_id) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when an error occurs as a result of one of the
|
||||||
|
// ContentDecryptionModule calls that accept a |promise_id|.
|
||||||
|
// |exception| must be specified. |error_message| and |system_code|
|
||||||
|
// are optional. |error_message_size| should not include null termination.
|
||||||
|
virtual void OnRejectPromise(uint32_t promise_id,
|
||||||
|
Exception exception,
|
||||||
|
uint32_t system_code,
|
||||||
|
const char* error_message,
|
||||||
|
uint32_t error_message_size) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when it has a message for session |session_id|.
|
||||||
|
// Size parameters should not include null termination.
|
||||||
|
virtual void OnSessionMessage(const char* session_id,
|
||||||
|
uint32_t session_id_size,
|
||||||
|
MessageType message_type,
|
||||||
|
const char* message,
|
||||||
|
uint32_t message_size) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when there has been a change in keys or their status for
|
||||||
|
// session |session_id|. |has_additional_usable_key| should be set if a
|
||||||
|
// key is newly usable (e.g. new key available, previously expired key has
|
||||||
|
// been renewed, etc.) and the browser should attempt to resume playback.
|
||||||
|
// |key_ids| is the list of key ids for this session along with their
|
||||||
|
// current status. |key_ids_count| is the number of entries in |key_ids|.
|
||||||
|
// Size parameter for |session_id| should not include null termination.
|
||||||
|
virtual void OnSessionKeysChange(const char* session_id,
|
||||||
|
uint32_t session_id_size,
|
||||||
|
bool has_additional_usable_key,
|
||||||
|
const KeyInformation* keys_info,
|
||||||
|
uint32_t keys_info_count) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when there has been a change in the expiration time for
|
||||||
|
// session |session_id|. This can happen as the result of an Update() call
|
||||||
|
// or some other event. If this happens as a result of a call to Update(),
|
||||||
|
// it must be called before resolving the Update() promise. |new_expiry_time|
|
||||||
|
// represents the time after which the key(s) in the session will no longer
|
||||||
|
// be usable for decryption. It can be 0 if no such time exists or if the
|
||||||
|
// license explicitly never expires. Size parameter should not include null
|
||||||
|
// termination.
|
||||||
|
virtual void OnExpirationChange(const char* session_id,
|
||||||
|
uint32_t session_id_size,
|
||||||
|
Time new_expiry_time) = 0;
|
||||||
|
|
||||||
|
// Called by the CDM when session |session_id| is closed. Size
|
||||||
|
// parameter should not include null termination.
|
||||||
|
virtual void OnSessionClosed(const char* session_id,
|
||||||
|
uint32_t session_id_size) = 0;
|
||||||
|
|
||||||
|
// The following are optional methods that may not be implemented on all
|
||||||
|
// platforms.
|
||||||
|
|
||||||
|
// Sends a platform challenge for the given |service_id|. |challenge| is at
|
||||||
|
// most 256 bits of data to be signed. Once the challenge has been completed,
|
||||||
|
// the host will call ContentDecryptionModule::OnPlatformChallengeResponse()
|
||||||
|
// with the signed challenge response and platform certificate. Size
|
||||||
|
// parameters should not include null termination.
|
||||||
|
virtual void SendPlatformChallenge(const char* service_id,
|
||||||
|
uint32_t service_id_size,
|
||||||
|
const char* challenge,
|
||||||
|
uint32_t challenge_size) = 0;
|
||||||
|
|
||||||
|
// Attempts to enable output protection (e.g. HDCP) on the display link. The
|
||||||
|
// |desired_protection_mask| is a bit mask of OutputProtectionMethods. No
|
||||||
|
// status callback is issued, the CDM must call QueryOutputProtectionStatus()
|
||||||
|
// periodically to ensure the desired protections are applied.
|
||||||
|
virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0;
|
||||||
|
|
||||||
|
// Requests the current output protection status. Once the host has the status
|
||||||
|
// it will call ContentDecryptionModule::OnQueryOutputProtectionStatus().
|
||||||
|
virtual void QueryOutputProtectionStatus() = 0;
|
||||||
|
|
||||||
|
// Must be called by the CDM if it returned kDeferredInitialization during
|
||||||
|
// InitializeAudioDecoder() or InitializeVideoDecoder().
|
||||||
|
virtual void OnDeferredInitializationDone(StreamType stream_type,
|
||||||
|
Status decoder_status) = 0;
|
||||||
|
|
||||||
|
// Creates a FileIO object from the host to do file IO operation. Returns NULL
|
||||||
|
// if a FileIO object cannot be obtained. Once a valid FileIO object is
|
||||||
|
// returned, |client| must be valid until FileIO::Close() is called. The
|
||||||
|
// CDM can call this method multiple times to operate on different files.
|
||||||
|
virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
|
||||||
|
|
||||||
|
// Requests a specific version of the storage ID. A storage ID is a stable,
|
||||||
|
// device specific ID used by the CDM to securely store persistent data. The
|
||||||
|
// ID will be returned by the host via ContentDecryptionModule::OnStorageId().
|
||||||
|
// If |version| is 0, the latest version will be returned. All |version|s
|
||||||
|
// that are greater than or equal to 0x80000000 are reserved for the CDM and
|
||||||
|
// should not be supported or returned by the host. The CDM must not expose
|
||||||
|
// the ID outside the client device, even in encrypted form.
|
||||||
|
virtual void RequestStorageId(uint32_t version) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Host_9() {}
|
||||||
|
virtual ~Host_9() {}
|
||||||
|
};
|
||||||
|
|
||||||
// Represents a decrypted block that has not been decoded.
|
// Represents a decrypted block that has not been decoded.
|
||||||
class DecryptedBlock {
|
class CDM_CLASS_API DecryptedBlock {
|
||||||
public:
|
public:
|
||||||
virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
|
virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
|
||||||
virtual Buffer* DecryptedBuffer() = 0;
|
virtual Buffer* DecryptedBuffer() = 0;
|
||||||
|
|
@ -1135,7 +1214,7 @@ class DecryptedBlock {
|
||||||
virtual ~DecryptedBlock() {}
|
virtual ~DecryptedBlock() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VideoFrame {
|
class CDM_CLASS_API VideoFrame {
|
||||||
public:
|
public:
|
||||||
enum VideoPlane {
|
enum VideoPlane {
|
||||||
kYPlane = 0,
|
kYPlane = 0,
|
||||||
|
|
@ -1178,7 +1257,7 @@ class VideoFrame {
|
||||||
//
|
//
|
||||||
// |<----------------- AudioFrames ------------------>|
|
// |<----------------- AudioFrames ------------------>|
|
||||||
// | audio buffer 0 | audio buffer 1 | audio buffer 2 |
|
// | audio buffer 0 | audio buffer 1 | audio buffer 2 |
|
||||||
class AudioFrames {
|
class CDM_CLASS_API AudioFrames {
|
||||||
public:
|
public:
|
||||||
virtual void SetFrameBuffer(Buffer* buffer) = 0;
|
virtual void SetFrameBuffer(Buffer* buffer) = 0;
|
||||||
virtual Buffer* FrameBuffer() = 0;
|
virtual Buffer* FrameBuffer() = 0;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef CDM_CONTENT_DECRYPTION_MODULE_EXPORT_H_
|
||||||
|
#define CDM_CONTENT_DECRYPTION_MODULE_EXPORT_H_
|
||||||
|
|
||||||
|
// Define CDM_API so that functionality implemented by the CDM module
|
||||||
|
// can be exported to consumers.
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
#if defined(CDM_IMPLEMENTATION)
|
||||||
|
#define CDM_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define CDM_API __declspec(dllimport)
|
||||||
|
#endif // defined(CDM_IMPLEMENTATION)
|
||||||
|
|
||||||
|
#else // defined(_WIN32)
|
||||||
|
#define CDM_API __attribute__((visibility("default")))
|
||||||
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
|
#endif // CDM_CONTENT_DECRYPTION_MODULE_EXPORT_H_
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef CDM_CONTENT_DECRYPTION_MODULE_EXT_H_
|
||||||
|
#define CDM_CONTENT_DECRYPTION_MODULE_EXT_H_
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "content_decryption_module_export.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace cdm {
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
typedef wchar_t FilePathCharType;
|
||||||
|
typedef HANDLE PlatformFile;
|
||||||
|
const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE;
|
||||||
|
#else
|
||||||
|
typedef char FilePathCharType;
|
||||||
|
typedef int PlatformFile;
|
||||||
|
const PlatformFile kInvalidPlatformFile = -1;
|
||||||
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
|
struct HostFile {
|
||||||
|
HostFile(const FilePathCharType* file_path,
|
||||||
|
PlatformFile file,
|
||||||
|
PlatformFile sig_file)
|
||||||
|
: file_path(file_path), file(file), sig_file(sig_file) {}
|
||||||
|
|
||||||
|
// File that is part of the host of the CDM.
|
||||||
|
const FilePathCharType* file_path = nullptr;
|
||||||
|
PlatformFile file = kInvalidPlatformFile;
|
||||||
|
|
||||||
|
// Signature file for |file|.
|
||||||
|
PlatformFile sig_file = kInvalidPlatformFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cdm
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
// Functions in this file are dynamically retrieved by their versioned function
|
||||||
|
// names. Increment the version number for any backward incompatible API
|
||||||
|
// changes.
|
||||||
|
|
||||||
|
// Verifies CDM host. All files in |host_files| are opened in read-only mode.
|
||||||
|
//
|
||||||
|
// Returns false and closes all files if there is an immediate failure.
|
||||||
|
// Otherwise returns true as soon as possible and processes the files
|
||||||
|
// asynchronously. All files MUST be closed by the CDM after this one-time
|
||||||
|
// processing is finished.
|
||||||
|
CDM_API bool VerifyCdmHost_0(const cdm::HostFile* host_files,
|
||||||
|
uint32_t num_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CDM_CONTENT_DECRYPTION_MODULE_EXT_H_
|
||||||
Loading…
Add table
Add a link
Reference in a new issue