Issue #26 - Part 2b: Stub out GMPDecryptorProxy functions.

If EME isn't built, these functions would have no use and the callback
structures are unavailable. Stubbing these out will still allow the
callers to work unchanged, but in effect simply always return without
dispatching a promised task.
This fixes the dependency issue from part 2a.
This commit is contained in:
wolfbeast 2020-02-04 11:48:13 +01:00 • committed by Roy Tam
commit 995d48aa96
2 changed files with 35 additions and 1 deletions

View file

@ -43,11 +43,13 @@ GMPDecryptorParent::~GMPDecryptorParent()
bool bool
GMPDecryptorParent::RecvSetDecryptorId(const uint32_t& aId) GMPDecryptorParent::RecvSetDecryptorId(const uint32_t& aId)
{ {
#ifdef MOZ_EME
if (!mIsOpen) { if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!"); NS_WARNING("Trying to use a dead GMP decrypter!");
return false; return false;
} }
mCallback->SetDecryptorId(aId); mCallback->SetDecryptorId(aId);
#endif
return true; return true;
} }
@ -202,6 +204,7 @@ bool
GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId, GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId,
const nsCString& aSessionId) const nsCString& aSessionId)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvSetSessionId(token=%u, sessionId='%s')", LOGD(("GMPDecryptorParent[%p]::RecvSetSessionId(token=%u, sessionId='%s')",
this, aCreateSessionId, aSessionId.get())); this, aCreateSessionId, aSessionId.get()));
@ -210,6 +213,7 @@ GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId,
return false; return false;
} }
mCallback->SetSessionId(aCreateSessionId, aSessionId); mCallback->SetSessionId(aCreateSessionId, aSessionId);
#endif
return true; return true;
} }
@ -217,6 +221,7 @@ bool
GMPDecryptorParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId, GMPDecryptorParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
const bool& aSuccess) const bool& aSuccess)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvResolveLoadSessionPromise(promiseId=%u)", LOGD(("GMPDecryptorParent[%p]::RecvResolveLoadSessionPromise(promiseId=%u)",
this, aPromiseId)); this, aPromiseId));
@ -225,12 +230,14 @@ GMPDecryptorParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
return false; return false;
} }
mCallback->ResolveLoadSessionPromise(aPromiseId, aSuccess); mCallback->ResolveLoadSessionPromise(aPromiseId, aSuccess);
#endif
return true; return true;
} }
bool bool
GMPDecryptorParent::RecvResolvePromise(const uint32_t& aPromiseId) GMPDecryptorParent::RecvResolvePromise(const uint32_t& aPromiseId)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvResolvePromise(promiseId=%u)", LOGD(("GMPDecryptorParent[%p]::RecvResolvePromise(promiseId=%u)",
this, aPromiseId)); this, aPromiseId));
@ -239,6 +246,7 @@ GMPDecryptorParent::RecvResolvePromise(const uint32_t& aPromiseId)
return false; return false;
} }
mCallback->ResolvePromise(aPromiseId); mCallback->ResolvePromise(aPromiseId);
#endif
return true; return true;
} }
@ -266,6 +274,7 @@ GMPDecryptorParent::RecvRejectPromise(const uint32_t& aPromiseId,
const GMPDOMException& aException, const GMPDOMException& aException,
const nsCString& aMessage) const nsCString& aMessage)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvRejectPromise(promiseId=%u, exception=%d, msg='%s')", LOGD(("GMPDecryptorParent[%p]::RecvRejectPromise(promiseId=%u, exception=%d, msg='%s')",
this, aPromiseId, aException, aMessage.get())); this, aPromiseId, aException, aMessage.get()));
@ -274,10 +283,11 @@ GMPDecryptorParent::RecvRejectPromise(const uint32_t& aPromiseId,
return false; return false;
} }
mCallback->RejectPromise(aPromiseId, GMPExToNsresult(aException), aMessage); mCallback->RejectPromise(aPromiseId, GMPExToNsresult(aException), aMessage);
#endif
return true; return true;
} }
#ifdef MOZ_EME
static dom::MediaKeyMessageType static dom::MediaKeyMessageType
ToMediaKeyMessageType(GMPSessionMessageType aMessageType) { ToMediaKeyMessageType(GMPSessionMessageType aMessageType) {
switch (aMessageType) { switch (aMessageType) {
@ -288,12 +298,14 @@ ToMediaKeyMessageType(GMPSessionMessageType aMessageType) {
default: return dom::MediaKeyMessageType::License_request; default: return dom::MediaKeyMessageType::License_request;
}; };
}; };
#endif
bool bool
GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId, GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId,
const GMPSessionMessageType& aMessageType, const GMPSessionMessageType& aMessageType,
nsTArray<uint8_t>&& aMessage) nsTArray<uint8_t>&& aMessage)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvSessionMessage(sessionId='%s', type=%d, msg='%s')", LOGD(("GMPDecryptorParent[%p]::RecvSessionMessage(sessionId='%s', type=%d, msg='%s')",
this, aSessionId.get(), aMessageType, ToBase64(aMessage).get())); this, aSessionId.get(), aMessageType, ToBase64(aMessage).get()));
@ -302,6 +314,7 @@ GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId,
return false; return false;
} }
mCallback->SessionMessage(aSessionId, ToMediaKeyMessageType(aMessageType), aMessage); mCallback->SessionMessage(aSessionId, ToMediaKeyMessageType(aMessageType), aMessage);
#endif
return true; return true;
} }
@ -309,6 +322,7 @@ bool
GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId, GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId,
const double& aExpiryTime) const double& aExpiryTime)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvExpirationChange(sessionId='%s', expiry=%lf)", LOGD(("GMPDecryptorParent[%p]::RecvExpirationChange(sessionId='%s', expiry=%lf)",
this, aSessionId.get(), aExpiryTime)); this, aSessionId.get(), aExpiryTime));
@ -317,12 +331,14 @@ GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId,
return false; return false;
} }
mCallback->ExpirationChange(aSessionId, aExpiryTime); mCallback->ExpirationChange(aSessionId, aExpiryTime);
#endif
return true; return true;
} }
bool bool
GMPDecryptorParent::RecvSessionClosed(const nsCString& aSessionId) GMPDecryptorParent::RecvSessionClosed(const nsCString& aSessionId)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvSessionClosed(sessionId='%s')", LOGD(("GMPDecryptorParent[%p]::RecvSessionClosed(sessionId='%s')",
this, aSessionId.get())); this, aSessionId.get()));
@ -331,6 +347,7 @@ GMPDecryptorParent::RecvSessionClosed(const nsCString& aSessionId)
return false; return false;
} }
mCallback->SessionClosed(aSessionId); mCallback->SessionClosed(aSessionId);
#endif
return true; return true;
} }
@ -340,6 +357,7 @@ GMPDecryptorParent::RecvSessionError(const nsCString& aSessionId,
const uint32_t& aSystemCode, const uint32_t& aSystemCode,
const nsCString& aMessage) const nsCString& aMessage)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvSessionError(sessionId='%s', exception=%d, sysCode=%d, msg='%s')", LOGD(("GMPDecryptorParent[%p]::RecvSessionError(sessionId='%s', exception=%d, sysCode=%d, msg='%s')",
this, aSessionId.get(), this, aSessionId.get(),
aException, aSystemCode, aMessage.get())); aException, aSystemCode, aMessage.get()));
@ -352,9 +370,11 @@ GMPDecryptorParent::RecvSessionError(const nsCString& aSessionId,
GMPExToNsresult(aException), GMPExToNsresult(aException),
aSystemCode, aSystemCode,
aMessage); aMessage);
#endif
return true; return true;
} }
#ifdef MOZ_EME
static dom::MediaKeyStatus static dom::MediaKeyStatus
ToMediaKeyStatus(GMPMediaKeyStatus aStatus) { ToMediaKeyStatus(GMPMediaKeyStatus aStatus) {
switch (aStatus) { switch (aStatus) {
@ -368,11 +388,13 @@ ToMediaKeyStatus(GMPMediaKeyStatus aStatus) {
default: return dom::MediaKeyStatus::Internal_error; default: return dom::MediaKeyStatus::Internal_error;
} }
} }
#endif
bool bool
GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId, GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
InfallibleTArray<GMPKeyInformation>&& aKeyInfos) InfallibleTArray<GMPKeyInformation>&& aKeyInfos)
{ {
#ifdef MOZ_EME
LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%d')", LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%d')",
this, aSessionId.get(), aKeyInfos.Length())); this, aSessionId.get(), aKeyInfos.Length()));
@ -392,9 +414,11 @@ GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
} }
mCallback->BatchedKeyStatusChanged(aSessionId, cdmKeyInfos); mCallback->BatchedKeyStatusChanged(aSessionId, cdmKeyInfos);
} }
#endif
return true; return true;
} }
#ifdef MOZ_EME
DecryptStatus DecryptStatus
ToDecryptStatus(GMPErr aError) ToDecryptStatus(GMPErr aError)
{ {
@ -405,12 +429,14 @@ ToDecryptStatus(GMPErr aError)
default: return GenericErr; default: return GenericErr;
} }
} }
#endif
bool bool
GMPDecryptorParent::RecvDecrypted(const uint32_t& aId, GMPDecryptorParent::RecvDecrypted(const uint32_t& aId,
const GMPErr& aErr, const GMPErr& aErr,
InfallibleTArray<uint8_t>&& aBuffer) InfallibleTArray<uint8_t>&& aBuffer)
{ {
#ifdef MOZ_EME
LOGV(("GMPDecryptorParent[%p]::RecvDecrypted(id=%d, err=%d)", LOGV(("GMPDecryptorParent[%p]::RecvDecrypted(id=%d, err=%d)",
this, aId, aErr)); this, aId, aErr));
@ -419,6 +445,7 @@ GMPDecryptorParent::RecvDecrypted(const uint32_t& aId,
return false; return false;
} }
mCallback->Decrypted(aId, ToDecryptStatus(aErr), aBuffer); mCallback->Decrypted(aId, ToDecryptStatus(aErr), aBuffer);
#endif
return true; return true;
} }

View file

@ -6,7 +6,9 @@
#ifndef GMPDecryptorProxy_h_ #ifndef GMPDecryptorProxy_h_
#define GMPDecryptorProxy_h_ #define GMPDecryptorProxy_h_
#ifdef MOZ_EME
#include "mozilla/DecryptorProxyCallback.h" #include "mozilla/DecryptorProxyCallback.h"
#endif
#include "GMPCallbackBase.h" #include "GMPCallbackBase.h"
#include "gmp-decryption.h" #include "gmp-decryption.h"
#include "nsString.h" #include "nsString.h"
@ -15,8 +17,13 @@ namespace mozilla {
class CryptoSample; class CryptoSample;
} // namespace mozilla } // namespace mozilla
#ifdef MOZ_EME
class GMPDecryptorProxyCallback : public DecryptorProxyCallback, class GMPDecryptorProxyCallback : public DecryptorProxyCallback,
public GMPCallbackBase { public GMPCallbackBase {
#else
class GMPDecryptorProxyCallback : public GMPCallbackBase {
#endif
public: public:
virtual ~GMPDecryptorProxyCallback() {} virtual ~GMPDecryptorProxyCallback() {}
}; };