Title: [247783] trunk
Revision
247783
Author
[email protected]
Date
2019-07-24 11:13:05 -0700 (Wed, 24 Jul 2019)

Log Message

[MSE] Reenqueue after removeCodedFrames()
https://bugs.webkit.org/show_bug.cgi?id=199749

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Before this patch, SourceBuffer::removeCodedFrames() did not trigger
an immediate reenqueue, but rather just set the `needsReenqueuing`
flag, deferring it for the next append... but there may not be another
append! In that case, the removed frames would still wrongly play.

This is the case for instance in tests where a single long media
append is done and then "cropped" with SourceBuffer.erase().

Test: media/media-source/media-source-erase-after-last-append.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::removeCodedFrames):

LayoutTests:

Added a test that checks that when an .erase() is performed after the
last append the erased frames are indeed not played.

* media/media-source/media-source-erase-after-last-append-expected.txt: Added.
* media/media-source/media-source-erase-after-last-append.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (247782 => 247783)


--- trunk/LayoutTests/ChangeLog	2019-07-24 18:08:31 UTC (rev 247782)
+++ trunk/LayoutTests/ChangeLog	2019-07-24 18:13:05 UTC (rev 247783)
@@ -1,3 +1,16 @@
+2019-07-24  Alicia Boya García  <[email protected]>
+
+        [MSE] Reenqueue after removeCodedFrames()
+        https://bugs.webkit.org/show_bug.cgi?id=199749
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Added a test that checks that when an .erase() is performed after the
+        last append the erased frames are indeed not played.
+
+        * media/media-source/media-source-erase-after-last-append-expected.txt: Added.
+        * media/media-source/media-source-erase-after-last-append.html: Added.
+
 2019-07-24  Russell Epstein  <[email protected]>
 
         Remove test expectation for fast/events/ios/keydown-keyup-keypress-keys-in-non-editable-using-chinese-keyboard.html

Added: trunk/LayoutTests/media/media-source/media-source-erase-after-last-append-expected.txt (0 => 247783)


