mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 02:17:34 +09:00
[EME] Make WidevineAdapter compatible with CDM version 9
NOTE: this breaks compatibility with CDM version 8.
This commit is contained in:
parent
a4dd5cc088
commit
eb2e8d7f92
6 changed files with 51 additions and 50 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)
|
||||||
|
|
@ -162,7 +162,7 @@ WidevineAdapter::Supports(int32_t aModuleVersion,
|
||||||
{
|
{
|
||||||
return aModuleVersion == CDM_MODULE_VERSION &&
|
return aModuleVersion == CDM_MODULE_VERSION &&
|
||||||
aInterfaceVersion == cdm::ContentDecryptionModule::kVersion &&
|
aInterfaceVersion == cdm::ContentDecryptionModule::kVersion &&
|
||||||
aHostVersion == cdm::Host_8::kVersion;
|
aHostVersion == cdm::Host_9::kVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,12 @@ WidevineDecryptor::GetCurrentWallTime()
|
||||||
return base::Time::Now().ToDoubleT();
|
return base::Time::Now().ToDoubleT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ChromiumCDMChild::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,
|
||||||
|
|
@ -332,42 +338,41 @@ WidevineDecryptor::OnResolvePromise(uint32_t aPromiseId)
|
||||||
mCallback->ResolvePromise(aPromiseId);
|
mCallback->ResolvePromise(aPromiseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GMPDOMException
|
// Align with spec, the Exceptions used by CDM to reject promises .
|
||||||
ToGMPDOMException(cdm::Error aError)
|
// https://w3c.github.io/encrypted-media/#exceptions
|
||||||
{
|
cdm::Exception
|
||||||
switch (aError) {
|
ConvertCDMErrorToCDMException(cdm::Error error) {
|
||||||
case kNotSupportedError: return kGMPNotSupportedError;
|
switch (error) {
|
||||||
case kInvalidStateError: return kGMPInvalidStateError;
|
case cdm::kNotSupportedError:
|
||||||
case kInvalidAccessError:
|
return cdm::Exception::kExceptionNotSupportedError;
|
||||||
// Note: Chrome converts kInvalidAccessError to TypeError, since the
|
case cdm::kInvalidStateError:
|
||||||
// Chromium CDM API doesn't have a type error enum value. The EME spec
|
return cdm::Exception::kExceptionInvalidStateError;
|
||||||
// requires TypeError in some places, so we do the same conversion.
|
case cdm::kInvalidAccessError:
|
||||||
// See bug 1313202.
|
return cdm::Exception::kExceptionTypeError;
|
||||||
return kGMPTypeError;
|
case cdm::kQuotaExceededError:
|
||||||
case kQuotaExceededError: return kGMPQuotaExceededError;
|
return cdm::Exception::kExceptionQuotaExceededError;
|
||||||
case kUnknownError: return kGMPInvalidModificationError; // Note: Unique placeholder.
|
break;
|
||||||
case kClientError: return kGMPAbortError; // Note: Unique placeholder.
|
}
|
||||||
case kOutputError: return kGMPSecurityError; // Note: Unique placeholder.
|
|
||||||
};
|
return cdm::Exception::kExceptionInvalidStateError;
|
||||||
return kGMPTimeoutError; // Note: Unique placeholder.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)aError, aSystemCode, aErrorMessage);
|
||||||
mCallback->RejectPromise(aPromiseId,
|
mCallback->RejectPromise(aPromiseId,
|
||||||
ToGMPDOMException(aError),
|
ToGMPDOMException(aException),
|
||||||
!aErrorMessageSize ? "" : aErrorMessage,
|
!aErrorMessageSize ? "" : aErrorMessage,
|
||||||
aErrorMessageSize);
|
aErrorMessageSize);
|
||||||
}
|
}
|
||||||
|
|
@ -385,12 +390,10 @@ 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");
|
||||||
|
|
|
||||||
|
|
@ -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() 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;
|
||||||
|
|
|
||||||
|
|
@ -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,12 @@ 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; }
|
||||||
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.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue