Bug 1000608 - Populate active source buffers and fix/rename ContainsTime - r=kinetik
authorcajbir <cajbir.bugzilla@cd.pn>
Wed, 23 Apr 2014 19:44:00 +1200
changeset 180755 d75260ca4ed2296c2924ded27b1345034e889b3e
parent 180754 f398aa51c65ab6f45cc310ca0efa02c4a3724407
child 180756 169eaed7017b4a14f0e029361d729f83fcc41cca
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerskinetik
bugs1000608
milestone31.0a1
Bug 1000608 - Populate active source buffers and fix/rename ContainsTime - r=kinetik
content/media/mediasource/MediaSource.cpp
content/media/mediasource/MediaSourceDecoder.cpp
content/media/mediasource/SourceBufferList.cpp
content/media/mediasource/SourceBufferList.h
--- a/content/media/mediasource/MediaSource.cpp
+++ b/content/media/mediasource/MediaSource.cpp
@@ -170,16 +170,17 @@ MediaSource::AddSourceBuffer(const nsASt
     return nullptr;
   }
   nsRefPtr<SourceBuffer> sourceBuffer = SourceBuffer::Create(this, NS_ConvertUTF16toUTF8(mimeType));
   if (!sourceBuffer) {
     aRv.Throw(NS_ERROR_FAILURE); // XXX need a better error here
     return nullptr;
   }
   mSourceBuffers->Append(sourceBuffer);
+  mActiveSourceBuffers->Append(sourceBuffer);
   MSE_DEBUG("%p AddSourceBuffer(Type=%s) -> %p", this,
             NS_ConvertUTF16toUTF8(mimeType).get(), sourceBuffer.get());
   return sourceBuffer.forget();
 }
 
 void
 MediaSource::RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv)
 {
--- a/content/media/mediasource/MediaSourceDecoder.cpp
+++ b/content/media/mediasource/MediaSourceDecoder.cpp
@@ -417,17 +417,17 @@ MediaSourceReader::CreateSubDecoder(cons
 
 nsresult
 MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
                         int64_t aCurrentTime)
 {
   ResetDecode();
 
   dom::SourceBufferList* sbl = mMediaSource->ActiveSourceBuffers();
-  if (sbl->ContainsTime (aTime / USECS_PER_S)) {
+  if (sbl->AllContainsTime (aTime / USECS_PER_S)) {
     if (GetAudioReader()) {
       nsresult rv = GetAudioReader()->Seek(aTime, aStartTime, aEndTime, aCurrentTime);
       if (NS_FAILED(rv)) {
         return rv;
       }
     }
     if (GetVideoReader()) {
       nsresult rv = GetVideoReader()->Seek(aTime, aStartTime, aEndTime, aCurrentTime);
--- a/content/media/mediasource/SourceBufferList.cpp
+++ b/content/media/mediasource/SourceBufferList.cpp
@@ -107,24 +107,24 @@ 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)
+SourceBufferList::AllContainsTime(double aTime)
 {
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
     if (!mSourceBuffers[i]->ContainsTime(aTime)) {
       return false;
     }
   }
-  return true;
+  return mSourceBuffers.Length() > 0;
 }
 
 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
@@ -73,17 +73,17 @@ public:
 
   // 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);
+  bool AllContainsTime(double aTime);
 
 private:
   friend class AsyncEventRunner<SourceBufferList>;
   void DispatchSimpleEvent(const char* aName);
   void QueueAsyncSimpleEvent(const char* aName);
 
   nsRefPtr<MediaSource> mMediaSource;
   nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers;