Bug 1000608 - Allow querying source buffers to see if they contain data for a given time - r=kinetik
authorcajbir <cajbir.bugzilla@cd.pn>
Wed, 23 Apr 2014 19:45:00 +1200
changeset 180404 1e21f55bcc9d
parent 180403 826e982173dd
child 180405 a336e673aaf5
push id26663
push userryanvm@gmail.com
push dateSun, 27 Apr 2014 01:52:51 +0000
treeherdermozilla-central@fcf19894d9f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1000608
milestone31.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 1000608 - Allow querying source buffers to see if they contain data for a given time - r=kinetik
content/media/mediasource/SourceBuffer.cpp
content/media/mediasource/SourceBuffer.h
content/media/mediasource/SourceBufferList.cpp
content/media/mediasource/SourceBufferList.h
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -485,16 +485,25 @@ SourceBuffer::Evict(double aStart, doubl
     if (end <= 0) {
       NS_WARNING("SourceBuffer::Evict failed");
       continue;
     }
     mDecoders[i]->GetResource()->EvictBefore(end);
   }
 }
 
+bool
+SourceBuffer::ContainsTime(double aTime)
+{
+  double start = 0.0;
+  double end = 0.0;
+  GetBufferedStartEndTime(&start, &end);
+  return aTime >= start && aTime <= end;
+}
+
 NS_IMPL_CYCLE_COLLECTION_INHERITED_1(SourceBuffer, DOMEventTargetHelper,
                                      mMediaSource)
 
 NS_IMPL_ADDREF_INHERITED(SourceBuffer, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(SourceBuffer, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(SourceBuffer)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
--- a/content/media/mediasource/SourceBuffer.h
+++ b/content/media/mediasource/SourceBuffer.h
@@ -104,16 +104,19 @@ public:
     return mMediaSource != nullptr;
   }
 
   void Ended();
 
   // Evict data in the source buffer in the given time range.
   void Evict(double aStart, double aEnd);
 
+  // Returns true if the data in the source buffer contains the given time.
+  bool ContainsTime(double aTime);
+
 private:
   SourceBuffer(MediaSource* aMediaSource, const nsACString& aType);
 
   friend class AsyncEventRunner<SourceBuffer>;
   void DispatchSimpleEvent(const char* aName);
   void QueueAsyncSimpleEvent(const char* aName);
 
   // Create a new decoder for mType, add it to mDecoders and update mCurrentDecoder.
--- a/content/media/mediasource/SourceBufferList.cpp
+++ b/content/media/mediasource/SourceBufferList.cpp
@@ -106,16 +106,27 @@ SourceBufferList::Remove(double aStart, 
 void
 SourceBufferList::Evict(double aStart, double aEnd)
 {
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
     mSourceBuffers[i]->Evict(aStart, aEnd);
   }
 }
 
+bool
+SourceBufferList::ContainsTime(double aTime)
+{
+  for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
+    if (!mSourceBuffers[i]->ContainsTime(aTime)) {
+      return false;
+    }
+  }
+  return true;
+}
+
 void
 SourceBufferList::Ended()
 {
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
     mSourceBuffers[i]->Ended();
   }
 }
 
--- a/content/media/mediasource/SourceBufferList.h
+++ b/content/media/mediasource/SourceBufferList.h
@@ -72,16 +72,19 @@ public:
   void Remove(double aStart, double aEnd, ErrorResult& aRv);
 
   // Mark all SourceBuffers input buffers as ended.
   void Ended();
 
   // Evicts data for the given time range from each SourceBuffer in the list.
   void Evict(double aStart, double aEnd);
 
+  // Returns true if all SourceBuffers in the list contain data for the given time.
+  bool ContainsTime(double aTime);
+
 private:
   friend class AsyncEventRunner<SourceBufferList>;
   void DispatchSimpleEvent(const char* aName);
   void QueueAsyncSimpleEvent(const char* aName);
 
   nsRefPtr<MediaSource> mMediaSource;
   nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers;
 };