Bug 1074614 - Remove ChangeToHaveMetadata and WAIT_FOR_MSE_DATA frame status. r=cajbir
authorMatthew Gregan <kinetik@flim.org>
Tue, 30 Sep 2014 17:12:45 +1300
changeset 208758 88258156ffef
parent 208757 df6a28be0934
child 208759 d5eb688ed4a1
push id49994
push usermgregan@mozilla.com
push dateFri, 03 Oct 2014 20:30:05 +0000
treeherdermozilla-inbound@d5eb688ed4a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1074614
milestone35.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 1074614 - Remove ChangeToHaveMetadata and WAIT_FOR_MSE_DATA frame status. r=cajbir
content/html/content/src/HTMLMediaElement.cpp
content/media/MediaDecoderOwner.h
content/media/mediasource/MediaSourceReader.cpp
content/media/mediasource/test/mochitest.ini
content/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -3090,24 +3090,16 @@ void HTMLMediaElement::UpdateReadyStateF
 {
   if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) {
     // aNextFrame might have a next frame because the decoder can advance
     // on its own thread before MetadataLoaded gets a chance to run.
     // The arrival of more data can't change us out of this readyState.
     return;
   }
 
-  // Section 2.4.3.1 of the Media Source Extensions spec requires
-  // changing to HAVE_METADATA when seeking into an unbuffered
-  // range.
-  if (aNextFrame == MediaDecoderOwner::NEXT_FRAME_WAIT_FOR_MSE_DATA) {
-    ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
-    return;
-  }
-
   if (aNextFrame == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING) {
     ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
     return;
   }
 
   if (mDownloadSuspendedByCache && mDecoder && !mDecoder->IsEnded()) {
     // The decoder has signaled that the download has been suspended by the
     // media cache. So move readyState into HAVE_ENOUGH_DATA, in case there's
--- a/content/media/MediaDecoderOwner.h
+++ b/content/media/MediaDecoderOwner.h
@@ -109,19 +109,16 @@ public:
     NEXT_FRAME_AVAILABLE,
     // The next frame of audio/video is unavailable because the decoder
     // is paused while it buffers up data
     NEXT_FRAME_UNAVAILABLE_BUFFERING,
     // The next frame of audio/video is unavailable for the decoder is seeking.
     NEXT_FRAME_UNAVAILABLE_SEEKING,
     // The next frame of audio/video is unavailable for some other reasons
     NEXT_FRAME_UNAVAILABLE,
-    // The next frame is unavailable due to waiting for more Media Source
-    // Extensions data to become available.
-    NEXT_FRAME_WAIT_FOR_MSE_DATA,
     // Sentinel value
     NEXT_FRAME_UNINITIALIZED
   };
 
   // Called by the decoder when some data has been downloaded or
   // buffering/seeking has ended. aNextFrameAvailable is true when
   // the data for the next frame is available. This method will
   // decide whether to set the ready state to HAVE_CURRENT_DATA,
--- a/content/media/mediasource/MediaSourceReader.cpp
+++ b/content/media/mediasource/MediaSourceReader.cpp
@@ -366,35 +366,16 @@ MediaSourceReader::OnTrackBufferConfigur
   }
   if (aInfo.HasVideo() && !mVideoTrack) {
     MSE_DEBUG("MediaSourceReader(%p)::OnTrackBufferConfigured %p video", this, aTrackBuffer);
     mVideoTrack = aTrackBuffer;
   }
   mDecoder->NotifyWaitingForResourcesStatusChanged();
 }
 
-class ChangeToHaveMetadata : public nsRunnable {
-public:
-  explicit ChangeToHaveMetadata(AbstractMediaDecoder* aDecoder) :
-    mDecoder(aDecoder)
-  {
-  }
-
-  NS_IMETHOD Run() MOZ_OVERRIDE MOZ_FINAL {
-    auto owner = mDecoder->GetOwner();
-    if (owner) {
-      owner->UpdateReadyStateForData(MediaDecoderOwner::NEXT_FRAME_WAIT_FOR_MSE_DATA);
-    }
-    return NS_OK;
-  }
-
-private:
-  nsRefPtr<AbstractMediaDecoder> mDecoder;
-};
-
 void
 MediaSourceReader::WaitForTimeRange(int64_t aTime)
 {
   MSE_DEBUG("MediaSourceReader(%p)::WaitForTimeRange(%lld)", this, aTime);
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
 
   // Loop until we have the requested time range in the active TrackBuffers.
   // Ideally, this wait loop would use an async request and callback
@@ -429,21 +410,16 @@ MediaSourceReader::Seek(int64_t aTime, i
   for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
     mTrackBuffers[i]->ResetDecode();
   }
 
   // Decoding discontinuity upon seek, reset last times to seek target.
   mLastAudioTime = aTime;
   mLastVideoTime = aTime;
 
-  if (!TrackBuffersContainTime(aTime)) {
-    MSE_DEBUG("MediaSourceReader(%p)::Seek no active buffer contains target=%lld", this, aTime);
-    NS_DispatchToMainThread(new ChangeToHaveMetadata(mDecoder));
-  }
-
   WaitForTimeRange(aTime);
 
   if (IsShutdown()) {
     return NS_ERROR_FAILURE;
   }
 
   if (mAudioTrack) {
     mAudioIsSeeking = true;
--- a/content/media/mediasource/test/mochitest.ini
+++ b/content/media/mediasource/test/mochitest.ini
@@ -1,17 +1,18 @@
 [DEFAULT]
 skip-if = e10s || buildapp == 'b2g' # b2g( ReferenceError: MediaSource is not defined)
 support-files =
   mediasource.js
   seek.webm seek.webm^headers^
   seek_lowres.webm seek_lowres.webm^headers^
 
+[test_MediaSource.html]
+[test_MediaSource_disabled.html]
 [test_BufferedSeek.html]
 [test_FrameSelection.html]
-[test_MediaSource.html]
-[test_MediaSource_disabled.html]
+[test_HaveMetadataUnbufferedSeek.html]
 [test_SeekableAfterEndOfStream.html]
 [test_SeekableAfterEndOfStreamSplit.html]
 [test_SeekableBeforeEndOfStream.html]
 [test_SeekableBeforeEndOfStreamSplit.html]
 [test_SplitAppendDelay.html]
 [test_SplitAppend.html]
new file mode 100644
--- /dev/null
+++ b/content/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: seekable attribute before end of stream</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="mediasource.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm", function (arrayBuffer) {
+      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 67833));
+    });
+
+    var target = 2;
+
+    v.addEventListener("canplay", function oncanplay() {
+      v.removeEventListener("canplay", oncanplay);
+      ok(v.readyState >= v.HAVE_FUTURE_DATA, "readyState is >= FUTURE_DATA");
+      v.currentTime = target;
+    });
+
+    v.addEventListener("seeking", function () {
+      is(v.readyState, v.HAVE_METADATA, "readyState is HAVE_METADATA");
+      fetchWithXHR("seek.webm", function (arrayBuffer) {
+        sb.appendBuffer(new Uint8Array(arrayBuffer, 67833));
+      });
+    });
+
+    v.addEventListener("seeked", function () {
+      ok(v.readyState >= v.HAVE_FUTURE_DATA, "readyState is >= FUTURE_DATA");
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>