--- a/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
@@ -39,17 +39,17 @@ GMPErr GMPCreateRecord(const char* aReco
void
WidevineAdapter::SetAdaptee(PRLibrary* aLib)
{
mLib = aLib;
}
void* GetCdmHost(int aHostInterfaceVersion, void* aUserData)
{
- Log("GetCdmHostFunc(%d, %p)", aHostInterfaceVersion, aUserData);
+ CDM_LOG("GetCdmHostFunc(%d, %p)", aHostInterfaceVersion, aUserData);
WidevineDecryptor* decryptor = reinterpret_cast<WidevineDecryptor*>(aUserData);
MOZ_ASSERT(decryptor);
return static_cast<cdm::Host_8*>(decryptor);
}
#define STRINGIFY(s) _STRINGIFY(s)
#define _STRINGIFY(s) #s
@@ -62,90 +62,90 @@ WidevineAdapter::GMPInit(const GMPPlatfo
}
auto init = reinterpret_cast<decltype(::INITIALIZE_CDM_MODULE)*>(
PR_FindFunctionSymbol(mLib, STRINGIFY(INITIALIZE_CDM_MODULE)));
if (!init) {
return GMPGenericErr;
}
- Log(STRINGIFY(INITIALIZE_CDM_MODULE)"()");
+ CDM_LOG(STRINGIFY(INITIALIZE_CDM_MODULE)"()");
init();
return GMPNoErr;
}
GMPErr
WidevineAdapter::GMPGetAPI(const char* aAPIName,
void* aHostAPI,
void** aPluginAPI,
uint32_t aDecryptorId)
{
- Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p",
- aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
+ CDM_LOG("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p",
+ aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
if (!strcmp(aAPIName, GMP_API_DECRYPTOR)) {
if (WidevineDecryptor::GetInstance(aDecryptorId)) {
// We only support one CDM instance per PGMPDecryptor. Fail!
- Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per IPDL actor! FAIL!");
+ CDM_LOG("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per IPDL actor! FAIL!");
return GMPQuotaExceededErr;
}
auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>(
PR_FindFunctionSymbol(mLib, "CreateCdmInstance"));
if (!create) {
- Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to find CreateCdmInstance",
- aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
+ CDM_LOG("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to find CreateCdmInstance",
+ aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
return GMPGenericErr;
}
auto* decryptor = new WidevineDecryptor();
auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>(
create(cdm::ContentDecryptionModule::kVersion,
kEMEKeySystemWidevine.get(),
kEMEKeySystemWidevine.Length(),
&GetCdmHost,
decryptor));
if (!cdm) {
- Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to create cdm",
- aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
+ CDM_LOG("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to create cdm",
+ aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
return GMPGenericErr;
}
- Log("cdm: 0x%p", cdm);
+ CDM_LOG("cdm: 0x%p", cdm);
RefPtr<CDMWrapper> wrapper(new CDMWrapper(cdm, decryptor));
decryptor->SetCDM(wrapper, aDecryptorId);
*aPluginAPI = decryptor;
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
RefPtr<CDMWrapper> wrapper = WidevineDecryptor::GetInstance(aDecryptorId);
// There is a possible race condition, where the decryptor will be destroyed
// before we are able to create the video decoder, so we create a dummy
// decoder to avoid crashing.
if (!wrapper) {
- Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p No cdm for video decoder. Using a DummyDecoder",
- aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
+ CDM_LOG("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p No cdm for video decoder. Using a DummyDecoder",
+ aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
*aPluginAPI = new WidevineDummyDecoder();
} else {
*aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
wrapper);
}
}
return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
}
void
WidevineAdapter::GMPShutdown()
{
- Log("WidevineAdapter::GMPShutdown()");
+ CDM_LOG("WidevineAdapter::GMPShutdown()");
decltype(::DeinitializeCdmModule)* deinit;
deinit = (decltype(deinit))(PR_FindFunctionSymbol(mLib, "DeinitializeCdmModule"));
if (deinit) {
- Log("DeinitializeCdmModule()");
+ CDM_LOG("DeinitializeCdmModule()");
deinit();
}
}
/* static */
bool
WidevineAdapter::Supports(int32_t aModuleVersion,
int32_t aInterfaceVersion,
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
@@ -30,40 +30,40 @@ WidevineDecryptor::GetInstance(uint32_t
}
return nullptr;
}
WidevineDecryptor::WidevineDecryptor()
: mCallback(nullptr)
{
- Log("WidevineDecryptor created this=%p, instanceId=%u", this, mInstanceId);
+ CDM_LOG("WidevineDecryptor created this=%p, instanceId=%u", this, mInstanceId);
AddRef(); // Released in DecryptingComplete().
}
WidevineDecryptor::~WidevineDecryptor()
{
- Log("WidevineDecryptor destroyed this=%p, instanceId=%u", this, mInstanceId);
+ CDM_LOG("WidevineDecryptor destroyed this=%p, instanceId=%u", this, mInstanceId);
}
void
WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM, uint32_t aInstanceId)
{
mCDM = aCDM;
mInstanceId = aInstanceId;
sDecryptors[mInstanceId] = aCDM.forget();
}
void
WidevineDecryptor::Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
{
- Log("WidevineDecryptor::Init() this=%p distinctiveId=%d persistentState=%d",
- this, aDistinctiveIdentifierRequired, aPersistentStateRequired);
+ CDM_LOG("WidevineDecryptor::Init() this=%p distinctiveId=%d persistentState=%d",
+ this, aDistinctiveIdentifierRequired, aPersistentStateRequired);
MOZ_ASSERT(aCallback);
mCallback = aCallback;
MOZ_ASSERT(mCDM);
mDistinctiveIdentifierRequired = aDistinctiveIdentifierRequired;
mPersistentStateRequired = aPersistentStateRequired;
if (CDM()) {
CDM()->Initialize(aDistinctiveIdentifierRequired,
aPersistentStateRequired);
@@ -87,17 +87,17 @@ void
WidevineDecryptor::CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,
const char* aInitDataType,
uint32_t aInitDataTypeSize,
const uint8_t* aInitData,
uint32_t aInitDataSize,
GMPSessionType aSessionType)
{
- Log("Decryptor::CreateSession(token=%d, pid=%d)", aCreateSessionToken, aPromiseId);
+ CDM_LOG("Decryptor::CreateSession(token=%d, pid=%d)", aCreateSessionToken, aPromiseId);
InitDataType initDataType;
if (!strcmp(aInitDataType, "cenc")) {
initDataType = kCenc;
} else if (!strcmp(aInitDataType, "webm")) {
initDataType = kWebM;
} else if (!strcmp(aInitDataType, "keyids")) {
initDataType = kKeyIds;
} else {
@@ -113,56 +113,56 @@ WidevineDecryptor::CreateSession(uint32_
aInitData, aInitDataSize);
}
void
WidevineDecryptor::LoadSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength)
{
- Log("Decryptor::LoadSession(pid=%d, %s)", aPromiseId, aSessionId);
+ CDM_LOG("Decryptor::LoadSession(pid=%d, %s)", aPromiseId, aSessionId);
// TODO: session type??
CDM()->LoadSession(aPromiseId, kPersistentLicense, aSessionId, aSessionIdLength);
}
void
WidevineDecryptor::UpdateSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength,
const uint8_t* aResponse,
uint32_t aResponseSize)
{
- Log("Decryptor::UpdateSession(pid=%d, session=%s)", aPromiseId, aSessionId);
+ CDM_LOG("Decryptor::UpdateSession(pid=%d, session=%s)", aPromiseId, aSessionId);
CDM()->UpdateSession(aPromiseId, aSessionId, aSessionIdLength, aResponse, aResponseSize);
}
void
WidevineDecryptor::CloseSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength)
{
- Log("Decryptor::CloseSession(pid=%d, session=%s)", aPromiseId, aSessionId);
+ CDM_LOG("Decryptor::CloseSession(pid=%d, session=%s)", aPromiseId, aSessionId);
CDM()->CloseSession(aPromiseId, aSessionId, aSessionIdLength);
}
void
WidevineDecryptor::RemoveSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength)
{
- Log("Decryptor::RemoveSession(%s)", aSessionId);
+ CDM_LOG("Decryptor::RemoveSession(%s)", aSessionId);
CDM()->RemoveSession(aPromiseId, aSessionId, aSessionIdLength);
}
void
WidevineDecryptor::SetServerCertificate(uint32_t aPromiseId,
const uint8_t* aServerCert,
uint32_t aServerCertSize)
{
- Log("Decryptor::SetServerCertificate()");
+ CDM_LOG("Decryptor::SetServerCertificate()");
CDM()->SetServerCertificate(aPromiseId, aServerCert, aServerCertSize);
}
class WidevineDecryptedBlock : public cdm::DecryptedBlock {
public:
WidevineDecryptedBlock()
: mBuffer(nullptr)
@@ -226,17 +226,17 @@ WidevineDecryptor::ThrottleDecrypt(cdm::
}
void
WidevineDecryptor::Decrypt(GMPBuffer* aBuffer,
GMPEncryptedBufferMetadata* aMetadata,
uint64_t aDurationUsecs)
{
if (!mCallback) {
- Log("WidevineDecryptor::Decrypt() this=%p FAIL; !mCallback", this);
+ CDM_LOG("WidevineDecryptor::Decrypt() this=%p FAIL; !mCallback", this);
return;
}
cdm::Time duration = double(aDurationUsecs) / USECS_PER_S;
mPendingDecrypts.push({aBuffer, aMetadata, duration});
ProcessDecrypts();
}
@@ -286,31 +286,32 @@ WidevineDecryptor::DecryptBuffer(const P
{
GMPBuffer* buffer = aJob.mBuffer;
const GMPEncryptedBufferMetadata* crypto = aJob.mMetadata;
InputBuffer sample;
nsTArray<SubsampleEntry> subsamples;
InitInputBuffer(crypto, buffer->Id(), buffer->Data(), buffer->Size(), sample, subsamples);
WidevineDecryptedBlock decrypted;
Status rv = CDM()->Decrypt(sample, &decrypted);
- Log("Decryptor::Decrypt(timestamp=%" PRId64 ") rv=%d sz=%d",
- sample.timestamp, rv, decrypted.DecryptedBuffer()->Size());
+ CDM_LOG("Decryptor::Decrypt(timestamp=%" PRId64 ") rv=%d sz=%d",
+ sample.timestamp, rv, decrypted.DecryptedBuffer()->Size());
if (rv == kSuccess) {
buffer->Resize(decrypted.DecryptedBuffer()->Size());
memcpy(buffer->Data(),
decrypted.DecryptedBuffer()->Data(),
decrypted.DecryptedBuffer()->Size());
}
mCallback->Decrypted(buffer, ToGMPErr(rv));
}
void
WidevineDecryptor::DecryptingComplete()
{
- Log("WidevineDecryptor::DecryptingComplete() this=%p, instanceId=%u", this, mInstanceId);
+ CDM_LOG("WidevineDecryptor::DecryptingComplete() this=%p, instanceId=%u",
+ this, mInstanceId);
// Ensure buffers are freed.
while (!mPendingDecrypts.empty()) {
PendingDecrypt& job = mPendingDecrypts.front();
if (mCallback) {
mCallback->Decrypted(job.mBuffer, GMPAbortedErr);
}
mPendingDecrypts.pop();
@@ -324,21 +325,21 @@ WidevineDecryptor::DecryptingComplete()
sDecryptors.erase(mInstanceId);
mCallback = nullptr;
Release();
}
class WidevineBuffer : public cdm::Buffer {
public:
explicit WidevineBuffer(size_t aSize) {
- Log("WidevineBuffer(size=%" PRIuSIZE ") created", aSize);
+ CDM_LOG("WidevineBuffer(size=%" PRIuSIZE ") created", aSize);
mBuffer.SetLength(aSize);
}
~WidevineBuffer() override {
- Log("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
+ CDM_LOG("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
}
void Destroy() override { delete this; }
uint32_t Capacity() const override { return mBuffer.Length(); };
uint8_t* Data() override { return mBuffer.Elements(); }
void SetSize(uint32_t aSize) override { mBuffer.SetLength(aSize); }
uint32_t Size() const override { return mBuffer.Length(); }
private:
@@ -346,17 +347,17 @@ private:
void operator=(const WidevineBuffer&);
nsTArray<uint8_t> mBuffer;
};
Buffer*
WidevineDecryptor::Allocate(uint32_t aCapacity)
{
- Log("Decryptor::Allocate(capacity=%u)", aCapacity);
+ CDM_LOG("Decryptor::Allocate(capacity=%u)", aCapacity);
return new WidevineBuffer(aCapacity);
}
class TimerTask : public GMPTask {
public:
TimerTask(WidevineDecryptor* aDecryptor,
RefPtr<CDMWrapper> aCDM,
void* aContext)
@@ -374,71 +375,71 @@ private:
RefPtr<WidevineDecryptor> mDecryptor;
RefPtr<CDMWrapper> mCDM;
void* mContext;
};
void
WidevineDecryptor::SetTimer(int64_t aDelayMs, void* aContext)
{
- Log("Decryptor::SetTimer(delay_ms=%" PRId64 ", context=0x%p)", aDelayMs, aContext);
+ CDM_LOG("Decryptor::SetTimer(delay_ms=%" PRId64 ", context=0x%p)", aDelayMs, aContext);
if (mCDM) {
GMPSetTimerOnMainThread(new TimerTask(this, mCDM, aContext), aDelayMs);
}
}
Time
WidevineDecryptor::GetCurrentWallTime()
{
GMPTimestamp gmpTime = 0;
GMPGetCurrentTime(&gmpTime);
double t = (double)gmpTime / 1e3;
- Log("Decryptor::GetCurrentWallTime()= %lf", t);
+ CDM_LOG("Decryptor::GetCurrentWallTime()= %lf", t);
return t;
}
void
WidevineDecryptor::OnResolveNewSessionPromise(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdSize)
{
if (!mCallback) {
- Log("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d) FAIL; !mCallback", aPromiseId);
+ CDM_LOG("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d) FAIL; !mCallback", aPromiseId);
return;
}
// This is laid out in the API. If we fail to load a session we should
// call OnResolveNewSessionPromise with nullptr as the sessionId.
// We can safely assume this means that we have failed to load a session
// as the other methods specify calling 'OnRejectPromise' when they fail.
if (!aSessionId) {
- Log("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d) Failed to load session", aPromiseId);
+ CDM_LOG("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d) Failed to load session", aPromiseId);
mCallback->ResolveLoadSessionPromise(aPromiseId, false);
return;
}
- Log("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d)", aPromiseId);
+ CDM_LOG("Decryptor::OnResolveNewSessionPromise(aPromiseId=0x%d)", aPromiseId);
auto iter = mPromiseIdToNewSessionTokens.find(aPromiseId);
if (iter == mPromiseIdToNewSessionTokens.end()) {
- Log("FAIL: Decryptor::OnResolveNewSessionPromise(aPromiseId=%d) unknown aPromiseId", aPromiseId);
+ CDM_LOG("FAIL: Decryptor::OnResolveNewSessionPromise(aPromiseId=%d) unknown aPromiseId", aPromiseId);
return;
}
mCallback->SetSessionId(iter->second, aSessionId, aSessionIdSize);
mCallback->ResolvePromise(aPromiseId);
mPromiseIdToNewSessionTokens.erase(iter);
}
void
WidevineDecryptor::OnResolvePromise(uint32_t aPromiseId)
{
if (!mCallback) {
- Log("Decryptor::OnResolvePromise(aPromiseId=0x%d) FAIL; !mCallback", aPromiseId);
+ CDM_LOG("Decryptor::OnResolvePromise(aPromiseId=0x%d) FAIL; !mCallback", aPromiseId);
return;
}
- Log("Decryptor::OnResolvePromise(aPromiseId=%d)", aPromiseId);
+ CDM_LOG("Decryptor::OnResolvePromise(aPromiseId=%d)", aPromiseId);
mCallback->ResolvePromise(aPromiseId);
}
static GMPDOMException
ToGMPDOMException(cdm::Error aError)
{
switch (aError) {
case kNotSupportedError: return kGMPNotSupportedError;
@@ -460,22 +461,22 @@ ToGMPDOMException(cdm::Error aError)
void
WidevineDecryptor::OnRejectPromise(uint32_t aPromiseId,
Error aError,
uint32_t aSystemCode,
const char* aErrorMessage,
uint32_t aErrorMessageSize)
{
if (!mCallback) {
- Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s) FAIL; !mCallback",
- aPromiseId, (int)aError, aSystemCode, aErrorMessage);
+ CDM_LOG("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s) FAIL; !mCallback",
+ aPromiseId, (int)aError, aSystemCode, aErrorMessage);
return;
}
- Log("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s)",
- aPromiseId, (int)aError, aSystemCode, aErrorMessage);
+ CDM_LOG("Decryptor::OnRejectPromise(aPromiseId=%d, err=%d, sysCode=%u, msg=%s)",
+ aPromiseId, (int)aError, aSystemCode, aErrorMessage);
mCallback->RejectPromise(aPromiseId,
ToGMPDOMException(aError),
!aErrorMessageSize ? "" : aErrorMessage,
aErrorMessageSize);
}
static GMPSessionMessageType
ToGMPMessageType(MessageType message_type)
@@ -493,20 +494,20 @@ WidevineDecryptor::OnSessionMessage(cons
uint32_t aSessionIdSize,
MessageType aMessageType,
const char* aMessage,
uint32_t aMessageSize,
const char* aLegacyDestinationUrl,
uint32_t aLegacyDestinationUrlLength)
{
if (!mCallback) {
- Log("Decryptor::OnSessionMessage() FAIL; !mCallback");
+ CDM_LOG("Decryptor::OnSessionMessage() FAIL; !mCallback");
return;
}
- Log("Decryptor::OnSessionMessage()");
+ CDM_LOG("Decryptor::OnSessionMessage()");
mCallback->SessionMessage(aSessionId,
aSessionIdSize,
ToGMPMessageType(aMessageType),
reinterpret_cast<const uint8_t*>(aMessage),
aMessageSize);
}
static GMPMediaKeyStatus
@@ -527,20 +528,20 @@ ToGMPKeyStatus(KeyStatus aStatus)
void
WidevineDecryptor::OnSessionKeysChange(const char* aSessionId,
uint32_t aSessionIdSize,
bool aHasAdditionalUsableKey,
const KeyInformation* aKeysInfo,
uint32_t aKeysInfoCount)
{
if (!mCallback) {
- Log("Decryptor::OnSessionKeysChange() FAIL; !mCallback");
+ CDM_LOG("Decryptor::OnSessionKeysChange() FAIL; !mCallback");
return;
}
- Log("Decryptor::OnSessionKeysChange()");
+ CDM_LOG("Decryptor::OnSessionKeysChange()");
nsTArray<GMPMediaKeyInfo> key_infos;
for (uint32_t i = 0; i < aKeysInfoCount; i++) {
key_infos.AppendElement(GMPMediaKeyInfo(aKeysInfo[i].key_id,
aKeysInfo[i].key_id_size,
ToGMPKeyStatus(aKeysInfo[i].status)));
}
mCallback->BatchedKeyStatusChanged(aSessionId, aSessionIdSize,
@@ -554,93 +555,93 @@ ToGMPTime(Time aCDMTime)
}
void
WidevineDecryptor::OnExpirationChange(const char* aSessionId,
uint32_t aSessionIdSize,
Time aNewExpiryTime)
{
if (!mCallback) {
- Log("Decryptor::OnExpirationChange(sid=%s) t=%lf FAIL; !mCallback",
- aSessionId, aNewExpiryTime);
+ CDM_LOG("Decryptor::OnExpirationChange(sid=%s) t=%lf FAIL; !mCallback",
+ aSessionId, aNewExpiryTime);
return;
}
- Log("Decryptor::OnExpirationChange(sid=%s) t=%lf", aSessionId, aNewExpiryTime);
+ CDM_LOG("Decryptor::OnExpirationChange(sid=%s) t=%lf", aSessionId, aNewExpiryTime);
GMPTimestamp expiry = ToGMPTime(aNewExpiryTime);
if (aNewExpiryTime == 0) {
return;
}
mCallback->ExpirationChange(aSessionId, aSessionIdSize, expiry);
}
void
WidevineDecryptor::OnSessionClosed(const char* aSessionId,
uint32_t aSessionIdSize)
{
if (!mCallback) {
- Log("Decryptor::OnSessionClosed(sid=%s) FAIL; !mCallback", aSessionId);
+ CDM_LOG("Decryptor::OnSessionClosed(sid=%s) FAIL; !mCallback", aSessionId);
return;
}
- Log("Decryptor::OnSessionClosed(sid=%s)", aSessionId);
+ CDM_LOG("Decryptor::OnSessionClosed(sid=%s)", aSessionId);
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);
+ CDM_LOG("Decryptor::OnLegacySessionError(sid=%s, error=%d) FAIL; !mCallback",
+ aSessionId, (int)aError);
return;
}
- Log("Decryptor::OnLegacySessionError(sid=%s, error=%d)", aSessionId, (int)aError);
+ CDM_LOG("Decryptor::OnLegacySessionError(sid=%s, error=%d)", aSessionId, (int)aError);
mCallback->SessionError(aSessionId,
aSessionIdLength,
ToGMPDOMException(aError),
aSystemCode,
aErrorMessage,
aErrorMessageLength);
}
void
WidevineDecryptor::SendPlatformChallenge(const char* aServiceId,
uint32_t aServiceIdSize,
const char* aChallenge,
uint32_t aChallengeSize)
{
- Log("Decryptor::SendPlatformChallenge(service_id=%s)", aServiceId);
+ CDM_LOG("Decryptor::SendPlatformChallenge(service_id=%s)", aServiceId);
}
void
WidevineDecryptor::EnableOutputProtection(uint32_t aDesiredProtectionMask)
{
- Log("Decryptor::EnableOutputProtection(mask=0x%x)", aDesiredProtectionMask);
+ CDM_LOG("Decryptor::EnableOutputProtection(mask=0x%x)", aDesiredProtectionMask);
}
void
WidevineDecryptor::QueryOutputProtectionStatus()
{
- Log("Decryptor::QueryOutputProtectionStatus()");
+ CDM_LOG("Decryptor::QueryOutputProtectionStatus()");
}
void
WidevineDecryptor::OnDeferredInitializationDone(StreamType aStreamType,
Status aDecoderStatus)
{
- Log("Decryptor::OnDeferredInitializationDone()");
+ CDM_LOG("Decryptor::OnDeferredInitializationDone()");
}
FileIO*
WidevineDecryptor::CreateFileIO(FileIOClient* aClient)
{
- Log("Decryptor::CreateFileIO()");
+ CDM_LOG("Decryptor::CreateFileIO()");
if (!mPersistentStateRequired) {
return nullptr;
}
return new WidevineFileIO(aClient);
}
} // namespace mozilla
--- a/dom/media/gmp/widevine-adapter/WidevineDummyDecoder.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDummyDecoder.cpp
@@ -1,57 +1,57 @@
#include "WidevineDummyDecoder.h"
#include "WidevineUtils.h"
using namespace cdm;
namespace mozilla {
WidevineDummyDecoder::WidevineDummyDecoder()
{
- Log("WidevineDummyDecoder created");
+ CDM_LOG("WidevineDummyDecoder created");
}
void WidevineDummyDecoder::InitDecode(const GMPVideoCodec & aCodecSettings,
const uint8_t * aCodecSpecific,
uint32_t aCodecSpecificLength,
GMPVideoDecoderCallback * aCallback,
int32_t aCoreCount)
{
- Log("WidevineDummyDecoder::InitDecode");
+ CDM_LOG("WidevineDummyDecoder::InitDecode");
mCallback = aCallback;
mCallback->Error(GMPErr::GMPNotImplementedErr);
}
void WidevineDummyDecoder::Decode(GMPVideoEncodedFrame * aInputFrame,
bool aMissingFrames,
const uint8_t * aCodecSpecificInfo,
uint32_t aCodecSpecificInfoLength,
int64_t aRenderTimeMs)
{
- Log("WidevineDummyDecoder::Decode");
+ CDM_LOG("WidevineDummyDecoder::Decode");
mCallback->Error(GMPErr::GMPNotImplementedErr);
}
void WidevineDummyDecoder::Reset()
{
- Log("WidevineDummyDecoder::Reset");
+ CDM_LOG("WidevineDummyDecoder::Reset");
mCallback->Error(GMPErr::GMPNotImplementedErr);
}
void WidevineDummyDecoder::Drain()
{
- Log("WidevineDummyDecoder::Drain");
+ CDM_LOG("WidevineDummyDecoder::Drain");
mCallback->Error(GMPErr::GMPNotImplementedErr);
}
void WidevineDummyDecoder::DecodingComplete()
{
- Log("WidevineDummyDecoder::DecodingComplete");
+ CDM_LOG("WidevineDummyDecoder::DecodingComplete");
mCallback = nullptr;
delete this;
}
WidevineDummyDecoder::~WidevineDummyDecoder() {
- Log("WidevineDummyDecoder destroyed");
+ CDM_LOG("WidevineDummyDecoder destroyed");
}
}
\ No newline at end of file
--- a/dom/media/gmp/widevine-adapter/WidevineFileIO.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineFileIO.cpp
@@ -8,57 +8,57 @@ namespace mozilla {
void
WidevineFileIO::Open(const char* aFilename, uint32_t aFilenameLength)
{
mName = std::string(aFilename, aFilename + aFilenameLength);
GMPRecord* record = nullptr;
GMPErr err = GMPCreateRecord(aFilename, aFilenameLength, &record, static_cast<GMPRecordClient*>(this));
if (GMP_FAILED(err)) {
- Log("WidevineFileIO::Open() '%s' GMPCreateRecord failed", mName.c_str());
+ CDM_LOG("WidevineFileIO::Open() '%s' GMPCreateRecord failed", mName.c_str());
mClient->OnOpenComplete(FileIOClient::kError);
return;
}
if (GMP_FAILED(record->Open())) {
- Log("WidevineFileIO::Open() '%s' record open failed", mName.c_str());
+ CDM_LOG("WidevineFileIO::Open() '%s' record open failed", mName.c_str());
mClient->OnOpenComplete(FileIOClient::kError);
return;
}
- Log("WidevineFileIO::Open() '%s'", mName.c_str());
+ CDM_LOG("WidevineFileIO::Open() '%s'", mName.c_str());
mRecord = record;
}
void
WidevineFileIO::Read()
{
if (!mRecord) {
- Log("WidevineFileIO::Read() '%s' used uninitialized!", mName.c_str());
+ CDM_LOG("WidevineFileIO::Read() '%s' used uninitialized!", mName.c_str());
mClient->OnReadComplete(FileIOClient::kError, nullptr, 0);
return;
}
- Log("WidevineFileIO::Read() '%s'", mName.c_str());
+ CDM_LOG("WidevineFileIO::Read() '%s'", mName.c_str());
mRecord->Read();
}
void
WidevineFileIO::Write(const uint8_t* aData, uint32_t aDataSize)
{
if (!mRecord) {
- Log("WidevineFileIO::Write() '%s' used uninitialized!", mName.c_str());
+ CDM_LOG("WidevineFileIO::Write() '%s' used uninitialized!", mName.c_str());
mClient->OnWriteComplete(FileIOClient::kError);
return;
}
mRecord->Write(aData, aDataSize);
}
void
WidevineFileIO::Close()
{
- Log("WidevineFileIO::Close() '%s'", mName.c_str());
+ CDM_LOG("WidevineFileIO::Close() '%s'", mName.c_str());
if (mRecord) {
mRecord->Close();
mRecord = nullptr;
}
delete this;
}
static FileIOClient::Status
@@ -69,29 +69,29 @@ GMPToWidevineFileStatus(GMPErr aStatus)
case GMPNoErr: return FileIOClient::kSuccess;
default: return FileIOClient::kError;
}
}
void
WidevineFileIO::OpenComplete(GMPErr aStatus)
{
- Log("WidevineFileIO::OpenComplete() '%s' status=%d", mName.c_str(), aStatus);
+ CDM_LOG("WidevineFileIO::OpenComplete() '%s' status=%d", mName.c_str(), aStatus);
mClient->OnOpenComplete(GMPToWidevineFileStatus(aStatus));
}
void
WidevineFileIO::ReadComplete(GMPErr aStatus,
const uint8_t* aData,
uint32_t aDataSize)
{
- Log("WidevineFileIO::OnReadComplete() '%s' status=%d", mName.c_str(), aStatus);
+ CDM_LOG("WidevineFileIO::OnReadComplete() '%s' status=%d", mName.c_str(), aStatus);
mClient->OnReadComplete(GMPToWidevineFileStatus(aStatus), aData, aDataSize);
}
void
WidevineFileIO::WriteComplete(GMPErr aStatus)
{
- Log("WidevineFileIO::WriteComplete() '%s' status=%d", mName.c_str(), aStatus);
+ CDM_LOG("WidevineFileIO::WriteComplete() '%s' status=%d", mName.c_str(), aStatus);
mClient->OnWriteComplete(GMPToWidevineFileStatus(aStatus));
}
} // namespace mozilla
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
@@ -66,14 +66,14 @@ CDMWrapper::CDMWrapper(cdm::ContentDecry
: mCDM(aCDM)
, mDecryptor(aDecryptor)
{
MOZ_ASSERT(mCDM);
}
CDMWrapper::~CDMWrapper()
{
- Log("CDMWrapper destroying CDM=%p", mCDM);
+ CDM_LOG("CDMWrapper destroying CDM=%p", mCDM);
mCDM->Destroy();
mCDM = nullptr;
}
} // namespace mozilla
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.h
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.h
@@ -15,28 +15,28 @@
#include "mozilla/Logging.h"
namespace mozilla {
namespace detail {
LogModule* GetCDMLog();
} // namespace detail
-#define Log(...) MOZ_LOG(detail::GetCDMLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
+#define CDM_LOG(...) MOZ_LOG(detail::GetCDMLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
#define ENSURE_TRUE(condition, rv) { \
if (!(condition)) {\
- Log("ENSURE_TRUE FAILED %s:%d", __FILE__, __LINE__); \
+ CDM_LOG("ENSURE_TRUE FAILED %s:%d", __FILE__, __LINE__); \
return rv; \
} \
} \
#define ENSURE_GMP_SUCCESS(err, rv) { \
if (GMP_FAILED(err)) {\
- Log("ENSURE_GMP_SUCCESS FAILED %s:%d", __FILE__, __LINE__); \
+ CDM_LOG("ENSURE_GMP_SUCCESS FAILED %s:%d", __FILE__, __LINE__); \
return rv; \
} \
} \
GMPErr
ToGMPErr(cdm::Status aStatus);
class WidevineDecryptor;
--- a/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
@@ -22,25 +22,25 @@ WidevineVideoDecoder::WidevineVideoDecod
, mSentInput(false)
, mCodecType(kGMPVideoCodecInvalid)
, mReturnOutputCallDepth(0)
, mDrainPending(false)
, mResetInProgress(false)
{
// Expect to start with a CDM wrapper, will release it in DecodingComplete().
MOZ_ASSERT(mCDMWrapper);
- Log("WidevineVideoDecoder created this=%p", this);
+ CDM_LOG("WidevineVideoDecoder created this=%p", this);
// Corresponding Release is in DecodingComplete().
AddRef();
}
WidevineVideoDecoder::~WidevineVideoDecoder()
{
- Log("WidevineVideoDecoder destroyed this=%p", this);
+ CDM_LOG("WidevineVideoDecoder destroyed this=%p", this);
}
static
VideoDecoderConfig::VideoCodecProfile
ToCDMH264Profile(uint8_t aProfile)
{
switch (aProfile) {
case 66: return VideoDecoderConfig::kH264ProfileBaseline;
@@ -83,17 +83,17 @@ WidevineVideoDecoder::InitDecode(const G
mExtraData->AppendElements(aCodecSpecific + 1, aCodecSpecificLength);
config.extra_data = mExtraData->Elements();
config.extra_data_size = mExtraData->Length();
Status rv = CDM()->InitializeVideoDecoder(config);
if (rv != kSuccess) {
mCallback->Error(ToGMPErr(rv));
return;
}
- Log("WidevineVideoDecoder::InitDecode() rv=%d", rv);
+ CDM_LOG("WidevineVideoDecoder::InitDecode() rv=%d", rv);
mAnnexB = mp4_demuxer::AnnexB::ConvertExtraDataToAnnexB(mExtraData);
}
void
WidevineVideoDecoder::Decode(GMPVideoEncodedFrame* aInputFrame,
bool aMissingFrames,
const uint8_t* aCodecSpecificInfo,
uint32_t aCodecSpecificInfoLength,
@@ -136,27 +136,27 @@ WidevineVideoDecoder::Decode(GMPVideoEnc
if (raw->mKeyframe
&& !subsamples.IsEmpty()
&& mCodecType == kGMPVideoCodecH264) {
subsamples[0].clear_bytes += mAnnexB->Length();
}
WidevineVideoFrame frame;
Status rv = CDM()->DecryptAndDecodeFrame(sample, &frame);
- Log("WidevineVideoDecoder::Decode(timestamp=%" PRId64 ") rv=%d", sample.timestamp,
- rv);
+ CDM_LOG("WidevineVideoDecoder::Decode(timestamp=%" PRId64 ") rv=%d",
+ sample.timestamp, rv);
// Destroy frame, so that the shmem is now free to be used to return
// output to the Gecko process.
aInputFrame->Destroy();
aInputFrame = nullptr;
if (rv == kSuccess) {
if (!ReturnOutput(frame)) {
- Log("WidevineVideoDecoder::Decode() Failed in ReturnOutput()");
+ CDM_LOG("WidevineVideoDecoder::Decode() Failed in ReturnOutput()");
mCallback->Error(GMPDecodeErr);
return;
}
// A reset should only be started at most at level mReturnOutputCallDepth 1,
// and if it's started it should be finished by that call by the time
// the it returns, so it should always be false by this point.
MOZ_ASSERT(!mResetInProgress);
// Only request more data if we don't have pending samples.
@@ -245,17 +245,17 @@ WidevineVideoDecoder::ReturnOutput(Widev
// be in a reset at this stage -- this would indicate receiving decode
// messages before completing our reset, which we should not.
MOZ_ASSERT(!mResetInProgress);
WidevineVideoFrame currentCDMFrame = Move(mFrameAllocationQueue.front());
mFrameAllocationQueue.pop_front();
GMPVideoFrame* f = nullptr;
auto err = mVideoHost->CreateFrame(kGMPI420VideoFrame, &f);
if (GMP_FAILED(err) || !f) {
- Log("Failed to create i420 frame!\n");
+ CDM_LOG("Failed to create i420 frame!\n");
return false;
}
auto gmpFrame = static_cast<GMPVideoi420Frame*>(f);
FrameDestroyerHelper frameDestroyerHelper(gmpFrame);
Size size = currentCDMFrame.Size();
const int32_t yStride = currentCDMFrame.Stride(VideoFrame::kYPlane);
const int32_t uStride = currentCDMFrame.Stride(VideoFrame::kUPlane);
const int32_t vStride = currentCDMFrame.Stride(VideoFrame::kVPlane);
@@ -326,17 +326,17 @@ WidevineVideoDecoder::ReturnOutput(Widev
}
return true;
}
void
WidevineVideoDecoder::Reset()
{
- Log("WidevineVideoDecoder::Reset() mSentInput=%d", mSentInput);
+ CDM_LOG("WidevineVideoDecoder::Reset() mSentInput=%d", mSentInput);
// We shouldn't reset if a drain is pending.
MOZ_ASSERT(!mDrainPending);
mResetInProgress = true;
if (mSentInput) {
CDM()->ResetDecoder(kStreamTypeVideo);
}
// Remove queued frames, but do not reset mReturnOutputCallDepth, let the
// ReturnOutput calls unwind and decrement the counter as needed.
@@ -355,57 +355,57 @@ WidevineVideoDecoder::CompleteReset()
mCallback->ResetComplete();
mSentInput = false;
mResetInProgress = false;
}
void
WidevineVideoDecoder::Drain()
{
- Log("WidevineVideoDecoder::Drain()");
+ CDM_LOG("WidevineVideoDecoder::Drain()");
if (mReturnOutputCallDepth > 0) {
- Log("Drain call is reentrant, postponing drain");
+ CDM_LOG("Drain call is reentrant, postponing drain");
mDrainPending = true;
return;
}
Status rv = kSuccess;
while (rv == kSuccess) {
WidevineVideoFrame frame;
InputBuffer sample;
Status rv = CDM()->DecryptAndDecodeFrame(sample, &frame);
- Log("WidevineVideoDecoder::Drain(); DecryptAndDecodeFrame() rv=%d", rv);
+ CDM_LOG("WidevineVideoDecoder::Drain(); DecryptAndDecodeFrame() rv=%d", rv);
if (frame.Format() == kUnknownVideoFormat) {
break;
}
if (rv == kSuccess) {
if (!ReturnOutput(frame)) {
- Log("WidevineVideoDecoder::Decode() Failed in ReturnOutput()");
+ CDM_LOG("WidevineVideoDecoder::Decode() Failed in ReturnOutput()");
}
}
}
// Shouldn't be reset while draining.
MOZ_ASSERT(!mResetInProgress);
CDM()->ResetDecoder(kStreamTypeVideo);
mDrainPending = false;
mCallback->DrainComplete();
}
void
WidevineVideoDecoder::DecodingComplete()
{
- Log("WidevineVideoDecoder::DecodingComplete()");
+ CDM_LOG("WidevineVideoDecoder::DecodingComplete()");
if (mCDMWrapper) {
// mCallback will be null if the decoder has not been fully initialized.
if (mCallback) {
CDM()->DeinitializeDecoder(kStreamTypeVideo);
} else {
- Log("WideVineDecoder::DecodingComplete() Decoder was not fully initialized!");
+ CDM_LOG("WideVineDecoder::DecodingComplete() Decoder was not fully initialized!");
}
mCDMWrapper = nullptr;
}
// Release that corresponds to AddRef() in constructor.
Release();
}
--- a/dom/media/gmp/widevine-adapter/WidevineVideoFrame.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoFrame.cpp
@@ -13,113 +13,113 @@ using namespace cdm;
namespace mozilla {
WidevineVideoFrame::WidevineVideoFrame()
: mFormat(kUnknownVideoFormat)
, mSize(0,0)
, mBuffer(nullptr)
, mTimestamp(0)
{
- Log("WidevineVideoFrame::WidevineVideoFrame() this=%p", this);
+ CDM_LOG("WidevineVideoFrame::WidevineVideoFrame() this=%p", this);
memset(mPlaneOffsets, 0, sizeof(mPlaneOffsets));
memset(mPlaneStrides, 0, sizeof(mPlaneStrides));
}
WidevineVideoFrame::WidevineVideoFrame(WidevineVideoFrame&& aOther)
: mFormat(aOther.mFormat)
, mSize(aOther.mSize)
, mBuffer(aOther.mBuffer)
, mTimestamp(aOther.mTimestamp)
{
- Log("WidevineVideoFrame::WidevineVideoFrame(WidevineVideoFrame&&) this=%p, other=%p",
- this, &aOther);
+ CDM_LOG("WidevineVideoFrame::WidevineVideoFrame(WidevineVideoFrame&&) this=%p, other=%p",
+ this, &aOther);
memcpy(mPlaneOffsets, aOther.mPlaneOffsets, sizeof(mPlaneOffsets));
memcpy(mPlaneStrides, aOther.mPlaneStrides, sizeof(mPlaneStrides));
aOther.mBuffer = nullptr;
}
WidevineVideoFrame::~WidevineVideoFrame()
{
if (mBuffer) {
mBuffer->Destroy();
mBuffer = nullptr;
}
}
void
WidevineVideoFrame::SetFormat(cdm::VideoFormat aFormat)
{
- Log("WidevineVideoFrame::SetFormat(%d) this=%p", aFormat, this);
+ CDM_LOG("WidevineVideoFrame::SetFormat(%d) this=%p", aFormat, this);
mFormat = aFormat;
}
cdm::VideoFormat
WidevineVideoFrame::Format() const
{
return mFormat;
}
void
WidevineVideoFrame::SetSize(cdm::Size aSize)
{
- Log("WidevineVideoFrame::SetSize(%d,%d) this=%p", aSize.width, aSize.height, this);
+ CDM_LOG("WidevineVideoFrame::SetSize(%d,%d) this=%p", aSize.width, aSize.height, this);
mSize.width = aSize.width;
mSize.height = aSize.height;
}
cdm::Size
WidevineVideoFrame::Size() const
{
return mSize;
}
void
WidevineVideoFrame::SetFrameBuffer(cdm::Buffer* aFrameBuffer)
{
- Log("WidevineVideoFrame::SetFrameBuffer(%p) this=%p", aFrameBuffer, this);
+ CDM_LOG("WidevineVideoFrame::SetFrameBuffer(%p) this=%p", aFrameBuffer, this);
MOZ_ASSERT(!mBuffer);
mBuffer = aFrameBuffer;
}
cdm::Buffer*
WidevineVideoFrame::FrameBuffer()
{
return mBuffer;
}
void
WidevineVideoFrame::SetPlaneOffset(cdm::VideoFrame::VideoPlane aPlane, uint32_t aOffset)
{
- Log("WidevineVideoFrame::SetPlaneOffset(%d, %d) this=%p", aPlane, aOffset, this);
+ CDM_LOG("WidevineVideoFrame::SetPlaneOffset(%d, %d) this=%p", aPlane, aOffset, this);
mPlaneOffsets[aPlane] = aOffset;
}
uint32_t
WidevineVideoFrame::PlaneOffset(cdm::VideoFrame::VideoPlane aPlane)
{
return mPlaneOffsets[aPlane];
}
void
WidevineVideoFrame::SetStride(cdm::VideoFrame::VideoPlane aPlane, uint32_t aStride)
{
- Log("WidevineVideoFrame::SetStride(%d, %d) this=%p", aPlane, aStride, this);
+ CDM_LOG("WidevineVideoFrame::SetStride(%d, %d) this=%p", aPlane, aStride, this);
mPlaneStrides[aPlane] = aStride;
}
uint32_t
WidevineVideoFrame::Stride(cdm::VideoFrame::VideoPlane aPlane)
{
return mPlaneStrides[aPlane];
}
void
WidevineVideoFrame::SetTimestamp(int64_t timestamp)
{
- Log("WidevineVideoFrame::SetTimestamp(%" PRId64 ") this=%p", timestamp, this);
+ CDM_LOG("WidevineVideoFrame::SetTimestamp(%" PRId64 ") this=%p", timestamp, this);
mTimestamp = timestamp;
}
int64_t
WidevineVideoFrame::Timestamp() const
{
return mTimestamp;
}