Bug 1487416 - Replace mValid and mMode with mCryptoScheme for track and sample crypto structs. r=jya

Explicitly store the crypto scheme being used on our crypto structs to let us
differentiate between cenc and cbcs data. In doing so remove mMode and replace
mValid with IsEncrypted() for the following reasons:
- Different modes within the existing schemes are not currently utilized by the
  spec: the scheme implies mode. Having a mode and a scheme could lead to confusion
  between the two. We can return mMode if ever needed by the spec --
  possibly if the isProtected flag which we were tracking with mMode, is
  ever changed to be more than a bool in the spec.
- mValid was typically used to check if these structs contained valid crypto
  data or not. With only one scheme this was often shorthand for 'IsEncrypted',
  but with multiple schemes what is considered valid data for one may not be for
  another. Do away with this and just explicitly have an 'IsEncrypted'.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryce Van Dyk 2019-01-11 15:29:45 +00:00
Родитель 1db6ef799b
Коммит fa9d86fda5
19 изменённых файлов: 231 добавлений и 197 удалений

Просмотреть файл

@ -490,13 +490,20 @@ class VideoData : public MediaData {
media::TimeUnit mNextKeyFrameTime;
};
enum class CryptoScheme : uint8_t {
None,
Cenc,
Cbcs,
};
class CryptoTrack {
public:
CryptoTrack() : mValid(false), mMode(0), mIVSize(0) {}
bool mValid;
int32_t mMode;
CryptoTrack() : mCryptoScheme(CryptoScheme::None), mIVSize(0) {}
CryptoScheme mCryptoScheme;
int32_t mIVSize;
nsTArray<uint8_t> mKeyId;
bool IsEncrypted() const { return mCryptoScheme != CryptoScheme::None; }
};
class CryptoSample : public CryptoTrack {

Просмотреть файл

@ -1397,8 +1397,8 @@ void MediaFormatReader::MaybeResolveMetadataPromise() {
}
bool MediaFormatReader::IsEncrypted() const {
return (HasAudio() && mAudio.GetCurrentInfo()->mCrypto.mValid) ||
(HasVideo() && mVideo.GetCurrentInfo()->mCrypto.mValid);
return (HasAudio() && mAudio.GetCurrentInfo()->mCrypto.IsEncrypted()) ||
(HasVideo() && mVideo.GetCurrentInfo()->mCrypto.IsEncrypted());
}
void MediaFormatReader::OnDemuxerInitFailed(const MediaResult& aError) {
@ -2006,7 +2006,8 @@ void MediaFormatReader::HandleDemuxedSamples(
bool recyclable =
StaticPrefs::MediaDecoderRecycleEnabled() &&
decoder.mDecoder->SupportDecoderRecycling() &&
(*info)->mCrypto.mValid == decoder.GetCurrentInfo()->mCrypto.mValid &&
(*info)->mCrypto.mCryptoScheme ==
decoder.GetCurrentInfo()->mCrypto.mCryptoScheme &&
(*info)->mMimeType == decoder.GetCurrentInfo()->mMimeType;
if (!recyclable && decoder.mTimeThreshold.isNothing() &&
(decoder.mNextStreamSourceID.isNothing() ||

Просмотреть файл

@ -543,7 +543,7 @@ class MediaFormatReader final
// Typically for audio, the number of channels and/or sampling rate can vary
// between what was found in the metadata and what the decoder returned.
const TrackInfo* GetWorkingInfo() const { return mWorkingInfo.get(); }
bool IsEncrypted() const { return GetCurrentInfo()->mCrypto.mValid; }
bool IsEncrypted() const { return GetCurrentInfo()->mCrypto.IsEncrypted(); }
// Used by the MDSM for logging purposes.
Atomic<size_t> mSizeOfQueue;

Просмотреть файл

@ -394,8 +394,8 @@ class MediaInfo {
}
bool IsEncrypted() const {
return (HasAudio() && mAudio.mCrypto.mValid) ||
(HasVideo() && mVideo.mCrypto.mValid);
return (HasAudio() && mAudio.mCrypto.IsEncrypted()) ||
(HasVideo() && mVideo.mCrypto.IsEncrypted());
}
bool HasValidMedia() const { return HasVideo() || HasAudio(); }

Просмотреть файл

@ -245,20 +245,35 @@ bool ChromiumCDMParent::InitCDMInputBuffer(gmp::CDMInputBuffer& aBuffer,
return false;
}
memcpy(shmem.get<uint8_t>(), aSample->Data(), aSample->Size());
GMPEncryptionScheme encryptionScheme =
GMPEncryptionScheme::kGMPEncryptionNone;
switch (crypto.mCryptoScheme) {
case CryptoScheme::None:
break; // Default to none
case CryptoScheme::Cenc:
encryptionScheme = GMPEncryptionScheme::kGMPEncryptionCenc;
break;
case CryptoScheme::Cbcs:
encryptionScheme = GMPEncryptionScheme::kGMPEncryptionCbcs;
break;
default:
GMP_LOG(
"InitCDMInputBuffer got unexpected encryption scheme with "
"value of %" PRIu8 ". Treating as no encryption.",
static_cast<uint8_t>(crypto.mCryptoScheme));
MOZ_ASSERT_UNREACHABLE("Should not have unrecognized encryption type");
break;
}
aBuffer = gmp::CDMInputBuffer(
shmem, crypto.mKeyId, crypto.mIV, aSample->mTime.ToMicroseconds(),
aSample->mDuration.ToMicroseconds(), crypto.mPlainSizes,
crypto.mEncryptedSizes,
crypto.mValid ? GMPEncryptionScheme::kGMPEncryptionCenc
: GMPEncryptionScheme::kGMPEncryptionNone);
crypto.mEncryptedSizes, encryptionScheme);
MOZ_ASSERT(
aBuffer.mEncryptionScheme() == GMPEncryptionScheme::kGMPEncryptionNone ||
aBuffer.mEncryptionScheme() ==
GMPEncryptionScheme::kGMPEncryptionCenc,
"aBuffer should use either no encryption or cenc, other kinds are not "
"yet "
"supported");
"yet supported");
return true;
}

Просмотреть файл

@ -167,8 +167,8 @@ TEST(MP4Demuxer, Seek) {
static nsCString ToCryptoString(const CryptoSample& aCrypto) {
nsCString res;
if (aCrypto.mValid) {
res.AppendPrintf("%d %d ", aCrypto.mMode, aCrypto.mIVSize);
if (aCrypto.IsEncrypted()) {
res.AppendPrintf("%d ", aCrypto.mIVSize);
for (size_t i = 0; i < aCrypto.mKeyId.Length(); i++) {
res.AppendPrintf("%02x", aCrypto.mKeyId[i]);
}
@ -189,125 +189,125 @@ static nsCString ToCryptoString(const CryptoSample& aCrypto) {
TEST(MP4Demuxer, CENCFragVideo) {
const char* video[] = {
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000000 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000000 "
"5,684 5,16980",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000450 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000450 "
"5,1826",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000004c3 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000004c3 "
"5,1215",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000050f "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000050f "
"5,1302",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000561 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000561 "
"5,939",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000059c "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000059c "
"5,763",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000005cc "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000005cc "
"5,672",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000005f6 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000005f6 "
"5,748",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000625 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000625 "
"5,1025",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000666 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000666 "
"5,730",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000694 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000694 "
"5,897",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000006cd "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000006cd "
"5,643",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000006f6 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000006f6 "
"5,556",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000719 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000719 "
"5,527",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000073a "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000073a "
"5,606",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000760 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000760 "
"5,701",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000078c "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000078c "
"5,531",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007ae "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007ae "
"5,562",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007d2 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007d2 "
"5,576",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007f6 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000007f6 "
"5,514",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000817 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000817 "
"5,404",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000831 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000831 "
"5,635",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000859 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000859 "
"5,433",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000875 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000875 "
"5,478",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000893 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000893 "
"5,474",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008b1 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008b1 "
"5,462",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008ce "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008ce "
"5,473",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008ec "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000008ec "
"5,437",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000908 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000908 "
"5,418",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000923 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000923 "
"5,475",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000941 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000941 "
"5,23133",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000ee7 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000ee7 "
"5,475",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f05 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f05 "
"5,402",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f1f "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f1f "
"5,415",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f39 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f39 "
"5,408",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f53 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f53 "
"5,442",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f6f "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f6f "
"5,385",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f88 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f88 "
"5,368",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f9f "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000f9f "
"5,354",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fb6 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fb6 "
"5,400",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fcf "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fcf "
"5,399",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fe8 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000fe8 "
"5,1098",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000102d "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000102d "
"5,1508",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000108c "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000108c "
"5,1345",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000010e1 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000010e1 "
"5,1945",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000115b "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000115b "
"5,1824",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000011cd "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000011cd "
"5,2133",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001253 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001253 "
"5,2486",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000012ef "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000012ef "
"5,1739",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000135c "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000135c "
"5,1836",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000013cf "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000013cf "
"5,2367",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001463 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001463 "
"5,2571",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001504 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001504 "
"5,3008",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000015c0 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000015c0 "
"5,3255",
"1 16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000168c "
"16 7e571d037e571d037e571d037e571d03 0000000000000000000000000000168c "
"5,3225",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001756 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001756 "
"5,3118",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001819 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001819 "
"5,2407",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000018b0 "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000018b0 "
"5,2400",
"1 16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001946 "
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000001946 "
"5,2158",
"1 16 7e571d037e571d037e571d037e571d03 000000000000000000000000000019cd "
"16 7e571d037e571d037e571d037e571d03 000000000000000000000000000019cd "
"5,2392",
};
@ -334,193 +334,193 @@ TEST(MP4Demuxer, CENCFragVideo) {
TEST(MP4Demuxer, CENCFragAudio) {
const char* audio[] = {
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000000 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000000 "
"0,281",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000012 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000012 "
"0,257",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000023 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000023 "
"0,246",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000033 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000033 "
"0,257",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000044 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000044 "
"0,260",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000055 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000055 "
"0,260",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000066 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000066 "
"0,272",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000077 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000077 "
"0,280",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000089 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000089 "
"0,284",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000009b "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000009b "
"0,290",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000ae "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000ae "
"0,278",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000c0 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000c0 "
"0,268",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000d1 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000d1 "
"0,307",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000e5 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000e5 "
"0,290",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000f8 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000000f8 "
"0,304",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000010b "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000010b "
"0,316",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000011f "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000011f "
"0,308",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000133 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000133 "
"0,301",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000146 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000146 "
"0,318",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000015a "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000015a "
"0,311",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000016e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000016e "
"0,303",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000181 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000181 "
"0,325",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000196 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000196 "
"0,334",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001ab "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001ab "
"0,344",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001c1 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001c1 "
"0,344",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001d7 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001d7 "
"0,387",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001f0 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000001f0 "
"0,396",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000209 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000209 "
"0,368",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000220 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000220 "
"0,373",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000238 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000238 "
"0,425",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000253 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000253 "
"0,428",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000026e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000026e "
"0,426",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000289 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000289 "
"0,427",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002a4 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002a4 "
"0,424",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002bf "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002bf "
"0,447",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002db "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002db "
"0,446",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002f7 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000002f7 "
"0,442",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000313 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000313 "
"0,444",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000032f "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000032f "
"0,374",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000347 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000347 "
"0,405",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000361 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000361 "
"0,372",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000379 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000379 "
"0,395",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000392 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000392 "
"0,435",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003ae "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003ae "
"0,426",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003c9 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003c9 "
"0,430",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003e4 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003e4 "
"0,390",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003fd "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000003fd "
"0,335",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000412 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000412 "
"0,339",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000428 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000428 "
"0,352",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000043e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000043e "
"0,364",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000455 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000455 "
"0,398",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000046e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000046e "
"0,451",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000048b "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000048b "
"0,448",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004a7 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004a7 "
"0,436",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004c3 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004c3 "
"0,424",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004de "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004de "
"0,428",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004f9 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000004f9 "
"0,413",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000513 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000513 "
"0,430",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000052e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000052e "
"0,450",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000054b "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000054b "
"0,386",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000564 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000564 "
"0,320",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000578 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000578 "
"0,347",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000058e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000058e "
"0,382",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005a6 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005a6 "
"0,437",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005c2 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005c2 "
"0,387",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005db "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005db "
"0,340",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005f1 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000005f1 "
"0,337",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000607 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000607 "
"0,389",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000620 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000620 "
"0,428",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000063b "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000063b "
"0,426",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000656 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000656 "
"0,446",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000672 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000672 "
"0,456",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000068f "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000068f "
"0,468",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006ad "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006ad "
"0,468",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006cb "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006cb "
"0,463",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006e8 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000006e8 "
"0,467",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000706 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000706 "
"0,460",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000723 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000723 "
"0,446",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000073f "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000073f "
"0,453",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000075c "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000075c "
"0,448",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000778 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000778 "
"0,446",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000794 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000794 "
"0,439",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007b0 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007b0 "
"0,436",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007cc "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007cc "
"0,441",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007e8 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000007e8 "
"0,465",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000806 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000806 "
"0,448",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000822 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000822 "
"0,448",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000083e "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000083e "
"0,469",
"1 16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000085c "
"16 7e571d047e571d047e571d047e571d04 0000000000000000000000000000085c "
"0,431",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000877 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000877 "
"0,437",
"1 16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000893 "
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000893 "
"0,474",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008b1 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008b1 "
"0,436",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008cd "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008cd "
"0,433",
"1 16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008e9 "
"16 7e571d047e571d047e571d047e571d04 000000000000000000000000000008e9 "
"0,481",
};

Просмотреть файл

@ -394,13 +394,20 @@ CryptoSample HLSTrackDemuxer::ExtractCryptoSample(
char const* msg = "";
do {
HLS_DEBUG("HLSTrackDemuxer", "Sample has Crypto Info");
crypto.mValid = true;
int32_t mode = 0;
if (NS_FAILED(aCryptoInfo->Mode(&mode))) {
msg = "Error when extracting encryption mode.";
break;
}
crypto.mMode = mode;
// We currently only handle ctr mode.
if (mode != java::sdk::MediaCodec::CRYPTO_MODE_AES_CTR) {
msg = "Error: unexpected encryption mode.";
break;
}
crypto.mCryptoScheme = CryptoScheme::Cenc;
mozilla::jni::ByteArray::LocalRef ivData;
if (NS_FAILED(aCryptoInfo->Iv(&ivData))) {
msg = "Error when extracting encryption IV.";

Просмотреть файл

@ -50,8 +50,9 @@ bool MP4AudioInfo::IsValid() const {
static void UpdateTrackProtectedInfo(mozilla::TrackInfo& aConfig,
const Mp4parseSinfInfo& aSinf) {
if (aSinf.is_encrypted != 0) {
aConfig.mCrypto.mValid = true;
aConfig.mCrypto.mMode = aSinf.is_encrypted;
// We currently only handle cenc, but this should be updated once we parse
// cbcs encryption data.
aConfig.mCrypto.mCryptoScheme = CryptoScheme::Cenc;
aConfig.mCrypto.mIVSize = aSinf.iv_size;
aConfig.mCrypto.mKeyId.AppendElements(aSinf.kid.data, aSinf.kid.length);
}

Просмотреть файл

@ -119,7 +119,8 @@ already_AddRefed<MediaRawData> SampleIterator::GetNext() {
// This Moof contained crypto init data. Report that. We only report
// the init data on the Moof's first sample, to avoid reporting it more
// than once per Moof.
writer->mCrypto.mValid = true;
// We only handle cenc for now, but update this once we're handling cbcs
writer->mCrypto.mCryptoScheme = CryptoScheme::Cenc;
writer->mCrypto.mInitDatas.AppendElements(currentMoof->mPsshes);
writer->mCrypto.mInitDataType = NS_LITERAL_STRING("cenc");
}
@ -143,7 +144,7 @@ already_AddRefed<MediaRawData> SampleIterator::GetNext() {
return nullptr;
}
BufferReader reader(cenc);
writer->mCrypto.mValid = true;
writer->mCrypto.mCryptoScheme = CryptoScheme::Cenc;
CencSampleEncryptionInfoEntry* sampleInfo = GetSampleEncryptionEntry();
if (sampleInfo) {

Просмотреть файл

@ -422,7 +422,7 @@ already_AddRefed<MediaRawData> MP4TrackDemuxer::GetNextSample() {
}
if (mInfo->GetAsVideoInfo()) {
sample->mExtraData = mInfo->GetAsVideoInfo()->mExtraData;
if (mIsH264 && !sample->mCrypto.mValid) {
if (mIsH264 && !sample->mCrypto.IsEncrypted()) {
H264::FrameType type = H264::GetFrameType(sample);
switch (type) {
case H264::FrameType::I_FRAME:
@ -458,9 +458,8 @@ already_AddRefed<MediaRawData> MP4TrackDemuxer::GetNextSample() {
}
}
if (sample->mCrypto.mValid) {
if (sample->mCrypto.IsEncrypted()) {
UniquePtr<MediaRawDataWriter> writer(sample->CreateWriter());
writer->mCrypto.mMode = mInfo->mCrypto.mMode;
// Only use the default key parsed from the moov if we haven't already got
// one from the sample group description.

Просмотреть файл

@ -197,7 +197,7 @@ already_AddRefed<MediaDataDecoder> PDMFactory::CreateDecoder(
}
const TrackInfo& config = aParams.mConfig;
bool isEncrypted = mEMEPDM && config.mCrypto.mValid;
bool isEncrypted = mEMEPDM && config.mCrypto.IsEncrypted();
if (isEncrypted) {
return CreateDecoderWithPDM(mEMEPDM, aParams);

Просмотреть файл

@ -53,7 +53,7 @@ bool Adts::ConvertSample(uint16_t aChannelCount, int8_t aFrequencyIndex,
return false;
}
if (aSample->mCrypto.mValid) {
if (aSample->mCrypto.IsEncrypted()) {
if (aSample->mCrypto.mPlainSizes.Length() == 0) {
writer->mCrypto.mPlainSizes.AppendElement(kADTSHeaderSize);
writer->mCrypto.mEncryptedSizes.AppendElement(aSample->Size() -
@ -82,7 +82,7 @@ bool Adts::RevertSample(MediaRawData* aSample) {
UniquePtr<MediaRawDataWriter> writer(aSample->CreateWriter());
writer->PopFront(kADTSHeaderSize);
if (aSample->mCrypto.mValid) {
if (aSample->mCrypto.IsEncrypted()) {
if (aSample->mCrypto.mPlainSizes.Length() > 0 &&
writer->mCrypto.mPlainSizes[0] >= kADTSHeaderSize) {
writer->mCrypto.mPlainSizes[0] -= kADTSHeaderSize;

Просмотреть файл

@ -70,7 +70,7 @@ Result<Ok, nsresult> AnnexB::ConvertSampleToAnnexB(
// offsets. So we need to account for the extra bytes by increasing
// the length of the first clear data subsample. Otherwise decryption
// will fail.
if (aSample->mCrypto.mValid) {
if (aSample->mCrypto.IsEncrypted()) {
if (aSample->mCrypto.mPlainSizes.Length() == 0) {
samplewriter->mCrypto.mPlainSizes.AppendElement(annexB->Length());
samplewriter->mCrypto.mEncryptedSizes.AppendElement(

Просмотреть файл

@ -804,7 +804,7 @@ static int32_t ConditionDimension(float aValue) {
int nalLenSize = ((*aSample->mExtraData)[4] & 3) + 1;
size_t sampleSize = aSample->Size();
if (aSample->mCrypto.mValid) {
if (aSample->mCrypto.IsEncrypted()) {
// The content is encrypted, we can only parse the non-encrypted data.
MOZ_ASSERT(aSample->mCrypto.mPlainSizes.Length() > 0);
if (aSample->mCrypto.mPlainSizes.Length() == 0 ||

Просмотреть файл

@ -376,7 +376,7 @@ static already_AddRefed<MediaDataDecoderProxy> CreateDecoderWrapper(
already_AddRefed<MediaDataDecoder> EMEDecoderModule::CreateVideoDecoder(
const CreateDecoderParams& aParams) {
MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
MOZ_ASSERT(aParams.mConfig.mCrypto.IsEncrypted());
if (StaticPrefs::MediaEmeVideoBlank()) {
EME_LOG("EMEDecoderModule::CreateVideoDecoder() creating a blank decoder.");
@ -407,7 +407,7 @@ already_AddRefed<MediaDataDecoder> EMEDecoderModule::CreateVideoDecoder(
already_AddRefed<MediaDataDecoder> EMEDecoderModule::CreateAudioDecoder(
const CreateDecoderParams& aParams) {
MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
MOZ_ASSERT(aParams.mConfig.mCrypto.IsEncrypted());
// We don't support using the GMP to decode audio.
MOZ_ASSERT(!SupportsMimeType(aParams.mConfig.mMimeType, nullptr));

Просмотреть файл

@ -25,7 +25,7 @@ SamplesWaitingForKey::~SamplesWaitingForKey() { Flush(); }
RefPtr<SamplesWaitingForKey::WaitForKeyPromise>
SamplesWaitingForKey::WaitIfKeyNotUsable(MediaRawData* aSample) {
if (!aSample || !aSample->mCrypto.mValid || !mProxy) {
if (!aSample || !aSample->mCrypto.IsEncrypted() || !mProxy) {
return WaitForKeyPromise::CreateAndResolve(aSample, __func__);
}
auto caps = mProxy->Capabilites().Lock();

Просмотреть файл

@ -521,7 +521,7 @@ static CryptoInfo::LocalRef GetCryptoInfoFromSample(
const MediaRawData* aSample) {
auto& cryptoObj = aSample->mCrypto;
if (!cryptoObj.mValid) {
if (!cryptoObj.IsEncrypted()) {
return nullptr;
}

Просмотреть файл

@ -146,7 +146,7 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
MediaResult CheckForChange(MediaRawData* aSample) override {
// Don't look at encrypted content.
if (aSample->mCrypto.mValid) {
if (aSample->mCrypto.IsEncrypted()) {
return NS_OK;
}
// For both VP8 and VP9, we only look for resolution changes

Просмотреть файл

@ -361,7 +361,9 @@ nsresult WebMDemuxer::ReadMetadata() {
mInfo.mVideo.mDuration = TimeUnit::FromNanoseconds(duration);
}
mInfo.mVideo.mCrypto = GetTrackCrypto(TrackInfo::kVideoTrack, track);
if (mInfo.mVideo.mCrypto.mValid) {
if (mInfo.mVideo.mCrypto.IsEncrypted()) {
MOZ_ASSERT(mInfo.mVideo.mCrypto.mCryptoScheme == CryptoScheme::Cenc,
"WebM should only use cenc scheme");
mCrypto.AddInitData(NS_LITERAL_STRING("webm"),
mInfo.mVideo.mCrypto.mKeyId);
}
@ -426,7 +428,9 @@ nsresult WebMDemuxer::ReadMetadata() {
mInfo.mAudio.mDuration = TimeUnit::FromNanoseconds(duration);
}
mInfo.mAudio.mCrypto = GetTrackCrypto(TrackInfo::kAudioTrack, track);
if (mInfo.mAudio.mCrypto.mValid) {
if (mInfo.mAudio.mCrypto.IsEncrypted()) {
MOZ_ASSERT(mInfo.mAudio.mCrypto.mCryptoScheme == CryptoScheme::Cenc,
"WebM should only use cenc scheme");
mCrypto.AddInitData(NS_LITERAL_STRING("webm"),
mInfo.mAudio.mCrypto.mKeyId);
}
@ -508,8 +512,8 @@ CryptoTrack WebMDemuxer::GetTrackCrypto(TrackInfo::TrackType aType,
}
if (!initData.IsEmpty()) {
crypto.mValid = true;
// crypto.mMode is not used for WebMs
// Webm only uses a cenc style scheme.
crypto.mCryptoScheme = CryptoScheme::Cenc;
crypto.mIVSize = WEBM_IV_SIZE;
crypto.mKeyId = std::move(initData);
}
@ -705,7 +709,7 @@ nsresult WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType,
unsigned char const* iv;
size_t ivLength;
nestegg_packet_iv(holder->Packet(), &iv, &ivLength);
writer->mCrypto.mValid = true;
writer->mCrypto.mCryptoScheme = CryptoScheme::Cenc;
writer->mCrypto.mIVSize = ivLength;
if (ivLength == 0) {
// Frame is not encrypted. This shouldn't happen as it means the
@ -1165,9 +1169,8 @@ void WebMTrackDemuxer::Reset() {
void WebMTrackDemuxer::UpdateSamples(nsTArray<RefPtr<MediaRawData>>& aSamples) {
for (const auto& sample : aSamples) {
if (sample->mCrypto.mValid) {
if (sample->mCrypto.IsEncrypted()) {
UniquePtr<MediaRawDataWriter> writer(sample->CreateWriter());
writer->mCrypto.mMode = mInfo->mCrypto.mMode;
writer->mCrypto.mIVSize = mInfo->mCrypto.mIVSize;
writer->mCrypto.mKeyId.AppendElements(mInfo->mCrypto.mKeyId);
}