Bug 1368837 - Implement SourceBufferResource::GetCachedDataEnd - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 29 May 2017 14:51:08 +1200
changeset 409834 d7836ae27b65d4e511d3bf047380e1fb83124002
parent 409833 e38d5530bf2b18ee63a7b3a1f7633376a0ce0969
child 409835 a341e170f306d01a9ade7eba3158edfe1c50995c
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1368837
milestone55.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 1368837 - Implement SourceBufferResource::GetCachedDataEnd - r=cpearce MediaResourceIndex caching requires GetCachedDataEnd and ReadFromCache. Implementing SourceBufferResource::GetCachedDataEnd is trivial, as it's just a buffer from 0 to GetLength(), so if the requested cached-data offset is inside the buffer, we can just return the total length as known cached data. MozReview-Commit-ID: 1DO0PzDnjQp
dom/media/mediasource/SourceBufferResource.h
--- a/dom/media/mediasource/SourceBufferResource.h
+++ b/dom/media/mediasource/SourceBufferResource.h
@@ -79,18 +79,24 @@ public:
       return mInputBuffer.GetOffset();
     } else if (aOffset == GetLength()) {
       return -1;
     }
     return aOffset;
   }
   int64_t GetCachedDataEnd(int64_t aOffset) override
   {
-    UNIMPLEMENTED();
-    return -1;
+    MOZ_ASSERT(OnTaskQueue());
+    MOZ_ASSERT(aOffset >= 0);
+    if (uint64_t(aOffset) < mInputBuffer.GetOffset() ||
+        aOffset >= GetLength()) {
+      // aOffset is outside of the buffered range.
+      return aOffset;
+    }
+    return GetLength();
   }
   bool IsDataCachedToEndOfResource(int64_t aOffset) override { return false; }
   bool IsSuspendedByCache() override
   {
     UNIMPLEMENTED();
     return false;
   }
   bool IsSuspended() override