Bug 1098126 - MoofParser fixes and disable for EME; r=mattwoodrow
authorAnthony Jones <ajones@mozilla.com>
Fri, 05 Dec 2014 14:01:44 -0800
changeset 219896 0cb3299f2a30e637494a55d0a5ac0ff9077c3ae6
parent 219895 73275f4fe25290906c974c4e48b2a247e0d63ea9
child 219897 a2f64e4663be465b8c38dade8dba4f5fb28407ec
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1098126
milestone37.0a1
Bug 1098126 - MoofParser fixes and disable for EME; r=mattwoodrow
dom/media/fmp4/MP4Reader.cpp
media/libstagefright/binding/MoofParser.cpp
media/libstagefright/binding/mp4_demuxer.cpp
--- a/dom/media/fmp4/MP4Reader.cpp
+++ b/dom/media/fmp4/MP4Reader.cpp
@@ -683,17 +683,19 @@ MP4Reader::PopSample(TrackType aTrack)
   }
 }
 
 nsresult
 MP4Reader::ResetDecode()
 {
   MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn());
   Flush(kVideo);
+  mDemuxer->SeekVideo(0);
   Flush(kAudio);
+  mDemuxer->SeekAudio(0);
   return MediaDecoderReader::ResetDecode();
 }
 
 void
 MP4Reader::Output(TrackType aTrack, MediaData* aSample)
 {
 #ifdef LOG_SAMPLE_DECODE
   VLOG("Decoded %s sample time=%lld dur=%lld",
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mp4_demuxer/MoofParser.h"
 #include "mp4_demuxer/Box.h"
+#include <limits>
 
 namespace mp4_demuxer
 {
 
 using namespace stagefright;
 using namespace mozilla;
 
 void
@@ -67,20 +68,18 @@ public:
 private:
   nsRefPtr<Stream> mStream;
 };
 
 bool
 MoofParser::BlockingReadNextMoof()
 {
   nsTArray<MediaByteRange> byteRanges;
-  int64_t size;
-  bool hasSize = mSource->Length(&size);
   byteRanges.AppendElement(
-    MediaByteRange(0,hasSize ? size : std::numeric_limits<int64_t>::max()));
+    MediaByteRange(0, std::numeric_limits<int64_t>::max()));
   mp4_demuxer::BlockingStream* stream = new BlockingStream(mSource);
 
   BoxContext context(stream, byteRanges);
   for (Box box(&context, mOffset); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("moof")) {
       byteRanges.Clear();
       byteRanges.AppendElement(MediaByteRange(mOffset, box.Range().mEnd));
       RebuildFragmentedIndex(context);
@@ -329,17 +328,17 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd, 
         ctsOffset = reader->Read32();
       }
     }
 
     Sample sample;
     sample.mByteRange = MediaByteRange(offset, offset + sampleSize);
     offset += sampleSize;
 
-    sample.mDecodeTime = decodeTime;
+    sample.mDecodeTime = aMdhd.ToMicroseconds(decodeTime);
     sample.mCompositionRange = Interval<Microseconds>(
       aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset - aEdts.mMediaStart),
       aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset + sampleDuration - aEdts.mMediaStart));
     decodeTime += sampleDuration;
 
     sample.mSync = !(sampleFlags & 0x1010000);
 
     mIndex.AppendElement(sample);
--- 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()) {
+      if (index->IsFragmented() && !mAudioConfig.crypto.valid) {
         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()) {
+      if (index->IsFragmented() && !mVideoConfig.crypto.valid) {
         mPrivate->mVideoIterator = new SampleIterator(index);
       }
     }
   }
   sp<MetaData> metaData = e->getMetaData();
   mCrypto.Update(metaData);
 
   return mPrivate->mAudio.get() || mPrivate->mVideo.get();