mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1361900: Part 1 - Make CDMProxy.h compatible with mozilla::Result. r=JamesCheng
MozReview-Commit-ID: DiO7IPFYKbE --HG-- extra : rebase_source : defeef269706ba81ee35272818e468e3ae0b2b19
This commit is contained in:
parent
3a19a212cc
commit
49ed37ac3d
@ -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)
|
||||
|
@ -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<DecryptJob>& decrypt : mDecrypts) {
|
||||
decrypt->PostResult(AbortedErr);
|
||||
decrypt->PostResult(eme::AbortedErr);
|
||||
}
|
||||
mDecrypts.Clear();
|
||||
|
||||
|
@ -557,7 +557,7 @@ ChromiumCDMProxy::Decrypt(MediaRawData* aSample)
|
||||
{
|
||||
RefPtr<gmp::ChromiumCDMParent> cdm = GetCDMParent();
|
||||
if (!cdm) {
|
||||
return DecryptPromise::CreateAndReject(DecryptResult(AbortedErr, aSample),
|
||||
return DecryptPromise::CreateAndReject(DecryptResult(eme::AbortedErr, aSample),
|
||||
__func__);
|
||||
}
|
||||
RefPtr<MediaRawData> sample = aSample;
|
||||
|
@ -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<MediaRawDataWriter> writer(mSample->CreateWriter());
|
||||
PodCopy(writer->Data(),
|
||||
aDecryptedData.Elements(),
|
||||
std::min<size_t>(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.
|
||||
|
@ -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<DecryptJob> aJob)
|
||||
MOZ_ASSERT(IsOnOwnerThread());
|
||||
|
||||
if (!mCDM) {
|
||||
aJob->PostResult(AbortedErr);
|
||||
aJob->PostResult(eme::AbortedErr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user