зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1152652: Part1. Use mStandardMozillaStyle for crypto classes. r=edwin
This commit is contained in:
Родитель
8a19b6772a
Коммит
aa270b640c
|
@ -303,20 +303,20 @@ protected:
|
|||
class CryptoTrack
|
||||
{
|
||||
public:
|
||||
CryptoTrack() : valid(false) {}
|
||||
bool valid;
|
||||
int32_t mode;
|
||||
int32_t iv_size;
|
||||
nsTArray<uint8_t> key;
|
||||
CryptoTrack() : mValid(false) {}
|
||||
bool mValid;
|
||||
int32_t mMode;
|
||||
int32_t mIVSize;
|
||||
nsTArray<uint8_t> mKeyId;
|
||||
};
|
||||
|
||||
class CryptoSample : public CryptoTrack
|
||||
{
|
||||
public:
|
||||
nsTArray<uint16_t> plain_sizes;
|
||||
nsTArray<uint32_t> encrypted_sizes;
|
||||
nsTArray<uint8_t> iv;
|
||||
nsTArray<nsCString> session_ids;
|
||||
nsTArray<uint16_t> mPlainSizes;
|
||||
nsTArray<uint32_t> mEncryptedSizes;
|
||||
nsTArray<uint8_t> mIV;
|
||||
nsTArray<nsCString> mSessionIds;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -91,8 +91,8 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.key,
|
||||
aSample->mCrypto.session_ids);
|
||||
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.mKeyId,
|
||||
aSample->mCrypto.mSessionIds);
|
||||
|
||||
mProxy->Decrypt(aSample, new DeliverDecrypted(this, mTaskQueue));
|
||||
return NS_OK;
|
||||
|
@ -186,8 +186,8 @@ EMEMediaDataDecoderProxy::Input(MediaRawData* aSample)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.key,
|
||||
aSample->mCrypto.session_ids);
|
||||
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.mKeyId,
|
||||
aSample->mCrypto.mSessionIds);
|
||||
|
||||
return MediaDataDecoderProxy::Input(aSample);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ EMEDecoderModule::CreateVideoDecoder(const VideoDecoderConfig& aConfig,
|
|||
FlushableMediaTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
if (mCDMDecodesVideo && aConfig.crypto.valid) {
|
||||
if (mCDMDecodesVideo && aConfig.crypto.mValid) {
|
||||
nsRefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback, mProxy, aVideoTaskQueue);
|
||||
wrapper->SetProxyTarget(new EMEVideoDecoder(mProxy,
|
||||
aConfig,
|
||||
|
@ -265,7 +265,7 @@ EMEDecoderModule::CreateVideoDecoder(const VideoDecoderConfig& aConfig,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!aConfig.crypto.valid) {
|
||||
if (!aConfig.crypto.mValid) {
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ EMEDecoderModule::CreateAudioDecoder(const AudioDecoderConfig& aConfig,
|
|||
FlushableMediaTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
if (mCDMDecodesAudio && aConfig.crypto.valid) {
|
||||
if (mCDMDecodesAudio && aConfig.crypto.mValid) {
|
||||
nsRefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback, mProxy, aAudioTaskQueue);
|
||||
wrapper->SetProxyTarget(new EMEAudioDecoder(mProxy,
|
||||
aConfig,
|
||||
|
@ -295,7 +295,7 @@ EMEDecoderModule::CreateAudioDecoder(const AudioDecoderConfig& aConfig,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!aConfig.crypto.valid) {
|
||||
if (!aConfig.crypto.mValid) {
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ GMPUnique<GMPVideoEncodedFrame>::Ptr
|
|||
EMEVideoDecoder::CreateFrame(MediaRawData* aSample)
|
||||
{
|
||||
GMPUnique<GMPVideoEncodedFrame>::Ptr frame = GMPVideoDecoder::CreateFrame(aSample);
|
||||
if (frame && aSample->mCrypto.valid) {
|
||||
if (frame && aSample->mCrypto.mValid) {
|
||||
static_cast<gmp::GMPVideoEncodedFrameImpl*>(frame.get())->InitCrypto(aSample->mCrypto);
|
||||
}
|
||||
return frame;
|
||||
|
|
|
@ -28,17 +28,17 @@ SamplesWaitingForKey::~SamplesWaitingForKey()
|
|||
bool
|
||||
SamplesWaitingForKey::WaitIfKeyNotUsable(MediaRawData* aSample)
|
||||
{
|
||||
if (!aSample || !aSample->mCrypto.valid || !mProxy) {
|
||||
if (!aSample || !aSample->mCrypto.mValid || !mProxy) {
|
||||
return false;
|
||||
}
|
||||
CDMCaps::AutoLock caps(mProxy->Capabilites());
|
||||
const auto& keyid = aSample->mCrypto.key;
|
||||
const auto& keyid = aSample->mCrypto.mKeyId;
|
||||
if (!caps.IsKeyUsable(keyid)) {
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mSamples.AppendElement(aSample);
|
||||
}
|
||||
caps.NotifyWhenKeyIdUsable(aSample->mCrypto.key, this);
|
||||
caps.NotifyWhenKeyIdUsable(aSample->mCrypto.mKeyId, this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -50,7 +50,7 @@ SamplesWaitingForKey::NotifyUsable(const CencKeyId& aKeyId)
|
|||
MutexAutoLock lock(mMutex);
|
||||
size_t i = 0;
|
||||
while (i < mSamples.Length()) {
|
||||
if (aKeyId == mSamples[i]->mCrypto.key) {
|
||||
if (aKeyId == mSamples[i]->mCrypto.mKeyId) {
|
||||
RefPtr<nsIRunnable> task;
|
||||
task = NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(mDecoder,
|
||||
&MediaDataDecoder::Input,
|
||||
|
|
|
@ -41,7 +41,7 @@ GMPAudioSamplesImpl::GMPAudioSamplesImpl(MediaRawData* aSample,
|
|||
, mRate(aRate)
|
||||
{
|
||||
mBuffer.AppendElements(aSample->mData, aSample->mSize);
|
||||
if (aSample->mCrypto.valid) {
|
||||
if (aSample->mCrypto.mValid) {
|
||||
mCrypto = new GMPEncryptedBufferDataImpl(aSample->mCrypto);
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ GMPAudioSamplesImpl::GetDecryptionData() const
|
|||
void
|
||||
GMPAudioSamplesImpl::InitCrypto(const CryptoSample& aCrypto)
|
||||
{
|
||||
if (!aCrypto.valid) {
|
||||
if (!aCrypto.mValid) {
|
||||
return;
|
||||
}
|
||||
mCrypto = new GMPEncryptedBufferDataImpl(aCrypto);
|
||||
|
|
|
@ -142,13 +142,13 @@ GMPDecryptorParent::Decrypt(uint32_t aId,
|
|||
}
|
||||
|
||||
// Caller should ensure parameters passed in are valid.
|
||||
MOZ_ASSERT(!aBuffer.IsEmpty() && aCrypto.valid);
|
||||
MOZ_ASSERT(!aBuffer.IsEmpty() && aCrypto.mValid);
|
||||
|
||||
GMPDecryptionData data(aCrypto.key,
|
||||
aCrypto.iv,
|
||||
aCrypto.plain_sizes,
|
||||
aCrypto.encrypted_sizes,
|
||||
aCrypto.session_ids);
|
||||
GMPDecryptionData data(aCrypto.mKeyId,
|
||||
aCrypto.mIV,
|
||||
aCrypto.mPlainSizes,
|
||||
aCrypto.mEncryptedSizes,
|
||||
aCrypto.mSessionIds);
|
||||
|
||||
unused << SendDecrypt(aId, aBuffer, data);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ namespace mozilla {
|
|||
namespace gmp {
|
||||
|
||||
GMPEncryptedBufferDataImpl::GMPEncryptedBufferDataImpl(const CryptoSample& aCrypto)
|
||||
: mKeyId(aCrypto.key)
|
||||
, mIV(aCrypto.iv)
|
||||
, mClearBytes(aCrypto.plain_sizes)
|
||||
, mCipherBytes(aCrypto.encrypted_sizes)
|
||||
, mSessionIdList(aCrypto.session_ids)
|
||||
: mKeyId(aCrypto.mKeyId)
|
||||
, mIV(aCrypto.mIV)
|
||||
, mClearBytes(aCrypto.mPlainSizes)
|
||||
, mCipherBytes(aCrypto.mEncryptedSizes)
|
||||
, mSessionIdList(aCrypto.mSessionIds)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -67,19 +67,19 @@ static nsCString
|
|||
ToCryptoString(CryptoSample& aCrypto)
|
||||
{
|
||||
nsCString res;
|
||||
if (aCrypto.valid) {
|
||||
res.AppendPrintf("%d %d ", aCrypto.mode, aCrypto.iv_size);
|
||||
for (size_t i = 0; i < aCrypto.key.Length(); i++) {
|
||||
res.AppendPrintf("%02x", aCrypto.key[i]);
|
||||
if (aCrypto.mValid) {
|
||||
res.AppendPrintf("%d %d ", aCrypto.mMode, aCrypto.mIVSize);
|
||||
for (size_t i = 0; i < aCrypto.mKeyId.Length(); i++) {
|
||||
res.AppendPrintf("%02x", aCrypto.mKeyId[i]);
|
||||
}
|
||||
res.Append(" ");
|
||||
for (size_t i = 0; i < aCrypto.iv.Length(); i++) {
|
||||
res.AppendPrintf("%02x", aCrypto.iv[i]);
|
||||
for (size_t i = 0; i < aCrypto.mIV.Length(); i++) {
|
||||
res.AppendPrintf("%02x", aCrypto.mIV[i]);
|
||||
}
|
||||
EXPECT_EQ(aCrypto.plain_sizes.Length(), aCrypto.encrypted_sizes.Length());
|
||||
for (size_t i = 0; i < aCrypto.plain_sizes.Length(); i++) {
|
||||
res.AppendPrintf(" %d,%d", aCrypto.plain_sizes[i],
|
||||
aCrypto.encrypted_sizes[i]);
|
||||
EXPECT_EQ(aCrypto.mPlainSizes.Length(), aCrypto.mEncryptedSizes.Length());
|
||||
for (size_t i = 0; i < aCrypto.mPlainSizes.Length(); i++) {
|
||||
res.AppendPrintf(" %d,%d", aCrypto.mPlainSizes[i],
|
||||
aCrypto.mEncryptedSizes[i]);
|
||||
}
|
||||
} else {
|
||||
res.Append("no crypto");
|
||||
|
|
|
@ -61,12 +61,12 @@ Adts::ConvertSample(uint16_t aChannelCount, int8_t aFrequencyIndex,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (aSample->mCrypto.valid) {
|
||||
if (aSample->mCrypto.plain_sizes.Length() == 0) {
|
||||
aSample->mCrypto.plain_sizes.AppendElement(kADTSHeaderSize);
|
||||
aSample->mCrypto.encrypted_sizes.AppendElement(aSample->mSize - kADTSHeaderSize);
|
||||
if (aSample->mCrypto.mValid) {
|
||||
if (aSample->mCrypto.mPlainSizes.Length() == 0) {
|
||||
aSample->mCrypto.mPlainSizes.AppendElement(kADTSHeaderSize);
|
||||
aSample->mCrypto.mEncryptedSizes.AppendElement(aSample->mSize - kADTSHeaderSize);
|
||||
} else {
|
||||
aSample->mCrypto.plain_sizes[0] += kADTSHeaderSize;
|
||||
aSample->mCrypto.mPlainSizes[0] += kADTSHeaderSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,9 +110,9 @@ TrackConfig::Update(const MetaData* aMetaData, const char* aMimeType)
|
|||
duration = FindInt64(aMetaData, kKeyDuration);
|
||||
media_time = FindInt64(aMetaData, kKeyMediaTime);
|
||||
mTrackId = FindInt32(aMetaData, kKeyTrackID);
|
||||
crypto.valid = aMetaData->findInt32(kKeyCryptoMode, &crypto.mode) &&
|
||||
aMetaData->findInt32(kKeyCryptoDefaultIVSize, &crypto.iv_size) &&
|
||||
FindData(aMetaData, kKeyCryptoKey, &crypto.key);
|
||||
crypto.mValid = aMetaData->findInt32(kKeyCryptoMode, &crypto.mMode) &&
|
||||
aMetaData->findInt32(kKeyCryptoDefaultIVSize, &crypto.mIVSize) &&
|
||||
FindData(aMetaData, kKeyCryptoKey, &crypto.mKeyId);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -127,10 +127,10 @@ already_AddRefed<MediaRawData> SampleIterator::GetNext()
|
|||
return nullptr;
|
||||
}
|
||||
ByteReader reader(cenc);
|
||||
sample->mCrypto.valid = true;
|
||||
sample->mCrypto.iv_size = ivSize;
|
||||
sample->mCrypto.mValid = true;
|
||||
sample->mCrypto.mIVSize = ivSize;
|
||||
|
||||
if (!reader.ReadArray(sample->mCrypto.iv, ivSize)) {
|
||||
if (!reader.ReadArray(sample->mCrypto.mIV, ivSize)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ already_AddRefed<MediaRawData> SampleIterator::GetNext()
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
sample->mCrypto.plain_sizes.AppendElement(reader.ReadU16());
|
||||
sample->mCrypto.encrypted_sizes.AppendElement(reader.ReadU32());
|
||||
sample->mCrypto.mPlainSizes.AppendElement(reader.ReadU16());
|
||||
sample->mCrypto.mEncryptedSizes.AppendElement(reader.ReadU32());
|
||||
}
|
||||
} else {
|
||||
// No subsample information means the entire sample is encrypted.
|
||||
sample->mCrypto.plain_sizes.AppendElement(0);
|
||||
sample->mCrypto.encrypted_sizes.AppendElement(sample->mSize);
|
||||
sample->mCrypto.mPlainSizes.AppendElement(0);
|
||||
sample->mCrypto.mEncryptedSizes.AppendElement(sample->mSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -221,10 +221,10 @@ MP4Demuxer::DemuxAudioSample()
|
|||
}
|
||||
nsRefPtr<mozilla::MediaRawData> sample(mPrivate->mAudioIterator->GetNext());
|
||||
if (sample) {
|
||||
if (sample->mCrypto.valid) {
|
||||
sample->mCrypto.mode = mAudioConfig.crypto.mode;
|
||||
sample->mCrypto.iv_size = mAudioConfig.crypto.iv_size;
|
||||
sample->mCrypto.key.AppendElements(mAudioConfig.crypto.key);
|
||||
if (sample->mCrypto.mValid) {
|
||||
sample->mCrypto.mMode = mAudioConfig.crypto.mMode;
|
||||
sample->mCrypto.mIVSize = mAudioConfig.crypto.mIVSize;
|
||||
sample->mCrypto.mKeyId.AppendElements(mAudioConfig.crypto.mKeyId);
|
||||
}
|
||||
}
|
||||
return sample.forget();
|
||||
|
@ -240,9 +240,9 @@ MP4Demuxer::DemuxVideoSample()
|
|||
nsRefPtr<mozilla::MediaRawData> sample(mPrivate->mVideoIterator->GetNext());
|
||||
if (sample) {
|
||||
sample->mExtraData = mVideoConfig.extra_data;
|
||||
if (sample->mCrypto.valid) {
|
||||
sample->mCrypto.mode = mVideoConfig.crypto.mode;
|
||||
sample->mCrypto.key.AppendElements(mVideoConfig.crypto.key);
|
||||
if (sample->mCrypto.mValid) {
|
||||
sample->mCrypto.mMode = mVideoConfig.crypto.mMode;
|
||||
sample->mCrypto.mKeyId.AppendElements(mVideoConfig.crypto.mKeyId);
|
||||
}
|
||||
if (sample->mTime >= mNextKeyframeTime) {
|
||||
mNextKeyframeTime = mPrivate->mVideoIterator->GetNextKeyframeTime();
|
||||
|
|
Загрузка…
Ссылка в новой задаче