Diff
Modified: trunk/LayoutTests/ChangeLog (137331 => 137332)
--- trunk/LayoutTests/ChangeLog 2012-12-11 18:14:16 UTC (rev 137331)
+++ trunk/LayoutTests/ChangeLog 2012-12-11 18:23:46 UTC (rev 137332)
@@ -1,3 +1,22 @@
+2012-12-11 Aaron Colwell <[email protected]>
+
+ Update MediaSource to allow append() calls in "ended" state.
+ https://bugs.webkit.org/show_bug.cgi?id=104581
+
+ Reviewed by Eric Carlson.
+
+ - Removed old test case that verified appending in "ended" state failed.
+ - Added 3 new test cases that verify append behavior in the "ended" state.
+
+ * http/tests/media/media-source/video-media-source-add-and-remove-buffers-expected.txt:
+ * http/tests/media/media-source/video-media-source-add-and-remove-buffers.html:
+ * http/tests/media/media-source/video-media-source-append-in-ended-state-expected.txt: Added.
+ * http/tests/media/media-source/video-media-source-append-in-ended-state.html: Added.
+ * http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state-expected.txt: Added.
+ * http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state.html: Added.
+ * http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state-expected.txt: Added.
+ * http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state.html: Added.
+
2012-12-11 Robert Hogan <[email protected]>
REGRESSION(r121789): Text not wrapping in presence of floating objects
Modified: trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers-expected.txt (137331 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers-expected.txt 2012-12-11 18:14:16 UTC (rev 137331)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers-expected.txt 2012-12-11 18:23:46 UTC (rev 137332)
@@ -38,8 +38,6 @@
Test a successful append.
Test append with a null buffer.
Got expected exception Error: InvalidAccessError: DOM Exception 15
-Test append after ended.
-Got expected exception Error: InvalidStateError: DOM Exception 11
Test append after buffer has been removed.
Got expected exception Error: InvalidStateError: DOM Exception 11
END OF TEST
Modified: trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers.html (137331 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers.html 2012-12-11 18:14:16 UTC (rev 137331)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-add-and-remove-buffers.html 2012-12-11 18:23:46 UTC (rev 137332)
@@ -153,10 +153,6 @@
consoleWrite("Test append with a null buffer.");
expectExceptionOnAppend(null, DOMException.INVALID_ACCESS_ERR);
- consoleWrite("Test append after ended.");
- mediaSource.endOfStream();
- expectExceptionOnAppend(initSegment, DOMException.INVALID_STATE_ERR);
-
consoleWrite("Test append after buffer has been removed.");
mediaSource.removeSourceBuffer(segmentHelper.sourceBuffer);
expectExceptionOnAppend(initSegment, DOMException.INVALID_STATE_ERR);
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state-expected.txt (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state-expected.txt 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,9 @@
+Tests calling append() after the MediaSource has transitioned to the "ended" state.
+
+Appending initialization segment.
+EVENT(loadedmetadata)
+Appending first media segment.
+Calling endOfStream().
+Appending second media segment.
+END OF TEST
+
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state.html (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state.html (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-in-ended-state.html 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+ var segmentHelper = new MediaSourceTest.SegmentHelper(WebMSegmentInfo.testWebM);
+
+ function onSourceOpen(event)
+ {
+ event.target.removeEventListener('webkitsourceopen', onSourceOpen);
+
+ segmentHelper.addSourceBuffer();
+
+ consoleWrite("Appending initialization segment.");
+ segmentHelper.appendInitSegment();
+
+ waitForEventOnce('loadedmetadata', function()
+ {
+ try
+ {
+ consoleWrite("Appending first media segment.");
+ segmentHelper.appendMediaSegment(0);
+
+ consoleWrite("Calling endOfStream().");
+ mediaSource.endOfStream();
+
+ MediaSourceTest.expectSourceState(mediaSource, "ended");
+
+ MediaSourceTest.expectBufferedRange(mediaSource.sourceBuffers[0], [[0, 0.399]]);
+
+ consoleWrite("Appending second media segment.");
+ segmentHelper.sourceBuffer.append(segmentHelper.mediaSegments[1]);
+
+ MediaSourceTest.expectBufferedRange(mediaSource.sourceBuffers[0], [[0, 0.780]]);
+
+ MediaSourceTest.expectSourceState(mediaSource, "open");
+ }
+ catch (e)
+ {
+ failTest("Unexpected exception: " + e);
+ }
+
+ endTest();
+ });
+ }
+
+ function onLoad()
+ {
+ findMediaElement();
+
+ waitForEventAndFail('error');
+
+ segmentHelper.init(video, function(success)
+ {
+ if (!success) {
+ failTest("Failed to load segment data");
+ return;
+ }
+
+ mediaSource.addEventListener('webkitsourceopen', onSourceOpen);
+ MediaSourceTest.setSrcToMediaSourceTestURL(video);
+ });
+ }
+ </script>
+ </head>
+ <body _onload_="onLoad()">
+ <video> </video>
+ <p>Tests calling append() after the MediaSource has transitioned to the "ended" state.</p>
+ </body>
+</html>
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state-expected.txt (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state-expected.txt 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,10 @@
+Tests setting a timestampOffset and calling append() after the MediaSource has transitioned to the "ended" state.
+
+Appending initialization segment.
+EVENT(loadedmetadata)
+Appending first media segment.
+Calling endOfStream().
+Setting timestampOffset to 1.
+Appending second media segment.
+END OF TEST
+
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state.html (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state.html (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state.html 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+ var segmentHelper = new MediaSourceTest.SegmentHelper(WebMSegmentInfo.testWebM);
+
+ function onSourceOpen(event)
+ {
+ event.target.removeEventListener('webkitsourceopen', onSourceOpen);
+
+ segmentHelper.addSourceBuffer();
+ consoleWrite("Appending initialization segment.");
+ segmentHelper.appendInitSegment();
+
+ waitForEventOnce('loadedmetadata', function()
+ {
+ try
+ {
+ consoleWrite("Appending first media segment.");
+ segmentHelper.appendMediaSegment(0);
+
+ MediaSourceTest.expectBufferedRange(mediaSource.sourceBuffers[0], [[0, 0.385]]);
+
+ consoleWrite("Calling endOfStream().");
+ mediaSource.endOfStream();
+
+ MediaSourceTest.expectSourceState(mediaSource, "ended");
+
+ consoleWrite("Setting timestampOffset to 1.");
+ mediaSource.sourceBuffers[0].timestampOffset = 1;
+
+ consoleWrite("Appending second media segment.");
+ segmentHelper.sourceBuffer.append(segmentHelper.mediaSegments[1]);
+
+ MediaSourceTest.expectBufferedRange(mediaSource.sourceBuffers[0], [[0, 0.385], [1.385, 1.780]]);
+
+ MediaSourceTest.expectSourceState(mediaSource, "open");
+ }
+ catch (e)
+ {
+ failTest("Unexpected exception: " + e);
+ }
+
+ endTest();
+ });
+ }
+
+ function onLoad()
+ {
+ findMediaElement();
+
+ waitForEventAndFail('error');
+
+ segmentHelper.init(video, function(success)
+ {
+ if (!success) {
+ failTest("Failed to load segment data");
+ return;
+ }
+
+ mediaSource.addEventListener('webkitsourceopen', onSourceOpen);
+ MediaSourceTest.setSrcToMediaSourceTestURL(video);
+ });
+ }
+ </script>
+ </head>
+ <body _onload_="onLoad()">
+ <video> </video>
+ <p>Tests setting a timestampOffset and calling append() after the MediaSource has transitioned to the "ended" state.</p>
+ </body>
+</html>
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state-expected.txt (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state-expected.txt 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,9 @@
+Tests calling append() with an empty Uint8Array after the MediaSource has transitioned to the "ended" state.
+
+Appending initialization segment.
+EVENT(loadedmetadata)
+Appending first media segment.
+Calling endOfStream().
+Appending zero length Uint8Array.
+END OF TEST
+
Added: trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state.html (0 => 137332)
--- trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state.html (rev 0)
+++ trunk/LayoutTests/http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state.html 2012-12-11 18:23:46 UTC (rev 137332)
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+ var segmentHelper = new MediaSourceTest.SegmentHelper(WebMSegmentInfo.testWebM);
+
+ function onSourceOpen(event)
+ {
+ event.target.removeEventListener('webkitsourceopen', onSourceOpen);
+
+ segmentHelper.addSourceBuffer();
+
+ consoleWrite("Appending initialization segment.");
+ segmentHelper.appendInitSegment();
+
+ waitForEventOnce('loadedmetadata', function()
+ {
+ try
+ {
+ consoleWrite("Appending first media segment.");
+ segmentHelper.appendMediaSegment(0);
+
+ consoleWrite("Calling endOfStream().");
+ mediaSource.endOfStream();
+
+ MediaSourceTest.expectSourceState(mediaSource, "ended");
+
+ MediaSourceTest.expectBufferedRange(mediaSource.sourceBuffers[0], [[0, 0.399]]);
+
+ consoleWrite("Appending zero length Uint8Array.");
+ segmentHelper.sourceBuffer.append(new Uint8Array(0));
+
+ MediaSourceTest.expectSourceState(mediaSource, "open");
+ }
+ catch (e)
+ {
+ failTest("Unexpected exception: " + e);
+ }
+
+ endTest();
+ });
+ }
+
+ function onLoad()
+ {
+ findMediaElement();
+
+ waitForEventAndFail('error');
+
+ segmentHelper.init(video, function(success)
+ {
+ if (!success) {
+ failTest("Failed to load segment data");
+ return;
+ }
+
+ mediaSource.addEventListener('webkitsourceopen', onSourceOpen);
+ MediaSourceTest.setSrcToMediaSourceTestURL(video);
+ });
+ }
+ </script>
+ </head>
+ <body _onload_="onLoad()">
+ <video> </video>
+ <p>Tests calling append() with an empty Uint8Array after the MediaSource has transitioned to the "ended" state.</p>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (137331 => 137332)
--- trunk/Source/WebCore/ChangeLog 2012-12-11 18:14:16 UTC (rev 137331)
+++ trunk/Source/WebCore/ChangeLog 2012-12-11 18:23:46 UTC (rev 137332)
@@ -1,3 +1,21 @@
+2012-12-11 Aaron Colwell <[email protected]>
+
+ Update MediaSource to allow append() calls in "ended" state.
+ https://bugs.webkit.org/show_bug.cgi?id=104581
+
+ Reviewed by Eric Carlson.
+
+ Updated append and setTimestampOffset to allow appending in the "ended" readyState. An append() call
+ in the "ended" state now triggers a transition to the "open" state and allows the append to succeed.
+
+ Tests: http/tests/media/media-source/video-media-source-append-in-ended-state.html
+ http/tests/media/media-source/video-media-source-append-with-offset-in-ended-state.html
+ http/tests/media/media-source/video-media-source-zero-byte-append-in-ended-state.html
+
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::append):
+ (WebCore::MediaSource::setTimestampOffset):
+
2012-12-11 Robert Hogan <[email protected]>
REGRESSION(r121789): Text not wrapping in presence of floating objects
Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp (137331 => 137332)
--- trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2012-12-11 18:14:16 UTC (rev 137331)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2012-12-11 18:23:46 UTC (rev 137332)
@@ -281,13 +281,13 @@
return;
}
- if (!m_player || m_readyState != openKeyword()) {
+ if (!m_player || m_readyState == closedKeyword()) {
ec = INVALID_STATE_ERR;
return;
}
- if (!data->length())
- return;
+ if (m_readyState == endedKeyword())
+ setReadyState(openKeyword());
if (!m_player->sourceAppend(id, data->data(), data->length())) {
ec = SYNTAX_ERR;
@@ -308,7 +308,7 @@
bool MediaSource::setTimestampOffset(const String& id, double offset, ExceptionCode& ec)
{
- if (!m_player || m_readyState != openKeyword()) {
+ if (!m_player || m_readyState == closedKeyword()) {
ec = INVALID_STATE_ERR;
return false;
}