- Revision
- 273454
- Author
- alanc...@apple.com
- Date
- 2021-02-24 16:37:38 -0800 (Wed, 24 Feb 2021)
Log Message
Cherry-pick r272359. rdar://problem/74451201
[MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element
https://bugs.webkit.org/show_bug.cgi?id=221120
Reviewed by Daniel Bates.
Source/WebCore:
This patch updates the WebM parser regarding the timing to call didParseInitializationDataCallback()
based on a discussion with Jer.
Based on the spec, https://w3c.github.io/mse-byte-stream-format-webm/#webm-init-segments, "The user
agent MUST accept and ignore any elements other than an EBML Header or a Cluster that occur before,
in between, or after the Segment Information and Tracks elements." So the parser should have collected
all required information of the initialization segment when it finishes parsing the "Tracks" element.
Tests: media/media-source/media-source-webm.html
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::OnElementEnd):
(WebCore::SourceBufferParserWebM::OnClusterBegin):
LayoutTests:
* media/media-source/media-source-webm-expected.txt:
* media/media-source/media-source-webm.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272359 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-611-branch/LayoutTests/ChangeLog (273453 => 273454)
--- branches/safari-611-branch/LayoutTests/ChangeLog 2021-02-25 00:15:03 UTC (rev 273453)
+++ branches/safari-611-branch/LayoutTests/ChangeLog 2021-02-25 00:37:38 UTC (rev 273454)
@@ -1,3 +1,45 @@
+2021-02-24 Russell Epstein <repst...@apple.com>
+
+ Cherry-pick r272359. rdar://problem/74451201
+
+ [MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element
+ https://bugs.webkit.org/show_bug.cgi?id=221120
+
+ Reviewed by Daniel Bates.
+
+ Source/WebCore:
+
+ This patch updates the WebM parser regarding the timing to call didParseInitializationDataCallback()
+ based on a discussion with Jer.
+
+ Based on the spec, https://w3c.github.io/mse-byte-stream-format-webm/#webm-init-segments, "The user
+ agent MUST accept and ignore any elements other than an EBML Header or a Cluster that occur before,
+ in between, or after the Segment Information and Tracks elements." So the parser should have collected
+ all required information of the initialization segment when it finishes parsing the "Tracks" element.
+
+ Tests: media/media-source/media-source-webm.html
+
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::OnElementEnd):
+ (WebCore::SourceBufferParserWebM::OnClusterBegin):
+
+ LayoutTests:
+
+ * media/media-source/media-source-webm-expected.txt:
+ * media/media-source/media-source-webm.html:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272359 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-03 Peng Liu <peng.l...@apple.com>
+
+ [MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element
+ https://bugs.webkit.org/show_bug.cgi?id=221120
+
+ Reviewed by Daniel Bates.
+
+ * media/media-source/media-source-webm-expected.txt:
+ * media/media-source/media-source-webm.html:
+
2021-02-23 Alan Coon <alanc...@apple.com>
Cherry-pick r273158. rdar://problem/74623451
Modified: branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm-expected.txt (273453 => 273454)
--- branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm-expected.txt 2021-02-25 00:15:03 UTC (rev 273453)
+++ branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm-expected.txt 2021-02-25 00:37:38 UTC (rev 273454)
@@ -1,4 +1,4 @@
-This tests the ability of the SourceBuffer to reset the parser after an abort(). A SourceBuffer in this state should be able to accept a new initialization segment or a new media segment.
+This tests that a SourceBuffer can accept an initialization segment and a media segment and fire "update" events, and the video element fires a "resize" event after the SourceBuffer appends the initialization segment.
RUN(video.src = ""
EVENT(sourceopen)
@@ -6,10 +6,11 @@
RUN(sourceBuffer = source.addSourceBuffer(loader.type()))
RUN(sourceBuffer.appendBuffer(loader.initSegment()))
EVENT(update)
+EXPECTED (resizeEventFired == 'true') OK
+EXPECTED ((videoWidth == 320 || videoWidth == 0) == 'true') OK
+EXPECTED ((videoHeight == 240 || videoHeight == 0) == 'true') OK
Append a media segment.
RUN(sourceBuffer.appendBuffer(loader.mediaSegment(0)))
-EXPECTED (resizeEventFired == 'true') OK
-EXPECTED (videoWidth == '320') OK
-EXPECTED (videoHeight == '240') OK
+EVENT(update)
END OF TEST
Modified: branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm.html (273453 => 273454)
--- branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm.html 2021-02-25 00:15:03 UTC (rev 273453)
+++ branches/safari-611-branch/LayoutTests/media/media-source/media-source-webm.html 2021-02-25 00:37:38 UTC (rev 273454)
@@ -23,8 +23,6 @@
return new Promise(resolve => {
video.addEventListener('resize', event => {
// First resize can be 0x0
- if (video.videoWidth == 0 && video.videoHeight == 0)
- return;
resizeEventFired = true;
videoWidth = video.videoWidth;
videoHeight = video.videoHeight;
@@ -44,20 +42,22 @@
await waitFor(source, 'sourceopen');
waitForEventAndFail('error');
+ const resized = resizePromise(video);
+
run('source.duration = loader.duration()');
run('sourceBuffer = source.addSourceBuffer(loader.type())');
- const resized = resizePromise(video);
run('sourceBuffer.appendBuffer(loader.initSegment())');
-
await waitFor(sourceBuffer, 'update');
+ await resized;
+ testExpected('resizeEventFired', true);
+ testExpected('(videoWidth == 320 || videoWidth == 0)', true);
+ testExpected('(videoHeight == 240 || videoHeight == 0)', true);
+
consoleWrite('Append a media segment.')
run('sourceBuffer.appendBuffer(loader.mediaSegment(0))');
+ await waitFor(sourceBuffer, 'update');
- await resized;
- testExpected('resizeEventFired', true);
- testExpected('videoWidth', 320);
- testExpected('videoHeight', 240);
endTest();
} catch (e) {
failTest(`Caught exception: "${e}"`);
@@ -67,8 +67,8 @@
</head>
<body>
<div>
- This tests the ability of the SourceBuffer to reset the parser after an abort(). A SourceBuffer in this state should be able to accept
- a new initialization segment or a new media segment.
+ This tests that a SourceBuffer can accept an initialization segment and a media segment and fire "update" events,
+ and the video element fires a "resize" event after the SourceBuffer appends the initialization segment.
</div>
<video controls></video>
</body>
Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (273453 => 273454)
--- branches/safari-611-branch/Source/WebCore/ChangeLog 2021-02-25 00:15:03 UTC (rev 273453)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog 2021-02-25 00:37:38 UTC (rev 273454)
@@ -1,3 +1,56 @@
+2021-02-24 Russell Epstein <repst...@apple.com>
+
+ Cherry-pick r272359. rdar://problem/74451201
+
+ [MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element
+ https://bugs.webkit.org/show_bug.cgi?id=221120
+
+ Reviewed by Daniel Bates.
+
+ Source/WebCore:
+
+ This patch updates the WebM parser regarding the timing to call didParseInitializationDataCallback()
+ based on a discussion with Jer.
+
+ Based on the spec, https://w3c.github.io/mse-byte-stream-format-webm/#webm-init-segments, "The user
+ agent MUST accept and ignore any elements other than an EBML Header or a Cluster that occur before,
+ in between, or after the Segment Information and Tracks elements." So the parser should have collected
+ all required information of the initialization segment when it finishes parsing the "Tracks" element.
+
+ Tests: media/media-source/media-source-webm.html
+
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::OnElementEnd):
+ (WebCore::SourceBufferParserWebM::OnClusterBegin):
+
+ LayoutTests:
+
+ * media/media-source/media-source-webm-expected.txt:
+ * media/media-source/media-source-webm.html:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272359 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-03 Peng Liu <peng.l...@apple.com>
+
+ [MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element
+ https://bugs.webkit.org/show_bug.cgi?id=221120
+
+ Reviewed by Daniel Bates.
+
+ This patch updates the WebM parser regarding the timing to call didParseInitializationDataCallback()
+ based on a discussion with Jer.
+
+ Based on the spec, https://w3c.github.io/mse-byte-stream-format-webm/#webm-init-segments, "The user
+ agent MUST accept and ignore any elements other than an EBML Header or a Cluster that occur before,
+ in between, or after the Segment Information and Tracks elements." So the parser should have collected
+ all required information of the initialization segment when it finishes parsing the "Tracks" element.
+
+ Tests: media/media-source/media-source-webm.html
+
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::OnElementEnd):
+ (WebCore::SourceBufferParserWebM::OnClusterBegin):
+
2021-02-23 Alan Coon <alanc...@apple.com>
Cherry-pick r273264. rdar://problem/74622873
Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (273453 => 273454)
--- branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-02-25 00:15:03 UTC (rev 273453)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-02-25 00:37:38 UTC (rev 273454)
@@ -774,6 +774,16 @@
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER, "state(", oldState, "->", m_state, "), id(", metadata.id, "), size(", metadata.size, ")");
+ if (metadata.id == Id::kTracks) {
+ if (m_initializationSegmentEncountered && m_didParseInitializationDataCallback) {
+ m_callOnClientThreadCallback([this, protectedThis = makeRef(*this), initializationSegment = WTFMove(*m_initializationSegment)]() mutable {
+ m_didParseInitializationDataCallback(WTFMove(initializationSegment));
+ });
+ }
+ m_initializationSegmentEncountered = false;
+ m_initializationSegment = nullptr;
+ }
+
return Status(Status::kOkCompleted);
}
@@ -835,19 +845,6 @@
if (!action)
return Status(Status::kNotEnoughMemory);
- if (m_initializationSegmentEncountered && m_didParseInitializationDataCallback) {
- m_callOnClientThreadCallback([this, protectedThis = makeRef(*this), initializationSegment = WTFMove(*m_initializationSegment)]() mutable {
- m_didParseInitializationDataCallback(WTFMove(initializationSegment), [this, protectedThis = makeRef(*this)] {
- m_initializationSegmentIsHandledSemaphore->signal();
- });
- });
-
- // Wait until the initialization segment is handled
- m_initializationSegmentIsHandledSemaphore->wait();
- }
- m_initializationSegmentEncountered = false;
- m_initializationSegment = nullptr;
-
if (cluster.timecode.is_present())
m_currentTimecode = cluster.timecode.value();