Bug 1227396: P8. Replace MediaByteRange with Interval<int64_t> typedef. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 24 Nov 2015 20:37:21 +1100
changeset 274538 8a42bbaec5c597bc630e52c296fd8f3ffe5bee6c
parent 274537 c15c9f37f220e491e570fbca50edde924367b26e
child 274539 8d0d23a83e347a89692e64a1d58cbba8f7467e51
push id68621
push userjyavenard@mozilla.com
push dateMon, 30 Nov 2015 00:49:17 +0000
treeherdermozilla-inbound@fd4d78b89cc0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1227396
milestone45.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 1227396: P8. Replace MediaByteRange with Interval<int64_t> typedef. r=cpearce It's now okay to simplify.
dom/media/BufferMediaResource.h
dom/media/MediaResource.h
dom/media/mediasource/ContainerParser.cpp
dom/media/mediasource/gtest/TestContainerParser.cpp
media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
--- a/dom/media/BufferMediaResource.h
+++ b/dom/media/BufferMediaResource.h
@@ -96,17 +96,17 @@ private:
 
   virtual nsresult Open(nsIStreamListener** aStreamListener) override
   {
     return NS_ERROR_FAILURE;
   }
 
   virtual nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
   {
-    aRanges += MediaByteRange(0, mLength);
+    aRanges += MediaByteRange(0, int64_t(mLength));
     return NS_OK;
   }
 
   bool IsTransportSeekable() override { return true; }
 
   virtual const nsCString& GetContentType() const override
   {
     return mContentType;
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -127,37 +127,17 @@ private:
   TimeDuration mAccumulatedTime;
   TimeStamp    mLastStartTime;
   bool         mIsStarted;
 };
 
 // Represents a section of contiguous media, with a start and end offset.
 // Used to denote ranges of data which are cached.
 
-class MediaByteRange : public media::Interval<int64_t> {
-public:
-  typedef Interval<int64_t> BaseType;
-
-  // We can't use inherited constructors yet. So we have to duplicate the
-  // constructors found in Interval base class.
-  // all this could be later replaced with:
-  // using Interval<int64_t>::Interval;
-
-  MOZ_IMPLICIT MediaByteRange(const BaseType& aOther)
-    : BaseType(aOther)
-  {}
-  MOZ_IMPLICIT MediaByteRange(BaseType&& aOther)
-    : BaseType(Move(aOther))
-  {}
-  MediaByteRange(int64_t aStart, int64_t aEnd)
-    : media::Interval<int64_t>(aStart, aEnd)
-  {}
-  MediaByteRange() = default;
-};
-
+typedef media::Interval<int64_t> MediaByteRange;
 typedef media::IntervalSet<int64_t> MediaByteRangeSet;
 
 class RtspMediaResource;
 
 /**
  * Provides a thread-safe, seek/read interface to resources
  * loaded from a URI. Uses MediaCache to cache data received over
  * Necko's async channel API, thus resolving the mismatch between clients
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -435,17 +435,17 @@ public:
       mInitData = new MediaByteBuffer();
     } else if (!mStream || !mParser) {
       return false;
     }
 
     mResource->AppendData(aData);
     MediaByteRangeSet byteRanges;
     byteRanges +=
-      MediaByteRange(mParser->mOffset, mResource->GetLength());
+      MediaByteRange(int64_t(mParser->mOffset), mResource->GetLength());
     mParser->RebuildFragmentedIndex(byteRanges);
 
     if (initSegment || !HasCompleteInitData()) {
       MediaByteRange& range = mParser->mInitRange;
       if (range.Length()) {
         mCompleteInitSegmentRange = range;
         if (!mInitData->SetLength(range.Length(), fallible)) {
           // Super unlikely OOM
@@ -604,17 +604,17 @@ public:
                                   int64_t& aStart, int64_t& aEnd) override
   {
     // ADTS header.
     Header header;
     if (!Parse(aData, header)) {
       return false;
     }
     mHasInitData = true;
-    mCompleteInitSegmentRange = MediaByteRange(0, header.header_length);
+    mCompleteInitSegmentRange = MediaByteRange(0, int64_t(header.header_length));
 
     // Cache raw header in case the caller wants a copy.
     mInitData = new MediaByteBuffer(header.header_length);
     mInitData->AppendElements(aData->Elements(), header.header_length);
 
     // Check that we have enough data for the frame body.
     if (aData->Length() < header.frame_length) {
       MSE_DEBUGV(ADTSContainerParser, "Not enough data for %llu byte frame"
--- a/dom/media/mediasource/gtest/TestContainerParser.cpp
+++ b/dom/media/mediasource/gtest/TestContainerParser.cpp
@@ -80,13 +80,13 @@ TEST(ContainerParser, ADTSHeader) {
   EXPECT_FALSE(parser->ParseStartAndEndTimestamps(header, start, end));
 
   EXPECT_TRUE(parser->HasInitData());
   EXPECT_TRUE(parser->HasCompleteInitData());
   MediaByteBuffer* init = parser->InitData();
   ASSERT_NE(init, nullptr);
   EXPECT_EQ(init->Length(), header->Length());
 
-  EXPECT_EQ(parser->InitSegmentRange(), MediaByteRange(0, header->Length()));
+  EXPECT_EQ(parser->InitSegmentRange(), MediaByteRange(0, int64_t(header->Length())));
   // Media segment range should be empty here.
   EXPECT_EQ(parser->MediaHeaderRange(), MediaByteRange());
   EXPECT_EQ(parser->MediaSegmentRange(), MediaByteRange());
 }
--- a/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
@@ -9,18 +9,16 @@
 #include "mozilla/UniquePtr.h"
 #include "mp4_demuxer/Index.h"
 #include "mp4_demuxer/DecoderData.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "MediaInfo.h"
 #include "MediaResource.h"
 
-namespace mozilla { class MediaByteRange; }
-
 namespace stagefright { class MetaData; }
 
 namespace mp4_demuxer
 {
 
 struct StageFrightPrivate;
 
 class MP4Metadata