Bug 1133572 - Use new demuxer for all sample fetches; r=cpearce
authorAnthony Jones <ajones@mozilla.com>
Wed, 18 Feb 2015 19:13:15 +1300
changeset 229676 36a3cbc746f50d61a572b4b5b392aab02e238d74
parent 229675 5cc5ea4bf0726e7bbf8701dae40fd76a43d106f6
child 229677 71d030563b18097639ea2bcef8f4242ffa5864af
push id28294
push userryanvm@gmail.com
push dateThu, 19 Feb 2015 01:30:38 +0000
treeherdermozilla-central@360b5f211180 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1133572
milestone38.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 1133572 - Use new demuxer for all sample fetches; r=cpearce
dom/media/gtest/TestMP4Demuxer.cpp
dom/media/gtest/moz.build
dom/media/test/manifest.js
dom/media/test/mochitest.ini
dom/media/test/short-cenc.mp4
dom/media/test/short-cenc.xml
media/libstagefright/binding/Index.cpp
media/libstagefright/binding/mp4_demuxer.cpp
--- a/dom/media/gtest/TestMP4Demuxer.cpp
+++ b/dom/media/gtest/TestMP4Demuxer.cpp
@@ -82,77 +82,16 @@ ToCryptoString(CryptoSample& aCrypto)
                        aCrypto.encrypted_sizes[i]);
     }
   } else {
     res.Append("no crypto");
   }
   return res;
 }
 
