Bug 1496501 - Do not mark CDM input as unencrypted even if it has no encrypted bytes. r=cpearce

Bug 1494178 added code to mark samples with 0 encrypted ranges as unencrypted
before they were fed to the CDM. This was to catch issues where we could mark
such unencrypted samples as encrypted. However, the CDM expects certain samples
that are clear to still be marked as encrypted.

Specifically, WebM samples should be marked as encrypted if they are from an
encrypted track and have the signal byte's encryption bit set (a marker for if
the packet is encrypted), even if they have no encrypted ranges.

The WebM demuxer is already doing this. Further inspection and testing of the
mp4 demuxer shows it is behaving in line with Chromium's current mp4 parser,
which we can expect prepares its data sensibly for Widevine.

As the code removed here was added as a safety fallback, but is causing issues,
and as the demuxers already appear to be doing the right thing, the fallback
code can be removed.

Differential Revision: https://phabricator.services.mozilla.com/D8024

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryce Van Dyk 2018-10-08 22:34:32 +00:00
parent ba1f0dc311
commit f88683aacf

View File

@ -684,32 +684,6 @@ ConvertToCdmEncryptionScheme(const GMPEncryptionScheme& aEncryptionScheme)
}
}
static cdm::EncryptionScheme
ConvertToCdmEncryptionScheme(const GMPEncryptionScheme& aEncryptionScheme,
uint64_t aNumCipherBytes)
{
if (aNumCipherBytes == 0) {
// Starting at CDM10, if fed a sample marked as encrypted that has no
// encrypted bytes, the CDM will give a decryption error. So we mark these
// as unencrypted to attempt to avoid such errors -- though ideally our
// demuxers should not emit such data, so log it.
if (aEncryptionScheme != GMPEncryptionScheme::kGMPEncryptionNone) {
GMP_LOG(
"ChromiumCDMChild::ConvertToCdmEncryptionScheme() got scheme marked "
"as encrypted, but with no cipher bytes! This should be caught "
"earlier, preferably by the demuxer! Returning "
"cdm::EncryptionScheme::kUnencrypted");
}
return cdm::EncryptionScheme::kUnencrypted;
}
if (aEncryptionScheme == GMPEncryptionScheme::kGMPEncryptionNone) {
GMP_LOG("ChromiumCDMChild::ConvertToCdmEncryptionScheme() got scheme "
"marked as unecrypted but with > 0 cipher bytes! Something is "
"buggy to emit such data -- likey a demuxer");
}
return ConvertToCdmEncryptionScheme(aEncryptionScheme);
}
static void
InitInputBuffer(const CDMInputBuffer& aBuffer,
nsTArray<cdm::SubsampleEntry>& aSubSamples,
@ -729,17 +703,15 @@ InitInputBuffer(const CDMInputBuffer& aBuffer,
aInputBuffer.iv = aBuffer.mIV().Elements();
aInputBuffer.iv_size = aBuffer.mIV().Length();
uint64_t numCipherBytes = 0;
aSubSamples.SetCapacity(aBuffer.mClearBytes().Length());
for (size_t i = 0; i < aBuffer.mCipherBytes().Length(); i++) {
aSubSamples.AppendElement(cdm::SubsampleEntry{
aBuffer.mClearBytes()[i], aBuffer.mCipherBytes()[i] });
numCipherBytes += aBuffer.mCipherBytes()[i];
}
aInputBuffer.subsamples = aSubSamples.Elements();
aInputBuffer.num_subsamples = aSubSamples.Length();
aInputBuffer.encryption_scheme =
ConvertToCdmEncryptionScheme(aBuffer.mEncryptionScheme(), numCipherBytes);
ConvertToCdmEncryptionScheme(aBuffer.mEncryptionScheme());
}
aInputBuffer.timestamp = aBuffer.mTimestamp();
}