Bug 1421179. P3 - ComputePlaybackRate() should call mPlaybackStatistics.GetRate() instead of mPlaybackStatistics.GetRateAtLastStop(). draft
authorJW Wang <jwwang@mozilla.com>
Fri, 01 Dec 2017 12:25:00 +0800
changeset 706213 9fe3797b80193e42cb9627e808b7f33a34b84ec3
parent 706212 52c5478f9e28f67d957868b0d3852a8a2f9ad707
child 706715 70767c3472186b00a7e866a737d43530676a828d
push id91732
push userjwwang@mozilla.com
push dateFri, 01 Dec 2017 13:09:17 +0000
bugs1421179
milestone59.0a1
Bug 1421179. P3 - ComputePlaybackRate() should call mPlaybackStatistics.GetRate() instead of mPlaybackStatistics.GetRateAtLastStop(). Otherwise mPlaybackBytesPerSecond will always be zero before playback is stopped for the 1st time. This is important for a live stream where playback rate can't be calculated from the duration and resource length (-1). MozReview-Commit-ID: GEojREzHVEz
dom/media/ChannelMediaDecoder.cpp
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -406,17 +406,17 @@ ChannelMediaDecoder::ComputePlaybackRate
   int64_t length = mResource->GetLength();
   if (mozilla::IsFinite<double>(mDuration) && mDuration > 0 && length >= 0) {
     mPlaybackRateReliable = true;
     mPlaybackBytesPerSecond = length / mDuration;
     return;
   }
 
   bool reliable = false;
-  mPlaybackBytesPerSecond = mPlaybackStatistics.GetRateAtLastStop(&reliable);
+  mPlaybackBytesPerSecond = mPlaybackStatistics.GetRate(&reliable);
   mPlaybackRateReliable = reliable;
 }
 
 void
 ChannelMediaDecoder::UpdatePlaybackRate()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mResource);