Bug 1128069: [MSE] P4. Do not adjust duration to what data we may have been seen in the past. r?jwwang
With MediaSource, the duration is always known and exact. It is entirely possible that we have played data at some point, then removed that data and adjusted the duration.
MozReview-Commit-ID: HZe2yXtQfIL
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1095,17 +1095,22 @@ void MediaDecoderStateMachine::Recompute
} else if (mEstimatedDuration.Ref().isSome()) {
duration = mEstimatedDuration.Ref().ref();
} else if (mInfo.mMetadataDuration.isSome()) {
duration = mInfo.mMetadataDuration.ref();
} else {
return;
}
- if (duration < mObservedDuration.Ref()) {
+ // Only adjust the duration when an explicit duration isn't set (MSE).
+ // The duration is always exactly known with MSE and there's no need to adjust
+ // it based on what may have been seen in the past; in particular as this data
+ // may no longer exist such as when the mediasource duration was reduced.
+ if (mExplicitDuration.Ref().isNothing() &&
+ duration < mObservedDuration.Ref()) {
duration = mObservedDuration;
}
MOZ_ASSERT(duration.ToMicroseconds() >= 0);
mDuration = Some(duration);
}
void