Bug 1171330: P14. Add ContainerParser::FirstCompleteMediaHeader() method. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 11 Jun 2015 16:27:15 +1000
changeset 267816 06f657ea41601a67abfdc7e5f7b15c22c904d977
parent 267815 d3f99ebe7c888182b6734ac82e94e3c341252dcf
child 267817 cb28ba1d607b32cc4598d08e63f5875143758cda
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1171330
milestone41.0a1
Bug 1171330: P14. Add ContainerParser::FirstCompleteMediaHeader() method. r=kentuckyfriedtakahe
dom/media/mediasource/ContainerParser.cpp
dom/media/mediasource/ContainerParser.h
media/libstagefright/binding/MoofParser.cpp
media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -88,27 +88,33 @@ ContainerParser::HasCompleteInitData()
 
 MediaLargeByteBuffer*
 ContainerParser::InitData()
 {
   return mInitData;
 }
 
 MediaByteRange
+ContainerParser::InitSegmentRange()
+{
+  return mCompleteInitSegmentRange;
+}
+
+MediaByteRange
+ContainerParser::MediaHeaderRange()
+{
+  return mCompleteMediaHeaderRange;
+}
+
+MediaByteRange
 ContainerParser::MediaSegmentRange()
 {
   return mCompleteMediaSegmentRange;
 }
 
-MediaByteRange
-ContainerParser::InitSegmentRange()
-{
-  return mCompleteInitSegmentRange;
-}
-
 class WebMContainerParser : public ContainerParser {
 public:
   explicit WebMContainerParser(const nsACString& aType)
     : ContainerParser(aType)
     , mParser(0)
     , mOffset(0)
   {}
 
@@ -334,16 +340,17 @@ public:
         MSE_DEBUG(MP4ContainerParser, "Incomplete init found.");
       }
       mHasInitData = true;
     }
 
     mp4_demuxer::Interval<mp4_demuxer::Microseconds> compositionRange =
       mParser->GetCompositionRange(byteRanges);
 
+    mCompleteMediaHeaderRange = mParser->FirstCompleteMediaHeader();
     mCompleteMediaSegmentRange = mParser->FirstCompleteMediaSegment();
     ErrorResult rv;
     mResource->EvictData(mParser->mOffset, mParser->mOffset, rv);
     if (NS_WARN_IF(rv.Failed())) {
       rv.SuppressException();
       return false;
     }
 
--- a/dom/media/mediasource/ContainerParser.h
+++ b/dom/media/mediasource/ContainerParser.h
@@ -47,26 +47,32 @@ public:
   MediaLargeByteBuffer* InitData();
 
   bool HasInitData()
   {
     return mHasInitData;
   }
 
   bool HasCompleteInitData();
-  // Return the byte range of the first complete media segment or an empty
+  // Returns the byte range of the first complete init segment, or an empty
+  // range if not complete.
+  MediaByteRange InitSegmentRange();
+  // Returns the byte range of the first complete media segment header,
+  // or an empty range if not complete.
+  MediaByteRange MediaHeaderRange();
+  // Returns the byte range of the first complete media segment or an empty
   // range if not complete.
   MediaByteRange MediaSegmentRange();
-  MediaByteRange InitSegmentRange();
 
   static ContainerParser* CreateForMIMEType(const nsACString& aType);
 
 protected:
   nsRefPtr<MediaLargeByteBuffer> mInitData;
   nsRefPtr<SourceBufferResource> mResource;
   bool mHasInitData;
+  MediaByteRange mCompleteInitSegmentRange;
+  MediaByteRange mCompleteMediaHeaderRange;
   MediaByteRange mCompleteMediaSegmentRange;
-  MediaByteRange mCompleteInitSegmentRange;
   const nsCString mType;
 };
 
 } // namespace mozilla
 #endif /* MOZILLA_CONTAINERPARSER_H_ */
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -77,16 +77,25 @@ MoofParser::RebuildFragmentedIndex(BoxCo
       }
     }
     mOffset = box.NextOffset();
   }
   return foundValidMoof;
 }
 
 MediaByteRange
+MoofParser::FirstCompleteMediaHeader()
+{
+  if (Moofs().IsEmpty()) {
+    return MediaByteRange();
+  }
+  return Moofs()[0].mRange;
+}
+
+MediaByteRange
 MoofParser::FirstCompleteMediaSegment()
 {
   for (uint32_t i = 0 ; i < mMediaRanges.Length(); i++) {
     if (mMediaRanges[i].Contains(Moofs()[i].mMdatRange)) {
       return mMediaRanges[i];
     }
   }
   return MediaByteRange();
--- a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
@@ -221,16 +221,17 @@ public:
   void ParseStbl(Box& aBox);
   void ParseStsd(Box& aBox);
   void ParseEncrypted(Box& aBox);
   void ParseSinf(Box& aBox);
 
   bool BlockingReadNextMoof();
   bool HasMetadata();
   MediaByteRange FirstCompleteMediaSegment();
+  MediaByteRange FirstCompleteMediaHeader();
 
   mozilla::MediaByteRange mInitRange;
   nsRefPtr<Stream> mSource;
   uint64_t mOffset;
   nsTArray<uint64_t> mMoofOffsets;
   Mvhd mMvhd;
   Mdhd mMdhd;
   Trex mTrex;