Bug 1552717 - P3: Set mInitDataType on sample info regardless of if the sample is encrypted. r=cpearce
authorBryce Van Dyk <bvandyk@mozilla.com>
Tue, 28 May 2019 12:40:16 +0000
changeset 535467 267d1abce0581f08bdefc977f24e421c161e603f
parent 535466 71edbdac5e129ab4c49b0119d2e43962e1b24c34
child 535468 ecceef291b89d6970eaf433dfa520b0930810dcc
push id11522
push userffxbld-merge
push dateMon, 01 Jul 2019 09:00:55 +0000
treeherdermozilla-beta@53ea74d2bd09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1552717
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552717 - P3: Set mInitDataType on sample info regardless of if the sample is encrypted. r=cpearce Unencrypted samples can carry init data and thus we should set the init data type regardless of if the sample itself is encrypted (otherwise the init data info is incomplete for unencrypted samples). Depends on D32751 Differential Revision: https://phabricator.services.mozilla.com/D32752
dom/media/mp4/Index.cpp
--- a/dom/media/mp4/Index.cpp
+++ b/dom/media/mp4/Index.cpp
@@ -133,40 +133,39 @@ already_AddRefed<MediaRawData> SampleIte
     if (!moofParser->mSinf.IsValid()) {
       // The sample description entry says this sample is encrypted, but we
       // don't have a relevant sinf box, this shouldn't happen, so bail.
       return nullptr;
     }
     if (moofParser->mSinf.mDefaultEncryptionType == AtomType("cenc")) {
       cryptoScheme = CryptoScheme::Cenc;
       writer->mCrypto.mCryptoScheme = CryptoScheme::Cenc;
-      writer->mCrypto.mInitDataType = NS_LITERAL_STRING("cenc");
     } else if (moofParser->mSinf.mDefaultEncryptionType == AtomType("cbcs")) {
       cryptoScheme = CryptoScheme::Cbcs;
       writer->mCrypto.mCryptoScheme = CryptoScheme::Cbcs;
-      writer->mCrypto.mInitDataType = NS_LITERAL_STRING("cenc");
     } else {
       MOZ_ASSERT_UNREACHABLE(
           "Sample description entry reports sample is encrypted, but no "
           "scheme, or an unsupported shceme is in use!");
       return nullptr;
     }
   }
 
+  // We need to check if this moof has init data the CDM expects us to surface.
+  // This should happen when handling the first sample, even if that sample
+  // isn't encrypted (samples later in the moof may be).
   if (mCurrentSample == 0) {
     const nsTArray<Moof>& moofs = moofParser->Moofs();
     const Moof* currentMoof = &moofs[mCurrentMoof];
     if (!currentMoof->mPsshes.IsEmpty()) {
-      MOZ_ASSERT(sampleDescriptionEntry->mIsEncryptedEntry,
-                 "Unencrypted fragments should not contain pssh boxes");
-      MOZ_ASSERT(cryptoScheme != CryptoScheme::None);
       // 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.mInitDatas.AppendElements(currentMoof->mPsshes);
+      writer->mCrypto.mInitDataType = NS_LITERAL_STRING("cenc");
     }
   }
 
   if (sampleDescriptionEntry->mIsEncryptedEntry) {
     writer->mCrypto.mCryptoScheme = cryptoScheme;
 
     MOZ_ASSERT(writer->mCrypto.mKeyId.IsEmpty(),
                "Sample should not already have a key ID");