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 180407 d75260ca4ed2
parent 180406 f398aa51c65a
child 180408 169eaed7017b
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 - 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;