Bug 1080461 - Part 2: Fix RTSP autoplay. r=bechen, r=jwwang
authorJonathan Hao <jhao@mozilla.com>
Tue, 06 Jan 2015 09:58:04 +0800
changeset 248074 2b1854f193f9d7f85854122c0b4e2388746ca3be
parent 248073 c5075104363d7a8299868a9bcd7ba51325fbcba9
child 248075 8e5920cdf87b89bdc578ccf085e63f017bf22c94
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbechen, jwwang
bugs1080461
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1080461 - Part 2: Fix RTSP autoplay. r=bechen, r=jwwang
dom/media/MediaDecoder.cpp
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1556,17 +1556,20 @@ void MediaDecoder::UnpinForSeek()
   }
   mPinnedForSeek = false;
   resource->Unpin();
 }
 
 bool MediaDecoder::CanPlayThrough()
 {
   Statistics stats = GetStatistics();
-  if ((stats.mTotalBytes < 0 && stats.mDownloadRateReliable) ||
+
+  NS_ASSERTION(mDecoderStateMachine, "CanPlayThrough should have state machine!");
+  if (mDecoderStateMachine->IsRealTime() ||
+      (stats.mTotalBytes < 0 && stats.mDownloadRateReliable) ||
       (stats.mTotalBytes >= 0 && stats.mTotalBytes == stats.mDownloadPosition)) {
     return true;
   }
   if (!stats.mDownloadRateReliable || !stats.mPlaybackRateReliable) {
     return false;
   }
   int64_t bytesToDownload = stats.mTotalBytes - stats.mDownloadPosition;
   int64_t bytesToPlayback = stats.mTotalBytes - stats.mPlaybackPosition;
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1987,16 +1987,22 @@ MediaDecoderStateMachine::StartAudioThre
 int64_t MediaDecoderStateMachine::AudioDecodedUsecs()
 {
   NS_ASSERTION(HasAudio(),
                "Should only call AudioDecodedUsecs() when we have audio");
   // The amount of audio we have decoded is the amount of audio data we've
   // already decoded and pushed to the hardware, plus the amount of audio
   // data waiting to be pushed to the hardware.
   int64_t pushed = (mAudioEndTime != -1) ? (mAudioEndTime - GetMediaTime()) : 0;
+
+  // Currently for real time streams, AudioQueue().Duration() produce
+  // wrong values (Bug 1114434), so we use frame counts to calculate duration.
+  if (IsRealTime()) {
+    return pushed + FramesToUsecs(AudioQueue().FrameCount(), mInfo.mAudio.mRate).value();
+  }
   return pushed + AudioQueue().Duration();
 }
 
 bool MediaDecoderStateMachine::HasLowDecodedData(int64_t aAudioUsecs)
 {
   AssertCurrentThreadInMonitor();
   MOZ_ASSERT(mReader->UseBufferingHeuristics());
   // We consider ourselves low on decoded data if we're low on audio,