Bug 1390443. P3 - MediaSourceDecoder::CanPlayThroughImpl() should return true when its MediaSource is ended. draft
authorJW Wang <jwwang@mozilla.com>
Thu, 17 Aug 2017 10:17:36 +0800
changeset 648088 d686c88b2dfa08b9d7f931c4f7c7830142193a5a
parent 648087 760e87b502e40577ea80b828c7c532728e273c2e
child 648089 bb3d5cd02916e6750894c8633de2375a60f7deb7
push id74618
push userjwwang@mozilla.com
push dateThu, 17 Aug 2017 07:21:25 +0000
bugs1390443
milestone57.0a1
Bug 1390443. P3 - MediaSourceDecoder::CanPlayThroughImpl() should return true when its MediaSource is ended. P1 removes the check for IsExpectingMoreData() and reveals a bug where readyState doesn't change to HAVE_ENOUGH_DATA when the MediaSource is ended. MozReview-Commit-ID: CeI3dReQibs
dom/media/mediasource/MediaSourceDecoder.cpp
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -302,24 +302,30 @@ MediaSourceDecoder::NextFrameBufferedSta
 }
 
 bool
 MediaSourceDecoder::CanPlayThroughImpl()
 {
   MOZ_ASSERT(NS_IsMainThread());
   AbstractThread::AutoEnter context(AbstractMainThread());
 
+  if (mEnded) {
+    // Return true for we have all the data.
+    return true;
+  }
+
   if (NextFrameBufferedStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE) {
     return false;
   }
 
   if (IsNaN(mMediaSource->Duration())) {
     // Don't have any data yet.
     return false;
   }
+
   TimeUnit duration = TimeUnit::FromSeconds(mMediaSource->Duration());
   auto currentPosition = CurrentPosition();
   if (duration.IsInfinite()) {
     // We can't make an informed decision and just assume that it's a live
     // stream
     return true;
   } else if (duration <= currentPosition) {
     return true;