Bug 1110608 - Add CENC support to MoofParser; r=edwin
☠☠ backed out by 9bda70b04207 ☠ ☠
authorAnthony Jones <ajones@mozilla.com>
Mon, 15 Dec 2014 17:43:59 +1300
changeset 219659 cdf7d750757792f801e348c93512ab0a694da32e
parent 219658 05ca5d4570e88bc99b292239241d7559dbf39330
child 219660 03e5a89726beb9c8d16c5fd3650f8dccbade68f2
push id52898
push userajones@mozilla.com
push dateMon, 15 Dec 2014 04:45:35 +0000
treeherdermozilla-inbound@03e5a89726be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1110608
milestone37.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 1110608 - Add CENC support to MoofParser; r=edwin
media/libstagefright/binding/Index.cpp
media/libstagefright/binding/MoofParser.cpp
media/libstagefright/binding/mp4_demuxer.cpp
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -121,16 +121,18 @@ MP4Sample* SampleIterator::GetNext()
     sample->crypto.valid = true;
     reader.ReadArray(sample->crypto.iv, 16);
     if (reader.Remaining()) {
       uint16_t count = reader.ReadU16();
       for (size_t i = 0; i < count; i++) {
         sample->crypto.plain_sizes.AppendElement(reader.ReadU16());
         sample->crypto.encrypted_sizes.AppendElement(reader.ReadU32());
       }
+      reader.ReadArray(sample->crypto.iv, 16);
+      sample->crypto.iv_size = 16;
     }
   }
 
   return sample.forget();
 }
 
 Sample* SampleIterator::Get()
 {
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -242,28 +242,26 @@ Moof::ProcessCenc()
 void
 Moof::ParseTraf(Box& aBox, Trex& aTrex, Mdhd& aMdhd, Edts& aEdts)
 {
   Tfhd tfhd(aTrex);
   Tfdt tfdt;
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("tfhd")) {
       tfhd = Tfhd(box, aTrex);
-    } else if (box.IsType("tfdt")) {
-      if (!aTrex.mTrackId || tfhd.mTrackId == aTrex.mTrackId) {
+    } else if (!aTrex.mTrackId || tfhd.mTrackId == aTrex.mTrackId) {
+      if (box.IsType("tfdt")) {
         tfdt = Tfdt(box);
+      } else if (box.IsType("trun")) {
+        ParseTrun(box, tfhd, tfdt, aMdhd, aEdts);
+      } else if (box.IsType("saiz")) {
+        mSaizs.AppendElement(Saiz(box));
+      } else if (box.IsType("saio")) {
+        mSaios.AppendElement(Saio(box));
       }
-    } else if (box.IsType("trun")) {
-      if (!aTrex.mTrackId || tfhd.mTrackId == aTrex.mTrackId) {
-        ParseTrun(box, tfhd, tfdt, aMdhd, aEdts);
-      }
-    } else if (box.IsType("saiz")) {
-      mSaizs.AppendElement(Saiz(box));
-    } else if (box.IsType("saio")) {
-      mSaios.AppendElement(Saio(box));
     }
   }
 }
 
 void
 Moof::FixRounding(const Moof& aMoof) {
   Microseconds gap = aMoof.mTimeRange.start - mTimeRange.end;
   if (gap > 0 && gap <= mMaxRoundingError) {
--- a/media/libstagefright/binding/mp4_demuxer.cpp
+++ b/media/libstagefright/binding/mp4_demuxer.cpp
@@ -106,30 +106,30 @@ MP4Demuxer::Init()
       if (track->start() != OK) {
         return false;
       }
       mPrivate->mAudio = track;
       mAudioConfig.Update(metaData, mimeType);
       nsRefPtr<Index> index = new Index(mPrivate->mAudio->exportIndex(),
                                         mSource, mAudioConfig.mTrackId);
       mPrivate->mIndexes.AppendElement(index);
-      if (index->IsFragmented() && !mAudioConfig.crypto.valid) {
+      if (index->IsFragmented()) {
         mPrivate->mAudioIterator = new SampleIterator(index);
       }
     } else if (!mPrivate->mVideo.get() && !strncmp(mimeType, "video/", 6)) {
       sp<MediaSource> track = e->getTrack(i);
       if (track->start() != OK) {
         return false;
       }
       mPrivate->mVideo = track;
       mVideoConfig.Update(metaData, mimeType);
       nsRefPtr<Index> index = new Index(mPrivate->mVideo->exportIndex(),
                                         mSource, mVideoConfig.mTrackId);
       mPrivate->mIndexes.AppendElement(index);
-      if (index->IsFragmented() && !mVideoConfig.crypto.valid) {
+      if (index->IsFragmented()) {
         mPrivate->mVideoIterator = new SampleIterator(index);
       }
     }
   }
   sp<MetaData> metaData = e->getMetaData();
   mCrypto.Update(metaData);
 
   return mPrivate->mAudio.get() || mPrivate->mVideo.get();
@@ -214,17 +214,16 @@ MP4Sample*
 MP4Demuxer::DemuxVideoSample()
 {
   if (mPrivate->mVideoIterator) {
     nsAutoPtr<MP4Sample> sample(mPrivate->mVideoIterator->GetNext());
     if (sample) {
       sample->prefix_data = mVideoConfig.annex_b;
       if (sample->crypto.valid) {
         sample->crypto.mode = mVideoConfig.crypto.mode;
-        sample->crypto.iv_size = mVideoConfig.crypto.iv_size;
         sample->crypto.key.AppendElements(mVideoConfig.crypto.key);
       }
     }
     return sample.forget();
   }
 
   nsAutoPtr<MP4Sample> sample(new MP4Sample());
   status_t status =