Title: [276703] releases/WebKitGTK/webkit-2.32/Source/WebCore
- Revision
- 276703
- Author
- [email protected]
- Date
- 2021-04-28 02:36:57 -0700 (Wed, 28 Apr 2021)
Log Message
Merge r275528 - [GStreamer] At EOS, change position to match duration, not the other way around.
https://bugs.webkit.org/show_bug.cgi?id=224237
Reviewed by Philippe Normand.
The criteria used to check if playback has finished is currentTime >=
duration. Currently MediaPlayerPrivateGStreamer::didEnd() ensures this
in an awkward way: by changing the duration so that it matches
currentTime, rather than the other way around.
This meant a duration change at the end of playback most of the time,
with a slightly different duration each time, since currentTime is
cached periodically.
This patch reworks that function to work more naturally and less racy:
First, only if the stream doesn't have a set duration (e.g. live
stream), we set a duration to currentTime, as defined in the spec.
Second, at EOS we update currentTime to match duration, rather than
the other way around.
This patch doesn't introduce changes in test results.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::didEnd):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog (276702 => 276703)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog 2021-04-28 09:36:51 UTC (rev 276702)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog 2021-04-28 09:36:57 UTC (rev 276703)
@@ -1,3 +1,32 @@
+2021-04-06 Alicia Boya GarcĂa <[email protected]>
+
+ [GStreamer] At EOS, change position to match duration, not the other way around.
+ https://bugs.webkit.org/show_bug.cgi?id=224237
+
+ Reviewed by Philippe Normand.
+
+ The criteria used to check if playback has finished is currentTime >=
+ duration. Currently MediaPlayerPrivateGStreamer::didEnd() ensures this
+ in an awkward way: by changing the duration so that it matches
+ currentTime, rather than the other way around.
+
+ This meant a duration change at the end of playback most of the time,
+ with a slightly different duration each time, since currentTime is
+ cached periodically.
+
+ This patch reworks that function to work more naturally and less racy:
+
+ First, only if the stream doesn't have a set duration (e.g. live
+ stream), we set a duration to currentTime, as defined in the spec.
+
+ Second, at EOS we update currentTime to match duration, rather than
+ the other way around.
+
+ This patch doesn't introduce changes in test results.
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::didEnd):
+
2021-04-12 Philippe Normand <[email protected]>
[MSE][GStreamer] Crash in WebCore::PlaybackPipeline::addSourceBuffer when setting duration and preload is set to none
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (276702 => 276703)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2021-04-28 09:36:51 UTC (rev 276702)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2021-04-28 09:36:57 UTC (rev 276703)
@@ -2550,19 +2550,28 @@
void MediaPlayerPrivateGStreamer::didEnd()
{
- GST_INFO_OBJECT(pipeline(), "Playback ended");
-
- // Synchronize position and duration values to not confuse the
- // HTMLMediaElement. In some cases like reverse playback the
- // position is not always reported as 0 for instance.
m_cachedPosition = MediaTime::invalidTime();
MediaTime now = currentMediaTime();
- if (now > MediaTime::zeroTime() && !m_isSeeking) {
+ GST_INFO_OBJECT(pipeline(), "Playback ended, currentMediaTime = %s, duration = %s", now.toString().utf8().data(), durationMediaTime().toString().utf8().data());
+ m_isEndReached = true;
+
+ if (!durationMediaTime().isFinite()) {
+ // From the HTMLMediaElement spec.
+ // If an "infinite" stream ends for some reason, then the duration would change from positive Infinity to the
+ // time of the last frame or sample in the stream, and the durationchange event would be fired.
+ GST_DEBUG_OBJECT(pipeline(), "HTMLMediaElement duration previously infinite or unknown (e.g. live stream), setting it to current position.");
m_cachedDuration = now;
m_player->durationChanged();
}
- m_isEndReached = true;
+ // Synchronize position and duration values to not confuse the
+ // HTMLMediaElement. In some cases like reverse playback the
+ // position is not always reported as 0 for instance.
+ if (!m_isSeeking) {
+ m_cachedPosition = m_playbackRate > 0 ? durationMediaTime() : MediaTime::zeroTime();
+ GST_DEBUG("Position adjusted: %s", currentMediaTime().toString().utf8().data());
+ }
+
// Now that playback has ended it's NOT a safe time to send a SELECT_STREAMS event. In fact, as of GStreamer 1.16,
// playbin3 will crash on a GStreamer assertion (combine->sinkpad being unexpectedly null) if we try. Instead, wait
// until we get the initial STREAMS_SELECTED message one more time.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes