зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
8499c27da0
Коммит
5b67cbcee7
|
@ -34,8 +34,6 @@ struct DecryptResult {
|
|||
RefPtr<MediaRawData> mSample;
|
||||
};
|
||||
|
||||
typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
|
||||
|
||||
class CDMKeyInfo {
|
||||
public:
|
||||
explicit CDMKeyInfo(const nsTArray<uint8_t>& aKeyId)
|
||||
|
@ -77,6 +75,8 @@ public:
|
|||
|
||||
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
||||
|
||||
typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
|
||||
|
||||
// Main thread only.
|
||||
CDMProxy(dom::MediaKeys* aKeys,
|
||||
const nsAString& aKeySystem,
|
||||
|
|
|
@ -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 <atomic>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
std::atomic<uint32_t> sDecryptJobInstanceCount = 0;
|
||||
|
||||
DecryptJob::DecryptJob(MediaRawData* aSample)
|
||||
: mId(++sDecryptJobInstanceCount )
|
||||
, mSample(aSample)
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<DecryptPromise>
|
||||
DecryptJob::Ensure()
|
||||
{
|
||||
return mPromise.Ensure(__func__);
|
||||
}
|
||||
|
||||
void
|
||||
DecryptJob::PostResult(DecryptStatus aResult)
|
||||
{
|
||||
nsTArray<uint8_t> empty;
|
||||
PostResult(aResult, empty);
|
||||
}
|
||||
|
||||
void
|
||||
DecryptJob::PostResult(DecryptStatus aResult,
|
||||
const nsTArray<uint8_t>& aDecryptedData)
|
||||
{
|
||||
if (aDecryptedData.Length() != mSample->Size()) {
|
||||
NS_WARNING("CDM returned incorrect number of decrypted bytes");
|
||||
}
|
||||
if (aResult == Ok) {
|
||||
UniquePtr<MediaRawDataWriter> writer(mSample->CreateWriter());
|
||||
PodCopy(writer->Data(),
|
||||
aDecryptedData.Elements(),
|
||||
std::min<size_t>(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
|
|
@ -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<uint8_t>& aDecryptedData);
|
||||
void PostResult(DecryptStatus aResult);
|
||||
|
||||
RefPtr<DecryptPromise> Ensure();
|
||||
|
||||
const uint32_t mId;
|
||||
RefPtr<MediaRawData> mSample;
|
||||
private:
|
||||
~DecryptJob() {}
|
||||
MozPromiseHolder<DecryptPromise> mPromise;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DecryptJob_h_
|
|
@ -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<DecryptPromise>
|
||||
RefPtr<GMPCDMProxy::DecryptPromise>
|
||||
GMPCDMProxy::Decrypt(MediaRawData* aSample)
|
||||
{
|
||||
RefPtr<DecryptJob> job(new DecryptJob(aSample));
|
||||
|
@ -709,6 +709,7 @@ GMPCDMProxy::gmp_Decrypt(RefPtr<DecryptJob> aJob)
|
|||
return;
|
||||
}
|
||||
|
||||
aJob->mId = ++mDecryptionJobCount;
|
||||
nsTArray<uint8_t> 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<uint8_t> empty;
|
||||
PostResult(aResult, empty);
|
||||
}
|
||||
|
||||
void
|
||||
GMPCDMProxy::DecryptJob::PostResult(DecryptStatus aResult,
|
||||
const nsTArray<uint8_t>& aDecryptedData)
|
||||
{
|
||||
if (aDecryptedData.Length() != mSample->Size()) {
|
||||
NS_WARNING("CDM returned incorrect number of decrypted bytes");
|
||||
}
|
||||
if (aResult == Ok) {
|
||||
UniquePtr<MediaRawDataWriter> writer(mSample->CreateWriter());
|
||||
PodCopy(writer->Data(),
|
||||
aDecryptedData.Elements(),
|
||||
std::min<size_t>(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<uint8_t>& aKeyId,
|
||||
nsTArray<nsCString>& aSessionIds)
|
||||
|
|
|
@ -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<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
|
||||
|
||||
GMPCDMProxy(dom::MediaKeys* aKeys,
|
||||
const nsAString& aKeySystem,
|
||||
GMPCrashHelper* aCrashHelper,
|
||||
|
@ -175,6 +175,30 @@ private:
|
|||
// GMP thread only.
|
||||
void gmp_RemoveSession(UniquePtr<SessionOpData>&& aData);
|
||||
|
||||
class DecryptJob {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DecryptJob)
|
||||
|
||||
explicit DecryptJob(MediaRawData* aSample)
|
||||
: mId(0)
|
||||
, mSample(aSample)
|
||||
{
|
||||
}
|
||||
|
||||
void PostResult(DecryptStatus aResult,
|
||||
const nsTArray<uint8_t>& aDecryptedData);
|
||||
void PostResult(DecryptStatus aResult);
|
||||
|
||||
RefPtr<DecryptPromise> Ensure() {
|
||||
return mPromise.Ensure(__func__);
|
||||
}
|
||||
|
||||
uint32_t mId;
|
||||
RefPtr<MediaRawData> mSample;
|
||||
private:
|
||||
~DecryptJob() {}
|
||||
MozPromiseHolder<DecryptPromise> mPromise;
|
||||
};
|
||||
// GMP thread only.
|
||||
void gmp_Decrypt(RefPtr<DecryptJob> aJob);
|
||||
|
||||
|
@ -218,6 +242,13 @@ private:
|
|||
// GMP thread only.
|
||||
nsTArray<RefPtr<DecryptJob>> 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;
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
typedef MozPromiseRequestHolder<DecryptPromise> DecryptPromiseRequestHolder;
|
||||
typedef MozPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder;
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
||||
|
||||
class EMEDecryptor : public MediaDataDecoder
|
||||
|
|
Загрузка…
Ссылка в новой задаче