Bug 1382557 - the duration should be finite when we can get one from the metadata. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 25 Jul 2017 14:34:59 +0800
changeset 615731 63e78b015c666973b993c2a016503c3a1723b9cb
parent 614808 dcfb58fcb6dd8f6474eed6520ba6272dedded393
child 639254 5aa7dd3a8c2335be839a1b724a7925b1b8b681af
push id70446
push userjwwang@mozilla.com
push dateWed, 26 Jul 2017 08:49:10 +0000
bugs1382557
milestone56.0a1
Bug 1382557 - the duration should be finite when we can get one from the metadata. This fixes the case where ChannelMediaResource::OnStartRequest() calls mCallback->SetInfinite(true) to report an infinite duration, yet later we get another duratoin from the metadata. http://searchfox.org/mozilla-central/rev/8a61c71153a79cda2e1ae7d477564347c607cc5f/dom/media/MediaDecoder.cpp#1179-1185 Note IsInfinite() is checked before other duration sources. We need to call SetInfinite(false) on the MediaDecoder so we can get the correct duration. MozReview-Commit-ID: 3BlFNJzlgXo
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -758,16 +758,21 @@ MediaDecoder::MetadataLoaded(UniquePtr<M
   // Invalidate() will end up calling GetOwner()->UpdateMediaSize with the last
   // dimensions retrieved from the video frame container. The video frame
   // container contains more up to date dimensions than aInfo.
   // So we call Invalidate() after calling GetOwner()->MetadataLoaded to ensure
   // the media element has the latest dimensions.
   Invalidate();
 
   EnsureTelemetryReported();
+
+  // The duration is no longer infinite when we get one from the metadata.
+  if (mInfo->mMetadataDuration && IsInfinite()) {
+    SetInfinite(false);
+  }
 }
 
 void
 MediaDecoder::EnsureTelemetryReported()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mTelemetryReported || !mInfo) {