From b588cdc5bb1bff7eccb6756bc485bd80325e0fc2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 12 May 2017 12:08:43 -0700 Subject: [PATCH] Bug 1361900: Part 1 - Make CDMProxy.h compatible with mozilla::Result. r=JamesCheng MozReview-Commit-ID: DiO7IPFYKbE --HG-- extra : rebase_source : 500e32854c50e2381fd9de3a3533611be1426329 extra : source : 9e3064aec4bb16542f9cc93a89f7a257b6716a98 --- dom/media/eme/CDMProxy.h | 4 ++++ dom/media/gmp/ChromiumCDMParent.cpp | 4 +++- dom/media/gmp/ChromiumCDMProxy.cpp | 2 +- dom/media/gmp/DecryptJob.cpp | 4 ++-- dom/media/gmp/GMPCDMProxy.cpp | 4 ++-- dom/media/gmp/GMPDecryptorParent.cpp | 8 ++++---- dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dom/media/eme/CDMProxy.h b/dom/media/eme/CDMProxy.h index 4a7c97d9335a..e2f082516370 100644 --- a/dom/media/eme/CDMProxy.h +++ b/dom/media/eme/CDMProxy.h @@ -19,12 +19,16 @@ namespace mozilla { class MediaRawData; class ChromiumCDMProxy; +namespace eme { enum DecryptStatus { Ok = 0, GenericErr = 1, NoKeyErr = 2, AbortedErr = 3, }; +} + +using eme::DecryptStatus; struct DecryptResult { DecryptResult(DecryptStatus aStatus, MediaRawData* aSample) diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index 2ef5bf041037..13559ab980fe 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -18,6 +18,8 @@ namespace mozilla { namespace gmp { +using namespace eme; + ChromiumCDMParent::ChromiumCDMParent(GMPContentParent* aContentParent, uint32_t aPluginId) : mPluginId(aPluginId) @@ -1084,7 +1086,7 @@ ChromiumCDMParent::Shutdown() mProxy = nullptr; for (RefPtr& decrypt : mDecrypts) { - decrypt->PostResult(AbortedErr); + decrypt->PostResult(eme::AbortedErr); } mDecrypts.Clear(); diff --git a/dom/media/gmp/ChromiumCDMProxy.cpp b/dom/media/gmp/ChromiumCDMProxy.cpp index a8495c8fc3c3..8b78e82b5b6c 100644 --- a/dom/media/gmp/ChromiumCDMProxy.cpp +++ b/dom/media/gmp/ChromiumCDMProxy.cpp @@ -557,7 +557,7 @@ ChromiumCDMProxy::Decrypt(MediaRawData* aSample) { RefPtr cdm = GetCDMParent(); if (!cdm) { - return DecryptPromise::CreateAndReject(DecryptResult(AbortedErr, aSample), + return DecryptPromise::CreateAndReject(DecryptResult(eme::AbortedErr, aSample), __func__); } RefPtr sample = aSample; diff --git a/dom/media/gmp/DecryptJob.cpp b/dom/media/gmp/DecryptJob.cpp index 8f90ee6d05ca..196b38976484 100644 --- a/dom/media/gmp/DecryptJob.cpp +++ b/dom/media/gmp/DecryptJob.cpp @@ -36,12 +36,12 @@ DecryptJob::PostResult(DecryptStatus aResult, if (aDecryptedData.Length() != mSample->Size()) { NS_WARNING("CDM returned incorrect number of decrypted bytes"); } - if (aResult == Ok) { + if (aResult == eme::Ok) { UniquePtr writer(mSample->CreateWriter()); PodCopy(writer->Data(), aDecryptedData.Elements(), std::min(aDecryptedData.Length(), mSample->Size())); - } else if (aResult == NoKeyErr) { + } else if (aResult == eme::NoKeyErr) { NS_WARNING("CDM returned NoKeyErr"); // We still have the encrypted sample, so we can re-enqueue it to be // decrypted again once the key is usable again. diff --git a/dom/media/gmp/GMPCDMProxy.cpp b/dom/media/gmp/GMPCDMProxy.cpp index 2ffd4ac051a3..1f5d19404491 100644 --- a/dom/media/gmp/GMPCDMProxy.cpp +++ b/dom/media/gmp/GMPCDMProxy.cpp @@ -500,7 +500,7 @@ GMPCDMProxy::gmp_Shutdown() // Abort any pending decrypt jobs, to awaken any clients waiting on a job. for (size_t i = 0; i < mDecryptionJobs.Length(); i++) { DecryptJob* job = mDecryptionJobs[i]; - job->PostResult(AbortedErr); + job->PostResult(eme::AbortedErr); } mDecryptionJobs.Clear(); @@ -696,7 +696,7 @@ GMPCDMProxy::gmp_Decrypt(RefPtr aJob) MOZ_ASSERT(IsOnOwnerThread()); if (!mCDM) { - aJob->PostResult(AbortedErr); + aJob->PostResult(eme::AbortedErr); return; } diff --git a/dom/media/gmp/GMPDecryptorParent.cpp b/dom/media/gmp/GMPDecryptorParent.cpp index 5acf96ae3557..fe826d67febd 100644 --- a/dom/media/gmp/GMPDecryptorParent.cpp +++ b/dom/media/gmp/GMPDecryptorParent.cpp @@ -400,10 +400,10 @@ DecryptStatus ToDecryptStatus(GMPErr aError) { switch (aError) { - case GMPNoErr: return Ok; - case GMPNoKeyErr: return NoKeyErr; - case GMPAbortedErr: return AbortedErr; - default: return GenericErr; + case GMPNoErr: return eme::Ok; + case GMPNoKeyErr: return eme::NoKeyErr; + case GMPAbortedErr: return eme::AbortedErr; + default: return eme::GenericErr; } } diff --git a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp index c7af45f9704f..1f0412513de0 100644 --- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp @@ -127,12 +127,12 @@ public: return; } - if (aDecrypted.mStatus == NoKeyErr) { + if (aDecrypted.mStatus == eme::NoKeyErr) { // Key became unusable after we sent the sample to CDM to decrypt. // Call Decode() again, so that the sample is enqueued for decryption // if the key becomes usable again. AttemptDecode(aDecrypted.mSample); - } else if (aDecrypted.mStatus != Ok) { + } else if (aDecrypted.mStatus != eme::Ok) { mDecodePromise.RejectIfExists( MediaResult( NS_ERROR_DOM_MEDIA_FATAL_ERR,