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
--- 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;