--- trunk/LayoutTests/media/media-source/media-source-erase-after-last-append-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-erase-after-last-append-expected.txt	2019-07-24 18:13:05 UTC (rev 247783)
@@ -0,0 +1,18 @@
+
+EXPECTED (source.readyState == 'closed') OK
+EVENT(sourceopen)
+RUN(sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock"))
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(sourceBuffer.appendBuffer(syncSampleRun(0, 10)))
+EVENT(updateend)
+RUN(sourceBuffer.remove(5, Infinity))
+EVENT(updateend)
+RUN(source.endOfStream())
+{PTS({0/1 = 0.000000}), DTS({0/1 = 0.000000}), duration({1/1 = 1.000000}), flags(1), generation(0)}
+{PTS({1/1 = 1.000000}), DTS({1/1 = 1.000000}), duration({1/1 = 1.000000}), flags(0), generation(0)}
+{PTS({2/1 = 2.000000}), DTS({2/1 = 2.000000}), duration({1/1 = 1.000000}), flags(0), generation(0)}
+{PTS({3/1 = 3.000000}), DTS({3/1 = 3.000000}), duration({1/1 = 1.000000}), flags(0), generation(0)}
+{PTS({4/1 = 4.000000}), DTS({4/1 = 4.000000}), duration({1/1 = 1.000000}), flags(0), generation(0)}
+END OF TEST
+

Added: trunk/LayoutTests/media/media-source/media-source-erase-after-last-append.html (0 => 247783)


--- trunk/LayoutTests/media/media-source/media-source-erase-after-last-append.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-erase-after-last-append.html	2019-07-24 18:13:05 UTC (rev 247783)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-erase-after-last-append</title>
+    <script src=""
+    <script src=""
+    <script>
+        var source;
+        var sourceBuffer;
+        var initSegment;
+
+        if (window.internals)
+            internals.initializeMockMediaSource();
+
+        function syncSampleRun(start, end) {
+            const samples = [];
+            for (let time = start; time < end; time++)
+                samples.push(makeASample(time, time, 1, 1, 1, time === start ? SAMPLE_FLAG.SYNC : SAMPLE_FLAG.NONE));
+            return concatenateSamples(samples);
+        }
+
+        window.addEventListener('load', async () => {
+            findMediaElement();
+            source = new MediaSource();
+            testExpected('source.readyState', 'closed');
+            const sourceOpened = waitFor(source, 'sourceopen');
+
+            const videoSource = document.createElement('source');
+            videoSource.type = 'video/mock; codecs=mock';
+            videoSource.src = ""
+            video.appendChild(videoSource);
+
+            await sourceOpened;
+            run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
+
+            initSegment = makeAInit(30, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+
+            run('sourceBuffer.appendBuffer(initSegment)');
+            await waitFor(sourceBuffer, 'updateend');
+
+            run('sourceBuffer.appendBuffer(syncSampleRun(0, 10))');
+            await waitFor(sourceBuffer, 'updateend');
+
+            run('sourceBuffer.remove(5, Infinity)');
+            await waitFor(sourceBuffer, 'updateend');
+
+            run('source.endOfStream()');
+
+            // Samples with PTS >= 5 should have been deleted and not reach playback.
+            internals.enqueuedSamplesForTrackID(sourceBuffer, 1).forEach(consoleWrite);
+            endTest();
+        });
+    </script>
+</head>
+<body>
+<video controls></video>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (247782 => 247783)


--- trunk/Source/WebCore/ChangeLog	2019-07-24 18:08:31 UTC (rev 247782)
+++ trunk/Source/WebCore/ChangeLog	2019-07-24 18:13:05 UTC (rev 247783)
@@ -1,3 +1,23 @@
+2019-07-24  Alicia Boya García  <[email protected]>
+
+        [MSE] Reenqueue after removeCodedFrames()
+        https://bugs.webkit.org/show_bug.cgi?id=199749
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Before this patch, SourceBuffer::removeCodedFrames() did not trigger
+        an immediate reenqueue, but rather just set the `needsReenqueuing`
+        flag, deferring it for the next append... but there may not be another
+        append! In that case, the removed frames would still wrongly play.
+
+        This is the case for instance in tests where a single long media
+        append is done and then "cropped" with SourceBuffer.erase().
+
+        Test: media/media-source/media-source-erase-after-last-append.html
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::removeCodedFrames):
+
 2019-07-24  Jer Noble  <[email protected]>
 
         Add per-document autoplay quirk for netflix.com.

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (247782 => 247783)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2019-07-24 18:08:31 UTC (rev 247782)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2019-07-24 18:13:05 UTC (rev 247783)
@@ -832,7 +832,10 @@
 
     // 2. Let end be the end presentation timestamp for the removal range.
     // 3. For each track buffer in this source buffer, run the following steps:
-    for (auto& trackBuffer : m_trackBufferMap.values()) {
+    for (auto& trackBufferKeyValue : m_trackBufferMap) {
+        TrackBuffer& trackBuffer = trackBufferKeyValue.value;
+        AtomString trackID = trackBufferKeyValue.key;
+
         // 3.1. Let remove end timestamp be the current value of duration
         // 3.2 If this track buffer has a random access point timestamp that is greater than or equal to end, then update
         // remove end timestamp to that random access point timestamp.
@@ -884,8 +887,11 @@
         if (trackBuffer.lastEnqueuedPresentationTime.isValid() && currentMediaTime < trackBuffer.lastEnqueuedPresentationTime) {
             PlatformTimeRanges possiblyEnqueuedRanges(currentMediaTime, trackBuffer.lastEnqueuedPresentationTime);
             possiblyEnqueuedRanges.intersectWith(erasedRanges);
-            if (possiblyEnqueuedRanges.length())
+            if (possiblyEnqueuedRanges.length()) {
                 trackBuffer.needsReenqueueing = true;
+                DEBUG_LOG(LOGIDENTIFIER, "the range in removeCodedFrames() includes already enqueued samples, reenqueueing from ", currentMediaTime);
+                reenqueueMediaForTime(trackBuffer, trackID, currentMediaTime);
+            }
         }
 
         erasedRanges.invert();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to