[MSE][GStreamer] Replaying the video should update currentTime
authoraboya@igalia.com <aboya@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Aug 2019 17:17:20 +0000 (17:17 +0000)
committeraboya@igalia.com <aboya@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Aug 2019 17:17:20 +0000 (17:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201307

Reviewed by Xabier Rodriguez-Calvar.

LayoutTests/imported/w3c:

* web-platform-tests/media-source/mediasource-replay-expected.txt: Added.
* web-platform-tests/media-source/mediasource-replay.html: Added.

Source/WebCore:

While writing a test to confirm that https://bugs.webkit.org/show_bug.cgi?id=190050
has indeed been fixed I noticed a non-conformity: when the video has
ended, right after calling .play() for a second playback currentTime
did not return zero, but the video duration.

This turned to be due to the m_isEndReached flag not being reseted on
seeks (replaying a video incurs in a seek done from multi-platform
code).

Test: imported/w3c/web-platform-tests/media-source/mediasource-replay.html

* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::seek):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

index 0185159..6f0bf8b 100644 (file)
@@ -1,3 +1,13 @@
+2019-08-30  Alicia Boya García  <aboya@igalia.com>
+
+        [MSE][GStreamer] Replaying the video should update currentTime
+        https://bugs.webkit.org/show_bug.cgi?id=201307
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * web-platform-tests/media-source/mediasource-replay-expected.txt: Added.
+        * web-platform-tests/media-source/mediasource-replay.html: Added.
+
 2019-08-30  Joonghun Park  <jh718.park@samsung.com>
 
         Import css/css-text/tab-size/tab-size.html wpt test
diff --git a/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay-expected.txt
new file mode 100644 (file)
index 0000000..05763e1
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Test replaying video after 'ended' 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay.html b/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-replay.html
new file mode 100644 (file)
index 0000000..05a8c0a
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<!-- Copyright © 2019 Igalia S.L -->
+<html>
+<head>
+    <title>MediaSource replay test case.</title>
+    <meta name="timeout" content="long">
+    <meta charset="utf-8">
+    <link rel="author" title="Alicia Boya García" href="mailto:aboya@igalia.com">
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="mediasource-util.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script>
+    mediasource_testafterdataloaded(function (test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) {
+        mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
+
+        test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
+
+        sourceBuffer.appendBuffer(mediaData);
+
+        test.waitForExpectedEvents(function () {
+            mediaSource.endOfStream();
+
+            // Start playing near the end.
+            mediaElement.currentTime = 6.2;
+            mediaElement.play();
+            test.expectEvent(mediaElement, 'ended', 'mediaElement');
+        });
+
+        test.waitForExpectedEvents(function () {
+            mediaElement.play();
+            assert_equals(mediaElement.currentTime, 0, "currentTime");
+            // If currentTime is able to advance, the player did not get stuck and it's a pass.
+            test.waitForCurrentTimeChange(mediaElement, test.step_func_done());
+        });
+    }, "Test replaying video after 'ended'");
+</script>
+</body>
+</html>
index d8ee95d..1ede0f7 100644 (file)
@@ -1,3 +1,24 @@
+2019-08-30  Alicia Boya García  <aboya@igalia.com>
+
+        [MSE][GStreamer] Replaying the video should update currentTime
+        https://bugs.webkit.org/show_bug.cgi?id=201307
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        While writing a test to confirm that https://bugs.webkit.org/show_bug.cgi?id=190050
+        has indeed been fixed I noticed a non-conformity: when the video has
+        ended, right after calling .play() for a second playback currentTime
+        did not return zero, but the video duration.
+
+        This turned to be due to the m_isEndReached flag not being reseted on
+        seeks (replaying a video incurs in a seek done from multi-platform
+        code).
+
+        Test: imported/w3c/web-platform-tests/media-source/mediasource-replay.html
+
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::seek):
+
 2019-08-30  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Make Geometry/Quirk/MarginCollapse subclasses stateful.
index 8671ce5..ac0122f 100644 (file)
@@ -144,8 +144,10 @@ MediaTime MediaPlayerPrivateGStreamerMSE::durationMediaTime() const
 
 void MediaPlayerPrivateGStreamerMSE::seek(const MediaTime& time)
 {
+    GST_DEBUG_OBJECT(pipeline(), "Seeking to %s", time.toString().utf8().data());
     m_seekTime = time;
     m_seeking = true;
+    m_isEndReached = false;
 
     webKitMediaSrcSeek(WEBKIT_MEDIA_SRC(m_source.get()), toGstClockTime(m_seekTime), m_playbackRate);