Bug 1509397 - mp4: use per sample IV size from sample group metadata if present. r=jya
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 23 Nov 2018 08:24:53 +0000
changeset 447797 1924c38b206345538d543d24a7cde110ca208855
parent 447796 be33905d0aca61fca9527907dfc56156db4ffdca
child 447798 ca9f1be1f8e80839902aced5f0191775e083505c
push id35090
push userbtara@mozilla.com
push dateFri, 23 Nov 2018 21:37:23 +0000
treeherdermozilla-central@2317749c5abf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1509397
milestone65.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 1509397 - mp4: use per sample IV size from sample group metadata if present. r=jya If sample group metadata is present, it should be used over the less specific track metadata. This patch changes the mp4 parser to do so for per sample IV sizes. Differential Revision: https://phabricator.services.mozilla.com/D12718
dom/media/mp4/Index.cpp
--- a/dom/media/mp4/Index.cpp
+++ b/dom/media/mp4/Index.cpp
@@ -139,23 +139,27 @@ already_AddRefed<MediaRawData> SampleIte
     cenc.SetLength(s->mCencRange.Length());
     if (!mIndex->mSource->ReadAt(s->mCencRange.mStart, cenc.Elements(),
                                  cenc.Length(), &bytesRead) ||
         bytesRead != cenc.Length()) {
       return nullptr;
     }
     BufferReader reader(cenc);
     writer->mCrypto.mValid = true;
-    writer->mCrypto.mIVSize = ivSize;
 
     CencSampleEncryptionInfoEntry* sampleInfo = GetSampleEncryptionEntry();
     if (sampleInfo) {
+      // Use sample group information if present, this supersedes track level
+      // information.
       writer->mCrypto.mKeyId.AppendElements(sampleInfo->mKeyId);
+      ivSize = sampleInfo->mIVSize;
     }
 
+    writer->mCrypto.mIVSize = ivSize;
+
     if (!reader.ReadArray(writer->mCrypto.mIV, ivSize)) {
       return nullptr;
     }
 
     auto res = reader.ReadU16();
     if (res.isOk() && res.unwrap() > 0) {
       uint16_t count = res.unwrap();