-TEST(MP4Demuxer, CENC)
-{
-  nsRefPtr<MP4DemuxerBinding> b = new MP4DemuxerBinding("short-cenc.mp4");
-  MonitorAutoLock mon(b->mMonitor);
-  MP4Demuxer* d = b->demuxer;
-
-  EXPECT_TRUE(d->Init());
-
-  const char* video[] = {
-    "1 16 7e571d017e571d017e571d017e571d01 00000000000000000000000000000000 5,686 5,388",
-    "1 16 7e571d017e571d017e571d017e571d01 00000000000000000000000000000044 5,717",
-    "1 16 7e571d017e571d017e571d017e571d01 00000000000000000000000000000071 5,613",
-    "1 16 7e571d017e571d017e571d017e571d01 00000000000000000000000000000098 5,196",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000a5 5,213",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000b3 5,213",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000c1 5,384",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000d9 5,256",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000e9 5,245",
-    "1 16 7e571d017e571d017e571d017e571d01 000000000000000000000000000000f9 5,251",
-  };
-
-  MP4Sample* sample;
-  size_t i = 0;
-  while (!!(sample = d->DemuxVideoSample())) {
-    nsCString text = ToCryptoString(sample->crypto);
-    EXPECT_STREQ(video[i++], text.get());
-  }
-  EXPECT_EQ(ArrayLength(video), i);
-
-  const char* audio[] = {
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000000 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000018 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000030 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000048 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000060 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000078 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000090 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000000a8 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000000c0 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000000d8 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000000f0 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000108 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000120 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000138 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000150 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000168 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000180 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 00000000000000000000000000000198 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000001b0 0,371",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000001c8 0,372",
-    "1 16 7e571d027e571d027e571d027e571d02 000000000000000000000000000001e0 0,371",
-  };
-
-  i = 0;
-  while (!!(sample = d->DemuxAudioSample())) {
-    nsCString text = ToCryptoString(sample->crypto);
-    EXPECT_STREQ(audio[i++], text.get());
-  }
-  EXPECT_EQ(ArrayLength(audio), i);
-}
-
 TEST(MP4Demuxer, CENCFrag)
 {
   nsRefPtr<MP4DemuxerBinding> b = new MP4DemuxerBinding("gizmo-frag.mp4");
   MonitorAutoLock mon(b->mMonitor);
   MP4Demuxer* d = b->demuxer;
 
   EXPECT_TRUE(d->Init());
 
--- a/dom/media/gtest/moz.build
+++ b/dom/media/gtest/moz.build
@@ -20,17 +20,16 @@ if CONFIG['MOZ_WEBM_ENCODER']:
         'TestVideoTrackEncoder.cpp',
         'TestVorbisTrackEncoder.cpp',
         'TestWebMWriter.cpp',
     ]
 
 TEST_HARNESS_FILES.gtest += [
     '../test/gizmo-frag.mp4',
     '../test/gizmo.mp4',
-    '../test/short-cenc.mp4',
     'dash_dashinit.mp4',
     'mediasource_test.mp4',
     'test.webm',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -641,39 +641,16 @@ var gMetadataTests = [
   },
   { name:"wavedata_u8.wav", tags: { }
   },
 ];
 
 // Test files for Encrypted Media Extensions
 var gEMETests = [
   {
-    name:"short-cenc.mp4",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
-    keys: {
-      // "keyid" : "key"
-      "7e571d017e571d017e571d017e571d01" : "7e5711117e5711117e5711117e571111",
-      "7e571d027e571d027e571d027e571d02" : "7e5722227e5722227e5722227e572222",
-    },
-    sessionType:"temporary",
-    duration:0.47
-  },
-  {
-    name:"short-cenc.mp4",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
-    keys: {
-      // "keyid" : "key"
-      "7e571d017e571d017e571d017e571d01" : "7e5711117e5711117e5711117e571111",
-      "7e571d027e571d027e571d027e571d02" : "7e5722227e5722227e5722227e572222",
-    },
-    sessionType:"temporary",
-    duration:0.47,
-    crossOrigin:true,
-  },
-  {
     name:"gizmo-frag-cencinit.mp4",
     fragments: [ "gizmo-frag-cencinit.mp4", "gizmo-frag-cenc1.m4s", "gizmo-frag-cenc2.m4s" ],
     type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     keys: {
       // "keyid" : "key"
       "7e571d037e571d037e571d037e571d03" : "7e5733337e5733337e5733337e573333",
       "7e571d047e571d047e571d047e571d04" : "7e5744447e5744447e5744447e574444",
     },
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -228,17 +228,16 @@ support-files =
   seek.webm
   seek.webm^headers^
   seek.yuv
   seek_support.js
   seekLies.sjs
   seek_with_sound.ogg^headers^
   sine.webm
   sine.webm^headers^
-  short-cenc.mp4
   short-video.ogv
   short-video.ogv^headers^
   small-shot-mp3.mp4
   small-shot-mp3.mp4^headers^
   small-shot.m4a
   small-shot.mp3
   small-shot.mp3^headers^
   small-shot.ogg
deleted file mode 100644
index aa44c3b9a187b78c7a7a0a0bbfeb546f6ee3d96a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/dom/media/test/short-cenc.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  This XML file describes the encryption applied to short-cenc.mp4. To generate
-  short-cenc, run the following command:
-
-    MP4Box -crypt short-cenc.xml -out short-cenc.mp4 short.mp4
--->
-
-<GPACDRM type="CENC AES-CTR">
-
-  <DRMInfo type="pssh" version="1">
-    <!--
-    SystemID specified in
-    https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/cenc-format.html
-    -->
-    <BS ID128="1077efecc0b24d02ace33c1e52e2fb4b" />
-    <!-- Number of KeyIDs = 2 -->
-    <BS bits="32" value="2" />
-    <!-- KeyID -->
-    <BS ID128="0x7e571d017e571d017e571d017e571d01" />
-    <BS ID128="0x7e571d027e571d027e571d027e571d02" />
-  </DRMInfo>
-
-  <CrypTrack trackID="1" isEncrypted="1" IV_size="16" saiSavedBox="senc"
-    first_IV="0x00000000000000000000000000000000">
-    <key KID="0x7e571d017e571d017e571d017e571d01"
-      value="0x7e5711117e5711117e5711117e571111" />
-  </CrypTrack>
-
-  <CrypTrack trackID="2" isEncrypted="1" IV_size="16" saiSavedBox="senc"
-    first_IV="0x00000000000000000000000000000000">
-    <key KID="0x7e571d027e571d027e571d027e571d02"
-      value="0x7e5722227e5722227e5722227e572222" />
-  </CrypTrack>
-
-</GPACDRM>
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -152,17 +152,20 @@ MP4Sample* SampleIterator::GetNext()
   Next();
 
   return sample.forget();
 }
 
 Sample* SampleIterator::Get()
 {
   if (!mIndex->mMoofParser) {
-    return nullptr;
+    MOZ_ASSERT(!mCurrentMoof);
+    return mCurrentSample < mIndex->mIndex.Length()
+      ? &mIndex->mIndex[mCurrentSample]
+      : nullptr;
   }
 
   nsTArray<Moof>& moofs = mIndex->mMoofParser->Moofs();
   while (true) {
     if (mCurrentMoof == moofs.Length()) {
       if (!mIndex->mMoofParser->BlockingReadNextMoof()) {
         return nullptr;
       }
--- a/media/libstagefright/binding/mp4_demuxer.cpp
+++ b/media/libstagefright/binding/mp4_demuxer.cpp
@@ -119,33 +119,29 @@ MP4Demuxer::Init()
         return false;
       }
       mPrivate->mAudio = track;
       mAudioConfig.Update(metaData, mimeType);
       nsRefPtr<Index> index = new Index(mPrivate->mAudio->exportIndex(),
                                         mSource, mAudioConfig.mTrackId,
                                         mMonitor);
       mPrivate->mIndexes.AppendElement(index);
-      if (index->IsFragmented()) {
-        mPrivate->mAudioIterator = new SampleIterator(index);
-      }
+      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,
                                         mMonitor);
       mPrivate->mIndexes.AppendElement(index);
-      if (index->IsFragmented()) {
-        mPrivate->mVideoIterator = new SampleIterator(index);
-      }
+      mPrivate->mVideoIterator = new SampleIterator(index);
     }
   }
   sp<MetaData> metaData = e->getMetaData();
   mCrypto.Update(metaData);
 
   int64_t movieDuration;
   if (!mVideoConfig.duration && !mAudioConfig.duration &&
       metaData->findInt64(kKeyMovieDuration, &movieDuration)) {