From 5b67cbcee70c1b81d06772e69b32df11ab4b974a Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 15 Feb 2017 11:57:38 -0800 Subject: [PATCH] Backed out 2 changesets (bug 1339755) for build bustage a=backout Backed out changeset f3629503d405 (bug 1339755) Backed out changeset 85641936e471 (bug 1339755) MozReview-Commit-ID: LiZfM9OcO5s --- dom/media/eme/CDMProxy.h | 4 +- dom/media/gmp/DecryptJob.cpp | 56 ------------------- dom/media/gmp/DecryptJob.h | 35 ------------ dom/media/gmp/GMPCDMProxy.cpp | 36 +++++++++++- dom/media/gmp/GMPCDMProxy.h | 35 +++++++++++- dom/media/gmp/moz.build | 2 - .../agnostic/eme/EMEDecoderModule.cpp | 2 +- 7 files changed, 70 insertions(+), 100 deletions(-) delete mode 100644 dom/media/gmp/DecryptJob.cpp delete mode 100644 dom/media/gmp/DecryptJob.h diff --git a/dom/media/eme/CDMProxy.h b/dom/media/eme/CDMProxy.h index c884cf7b5eb3..2263d943e0e0 100644 --- a/dom/media/eme/CDMProxy.h +++ b/dom/media/eme/CDMProxy.h @@ -34,8 +34,6 @@ struct DecryptResult { RefPtr mSample; }; -typedef MozPromise DecryptPromise; - class CDMKeyInfo { public: explicit CDMKeyInfo(const nsTArray& aKeyId) @@ -77,6 +75,8 @@ public: NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING + typedef MozPromise DecryptPromise; + // Main thread only. CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem, diff --git a/dom/media/gmp/DecryptJob.cpp b/dom/media/gmp/DecryptJob.cpp deleted file mode 100644 index 218f9265323d..000000000000 --- a/dom/media/gmp/DecryptJob.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "DecryptJob.h" -#include - -namespace mozilla { - -std::atomic sDecryptJobInstanceCount = 0; - -DecryptJob::DecryptJob(MediaRawData* aSample) - : mId(++sDecryptJobInstanceCount ) - , mSample(aSample) -{ -} - -RefPtr -DecryptJob::Ensure() -{ - return mPromise.Ensure(__func__); -} - -void -DecryptJob::PostResult(DecryptStatus aResult) -{ - nsTArray empty; - PostResult(aResult, empty); -} - -void -DecryptJob::PostResult(DecryptStatus aResult, - const nsTArray& aDecryptedData) -{ - if (aDecryptedData.Length() != mSample->Size()) { - NS_WARNING("CDM returned incorrect number of decrypted bytes"); - } - if (aResult == Ok) { - UniquePtr writer(mSample->CreateWriter()); - PodCopy(writer->Data(), - aDecryptedData.Elements(), - std::min(aDecryptedData.Length(), mSample->Size())); - } else if (aResult == 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. - } else { - nsAutoCString str("CDM returned decode failure DecryptStatus="); - str.AppendInt(aResult); - NS_WARNING(str.get()); - } - mPromise.Resolve(DecryptResult(aResult, mSample), __func__); -} - -} // namespace mozilla diff --git a/dom/media/gmp/DecryptJob.h b/dom/media/gmp/DecryptJob.h deleted file mode 100644 index 2ddf9d8bdf41..000000000000 --- a/dom/media/gmp/DecryptJob.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef DecryptJob_h_ -#define DecryptJob_h_ - -#include "mozilla/CDMProxy.h" - -namespace mozilla { - -class DecryptJob { -public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DecryptJob) - - explicit DecryptJob(MediaRawData* aSample); - - void PostResult(DecryptStatus aResult, - const nsTArray& aDecryptedData); - void PostResult(DecryptStatus aResult); - - RefPtr Ensure(); - - const uint32_t mId; - RefPtr mSample; -private: - ~DecryptJob() {} - MozPromiseHolder mPromise; -}; - -} // namespace mozilla - -#endif // DecryptJob_h_ diff --git a/dom/media/gmp/GMPCDMProxy.cpp b/dom/media/gmp/GMPCDMProxy.cpp index ae81fc1bdb41..cfe1796c2075 100644 --- a/dom/media/gmp/GMPCDMProxy.cpp +++ b/dom/media/gmp/GMPCDMProxy.cpp @@ -22,7 +22,6 @@ #include "GMPService.h" #include "MainThreadUtils.h" #include "MediaData.h" -#include "DecryptJob.h" namespace mozilla { @@ -37,6 +36,7 @@ GMPCDMProxy::GMPCDMProxy(dom::MediaKeys* aKeys, aPersistentStateRequired) , mCrashHelper(aCrashHelper) , mCDM(nullptr) + , mDecryptionJobCount(0) , mShutdownCalled(false) , mDecryptorId(0) , mCreatePromiseId(0) @@ -687,7 +687,7 @@ GMPCDMProxy::Capabilites() { return mCapabilites; } -RefPtr +RefPtr GMPCDMProxy::Decrypt(MediaRawData* aSample) { RefPtr job(new DecryptJob(aSample)); @@ -709,6 +709,7 @@ GMPCDMProxy::gmp_Decrypt(RefPtr aJob) return; } + aJob->mId = ++mDecryptionJobCount; nsTArray data; data.AppendElements(aJob->mSample->Data(), aJob->mSample->Size()); mCDM->Decrypt(aJob->mId, aJob->mSample->mCrypto, data, aJob->mSample->mDuration); @@ -741,6 +742,37 @@ GMPCDMProxy::gmp_Decrypted(uint32_t aId, #endif } +void +GMPCDMProxy::DecryptJob::PostResult(DecryptStatus aResult) +{ + nsTArray empty; + PostResult(aResult, empty); +} + +void +GMPCDMProxy::DecryptJob::PostResult(DecryptStatus aResult, + const nsTArray& aDecryptedData) +{ + if (aDecryptedData.Length() != mSample->Size()) { + NS_WARNING("CDM returned incorrect number of decrypted bytes"); + } + if (aResult == Ok) { + UniquePtr writer(mSample->CreateWriter()); + PodCopy(writer->Data(), + aDecryptedData.Elements(), + std::min(aDecryptedData.Length(), mSample->Size())); + } else if (aResult == NoKeyErr) { + EME_LOG("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. + } else { + nsAutoCString str("CDM returned decode failure DecryptStatus="); + str.AppendInt(aResult); + NS_WARNING(str.get()); + } + mPromise.Resolve(DecryptResult(aResult, mSample), __func__); +} + void GMPCDMProxy::GetSessionIdsForKeyId(const nsTArray& aKeyId, nsTArray& aSessionIds) diff --git a/dom/media/gmp/GMPCDMProxy.h b/dom/media/gmp/GMPCDMProxy.h index 38a685c1b782..d91de4acd895 100644 --- a/dom/media/gmp/GMPCDMProxy.h +++ b/dom/media/gmp/GMPCDMProxy.h @@ -12,9 +12,7 @@ #include "GMPDecryptorProxy.h" namespace mozilla { - class MediaRawData; -class DecryptJob; // Implementation of CDMProxy which is based on GMP architecture. class GMPCDMProxy : public CDMProxy { @@ -22,6 +20,8 @@ public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPCDMProxy, override) + typedef MozPromise DecryptPromise; + GMPCDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem, GMPCrashHelper* aCrashHelper, @@ -175,6 +175,30 @@ private: // GMP thread only. void gmp_RemoveSession(UniquePtr&& aData); + class DecryptJob { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DecryptJob) + + explicit DecryptJob(MediaRawData* aSample) + : mId(0) + , mSample(aSample) + { + } + + void PostResult(DecryptStatus aResult, + const nsTArray& aDecryptedData); + void PostResult(DecryptStatus aResult); + + RefPtr Ensure() { + return mPromise.Ensure(__func__); + } + + uint32_t mId; + RefPtr mSample; + private: + ~DecryptJob() {} + MozPromiseHolder mPromise; + }; // GMP thread only. void gmp_Decrypt(RefPtr aJob); @@ -218,6 +242,13 @@ private: // GMP thread only. nsTArray> mDecryptionJobs; + // Number of buffers we've decrypted. Used to uniquely identify + // decryption jobs sent to CDM. Note we can't just use the length of + // mDecryptionJobs as that shrinks as jobs are completed and removed + // from it. + // GMP thread only. + uint32_t mDecryptionJobCount; + // True if GMPCDMProxy::gmp_Shutdown was called. // GMP thread only. bool mShutdownCalled; diff --git a/dom/media/gmp/moz.build b/dom/media/gmp/moz.build index 5a332ee4dbb6..d10a0adb9d25 100644 --- a/dom/media/gmp/moz.build +++ b/dom/media/gmp/moz.build @@ -12,7 +12,6 @@ XPIDL_SOURCES += [ ] EXPORTS += [ - 'DecryptJob.h', 'gmp-api/gmp-decryption.h', 'gmp-api/gmp-entrypoints.h', 'gmp-api/gmp-errors.h', @@ -68,7 +67,6 @@ EXPORTS += [ ] UNIFIED_SOURCES += [ - 'DecryptJob.cpp', 'GMPCDMCallbackProxy.cpp', 'GMPCDMProxy.cpp', 'GMPChild.cpp', diff --git a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp index 2eed9ba373fe..36f0cf352eaa 100644 --- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp @@ -21,7 +21,7 @@ namespace mozilla { -typedef MozPromiseRequestHolder DecryptPromiseRequestHolder; +typedef MozPromiseRequestHolder DecryptPromiseRequestHolder; extern already_AddRefed CreateBlankDecoderModule(); class EMEDecryptor : public MediaDataDecoder