From a49d3e67b7983841f991c3067409b850164ef52d Mon Sep 17 00:00:00 2001 From: Chris Double Date: Wed, 19 Nov 2014 16:00:09 +1300 Subject: [PATCH] Backout e62c37b8e6b5 for Mulet test failure --- dom/media/mediasource/MediaSource.cpp | 8 ++- dom/media/mediasource/SourceBuffer.cpp | 11 +--- dom/media/mediasource/SourceBuffer.h | 3 -- dom/media/mediasource/SourceBufferList.cpp | 9 ++-- dom/media/mediasource/SourceBufferList.h | 5 +- dom/media/mediasource/test/mochitest.ini | 2 - .../mediasource/test/test_BufferedSeek.html | 10 +--- .../mediasource/test/test_EndOfStream.html | 50 ------------------- .../mediasource/test/test_FrameSelection.html | 10 ++-- .../mediasource/test/test_MediaSource.html | 14 ++---- .../test/test_SeekableAfterEndOfStream.html | 10 +--- .../test_SeekableAfterEndOfStreamSplit.html | 2 +- .../mediasource/test/test_SplitAppend.html | 10 ++-- .../test/test_SplitAppendDelay.html | 10 ++-- 14 files changed, 35 insertions(+), 119 deletions(-) delete mode 100644 dom/media/mediasource/test/test_EndOfStream.html diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index a41fe9eb254..6a45d1118cb 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -418,10 +418,14 @@ void MediaSource::DurationChange(double aOldDuration, double aNewDuration) { MOZ_ASSERT(NS_IsMainThread()); - MSE_DEBUG("MediaSource(%p)::DurationChange(aOldDuration=%f, aNewDuration=%f)", this, aOldDuration, aNewDuration); + MSE_DEBUG("MediaSource(%p)::DurationChange(aNewDuration=%f)", this, aNewDuration); if (aNewDuration < aOldDuration) { - mSourceBuffers->RangeRemoval(aNewDuration, aOldDuration); + ErrorResult rv; + mSourceBuffers->Remove(aNewDuration, aOldDuration, rv); + if (rv.Failed()) { + return; + } } // TODO: If partial audio frames/text cues exist, clamp duration based on mSourceBuffers. } diff --git a/dom/media/mediasource/SourceBuffer.cpp b/dom/media/mediasource/SourceBuffer.cpp index 838e02c56ba..320e2a6559e 100644 --- a/dom/media/mediasource/SourceBuffer.cpp +++ b/dom/media/mediasource/SourceBuffer.cpp @@ -188,19 +188,10 @@ SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv) aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return; } - if (mUpdating) { + if (mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } - if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) { - mMediaSource->SetReadyState(MediaSourceReadyState::Open); - } - RangeRemoval(aStart, aEnd); -} - -void -SourceBuffer::RangeRemoval(double aStart, double aEnd) -{ StartUpdating(); /// TODO: Run coded frame removal algorithm. diff --git a/dom/media/mediasource/SourceBuffer.h b/dom/media/mediasource/SourceBuffer.h index 88a6f892a1d..5be60b50a21 100644 --- a/dom/media/mediasource/SourceBuffer.h +++ b/dom/media/mediasource/SourceBuffer.h @@ -108,9 +108,6 @@ public: double GetBufferedStart(); double GetBufferedEnd(); - // Runs the range removal algorithm as defined by the MSE spec. - void RangeRemoval(double aStart, double aEnd); - #if defined(DEBUG) void Dump(const char* aPath); #endif diff --git a/dom/media/mediasource/SourceBufferList.cpp b/dom/media/mediasource/SourceBufferList.cpp index 041fbb80ed9..d833bc9ddbc 100644 --- a/dom/media/mediasource/SourceBufferList.cpp +++ b/dom/media/mediasource/SourceBufferList.cpp @@ -108,12 +108,15 @@ SourceBufferList::AnyUpdating() } void -SourceBufferList::RangeRemoval(double aStart, double aEnd) +SourceBufferList::Remove(double aStart, double aEnd, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); - MSE_DEBUG("SourceBufferList(%p)::RangeRemoval(aStart=%f, aEnd=%f", this, aStart, aEnd); + MSE_DEBUG("SourceBufferList(%p)::Remove(aStart=%f, aEnd=%f", this, aStart, aEnd); for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) { - mSourceBuffers[i]->RangeRemoval(aStart, aEnd); + mSourceBuffers[i]->Remove(aStart, aEnd, aRv); + if (aRv.Failed()) { + return; + } } } diff --git a/dom/media/mediasource/SourceBufferList.h b/dom/media/mediasource/SourceBufferList.h index de02b914a43..ca5087f2ea2 100644 --- a/dom/media/mediasource/SourceBufferList.h +++ b/dom/media/mediasource/SourceBufferList.h @@ -66,8 +66,9 @@ public: // Returns true if updating is true on any SourceBuffers in the list. bool AnyUpdating(); - // Runs the range removal steps from the MSE specification on each SourceBuffer. - void RangeRemoval(double aStart, double aEnd); + // Calls Remove(aStart, aEnd) on each SourceBuffer in the list. Aborts on + // first error, with result returned in aRv. + void Remove(double aStart, double aEnd, ErrorResult& aRv); // Mark all SourceBuffers input buffers as ended. void Ended(); diff --git a/dom/media/mediasource/test/mochitest.ini b/dom/media/mediasource/test/mochitest.ini index 76b2561e336..9d527391816 100644 --- a/dom/media/mediasource/test/mochitest.ini +++ b/dom/media/mediasource/test/mochitest.ini @@ -9,8 +9,6 @@ support-files = [test_MediaSource_disabled.html] [test_BufferedSeek.html] [test_BufferingWait.html] -[test_EndOfStream.html] -skip-if = (toolkit == 'android') #timeout android only bug 1101187 [test_FrameSelection.html] [test_HaveMetadataUnbufferedSeek.html] [test_LoadedMetadataFired.html] diff --git a/dom/media/mediasource/test/test_BufferedSeek.html b/dom/media/mediasource/test/test_BufferedSeek.html index 949fee773b7..b800a573576 100644 --- a/dom/media/mediasource/test/test_BufferedSeek.html +++ b/dom/media/mediasource/test/test_BufferedSeek.html @@ -12,8 +12,6 @@ SimpleTest.waitForExplicitFinish(); -var updateCount = 0; - runWithMSE(function (ms, v) { ms.addEventListener("sourceopen", function () { var sb = ms.addSourceBuffer("video/webm"); @@ -21,13 +19,7 @@ runWithMSE(function (ms, v) { fetchWithXHR("seek.webm", function (arrayBuffer) { sb.appendBuffer(new Uint8Array(arrayBuffer)); sb.addEventListener("updateend", function () { - updateCount++; - /* Ensure that we endOfStream on the first update event only as endOfStream can - raise more if the duration of the last buffered range and the intial duration - differ. See bug 1065207 */ - if (updateCount == 1) { - ms.endOfStream(); - }; + ms.endOfStream() }); }); diff --git a/dom/media/mediasource/test/test_EndOfStream.html b/dom/media/mediasource/test/test_EndOfStream.html deleted file mode 100644 index 655d21cd320..00000000000 --- a/dom/media/mediasource/test/test_EndOfStream.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - MSE: endOfStream call after an appendBuffer - - - - - -
-
-
- - diff --git a/dom/media/mediasource/test/test_FrameSelection.html b/dom/media/mediasource/test/test_FrameSelection.html index bb2634c706a..d75d8f7dded 100644 --- a/dom/media/mediasource/test/test_FrameSelection.html +++ b/dom/media/mediasource/test/test_FrameSelection.html @@ -12,8 +12,6 @@ SimpleTest.waitForExplicitFinish(); -var updateCount = 0; - runWithMSE(function (ms, v) { ms.addEventListener("sourceopen", function () { var sb = ms.addSourceBuffer("video/webm"); @@ -36,13 +34,13 @@ runWithMSE(function (ms, v) { fetchWithXHR("seek_lowres.webm", function (arrayBuffer) { // Append initialization segment. sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438)); + var first = true; sb.addEventListener("updateend", function () { - updateCount++; - if (updateCount == 1) { + if (first) { // Append media segment covering range [2, 4]. sb.appendBuffer(new Uint8Array(arrayBuffer, 51003)); - } - else if (updateCount == 2) { + first = false; + } else { ms.endOfStream(); target = targets.shift(); v.currentTime = target.currentTime; diff --git a/dom/media/mediasource/test/test_MediaSource.html b/dom/media/mediasource/test/test_MediaSource.html index 53c03cefa13..131d64b1c48 100644 --- a/dom/media/mediasource/test/test_MediaSource.html +++ b/dom/media/mediasource/test/test_MediaSource.html @@ -57,12 +57,7 @@ runWithMSE(function () { sb.addEventListener("update", function () { is(sb.updating, false, "SourceBuffer.updating is expected value in update event"); updateCount++; - /* Ensure that we endOfStream on the first update event only as endOfStream can - raise more if the duration of the last buffered range and the intial duration - differ. See bug 1065207 */ - if (updateCount == 1) { - ms.endOfStream(); - } + ms.endOfStream(); }); sb.addEventListener("updatestart", function () { @@ -89,10 +84,9 @@ runWithMSE(function () { // XXX: Duration should be exactly 4.0, see bug 1065207. ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration"); ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end"); - // XXX: 2 update events can be received dueto duration differences, see bug 1065207. - ok(updateCount == 1 || updateCount == 2, "update event received"); - ok(updateendCount == 1 || updateendCount == 2, "updateend event received"); - ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received"); + is(updateCount, 1, "update event received"); + is(updateendCount, 1, "updateend event received"); + is(updatestartCount, 1, "updatestart event received"); is(loadedmetadataCount, 1, "loadedmetadata event received"); v.parentNode.removeChild(v); SimpleTest.finish(); diff --git a/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html b/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html index 850434429a2..7ffe6868668 100644 --- a/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html +++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html @@ -12,8 +12,6 @@ SimpleTest.waitForExplicitFinish(); -var updateCount = 0; - runWithMSE(function (ms, v) { ms.addEventListener("sourceopen", function () { var sb = ms.addSourceBuffer("video/webm"); @@ -21,13 +19,7 @@ runWithMSE(function (ms, v) { fetchWithXHR("seek.webm", function (arrayBuffer) { sb.appendBuffer(new Uint8Array(arrayBuffer)); sb.addEventListener("updateend", function () { - updateCount++; - /* Ensure that we endOfStream on the first update event only as endOfStream can - raise more if the duration of the last buffered range and the intial duration - differ. See bug 1065207 */ - if (updateCount == 1) { - ms.endOfStream(); - }; + ms.endOfStream() }); }); diff --git a/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html b/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html index 771f9b159a6..5f75f11ffec 100644 --- a/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html +++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html @@ -24,7 +24,7 @@ runWithMSE(function (ms, v) { if (updateCount == 1) { sb.appendBuffer(new Uint8Array(arrayBuffer, 25223)); } - else if (updateCount == 2) { + else { ms.endOfStream(); } }); diff --git a/dom/media/mediasource/test/test_SplitAppend.html b/dom/media/mediasource/test/test_SplitAppend.html index e87bd00edca..f743032080d 100644 --- a/dom/media/mediasource/test/test_SplitAppend.html +++ b/dom/media/mediasource/test/test_SplitAppend.html @@ -12,20 +12,18 @@ SimpleTest.waitForExplicitFinish(); -var updateCount = 0; - 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, 318)); + var first = true; sb.addEventListener("updateend", function () { - updateCount++; - if (updateCount == 1) { + if (first) { sb.appendBuffer(new Uint8Array(arrayBuffer, 318)); - } - else if (updateCount == 2) { + first = false; + } else { ms.endOfStream(); } }); diff --git a/dom/media/mediasource/test/test_SplitAppendDelay.html b/dom/media/mediasource/test/test_SplitAppendDelay.html index f4604b3d0c1..10dde8b8156 100644 --- a/dom/media/mediasource/test/test_SplitAppendDelay.html +++ b/dom/media/mediasource/test/test_SplitAppendDelay.html @@ -12,22 +12,20 @@ SimpleTest.waitForExplicitFinish(); -var updateCount = 0; - 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, 318)); + var first = true; sb.addEventListener("updateend", function () { - updateCount++; - if (updateCount == 1) { + if (first) { window.setTimeout(function () { sb.appendBuffer(new Uint8Array(arrayBuffer, 318)); + first = false; }, 1000); - } - else if (updateCount == 2) { + } else { ms.endOfStream(); } });