Skip to content

Commit 332c665

Browse files
committed
Clamp setCurrentTimeFromBindings to prevent negative time
https://bugs.webkit.org/show_bug.cgi?id=278646 Reviewed by Eric Carlson. Just clamp the value to avoid negative numbers when seeking. Also return in GStreamer ports infinity as maxTimeSeekable for live streams. Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm Also another bunch of tests have now corrected expectations. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/seeking/seek-to-currentTime-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time-expected.txt: * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_seek_to_eos-expected.txt: * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/video_loop_base-expected.txt: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::setCurrentTimeForBindings): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::maxTimeSeekable const): Canonical link: https://commits.webkit.org/283134@main
1 parent 021946d commit 332c665

8 files changed

Lines changed: 1897 additions & 670 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
FAIL seek to currentTime assert_greater_than: seekable ranges expected a number greater than 0 but got 0
2+
PASS seek to currentTime
33

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
FAIL seek to negative time assert_equals: currentTime after setting expected 0 but got -1
2+
PASS seek to negative time
33

LayoutTests/platform/glib/TestExpectations

Lines changed: 1886 additions & 656 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11

2-
Harness Error (TIMEOUT), message = null
3-
4-
TIMEOUT seeking to the end of looping audio Test timed out
2+
PASS seeking to the end of looping audio
53

LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time-expected.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11

2-
Harness Error (TIMEOUT), message = null
3-
4-
NOTRUN Check if video.loop is set to true that expecting the seeking event is fired more than once
2+
PASS Check if video.loop is set to true that expecting the seeking event is fired more than once
53

Source/WebCore/html/HTMLMediaElement.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,6 +3531,8 @@ ExceptionOr<void> HTMLMediaElement::setCurrentTimeForBindings(double time)
35313531
if (m_mediaController)
35323532
return Exception { InvalidStateError };
35333533

3534+
time = clampTo(time, 0.0);
3535+
35343536
if (m_readyState == HAVE_NOTHING || !m_player) {
35353537
m_defaultPlaybackStartPosition = MediaTime::createWithDouble(time);
35363538
return { };

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,12 +780,14 @@ std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateGStreamer::buffered() cons
780780

781781
MediaTime MediaPlayerPrivateGStreamer::maxMediaTimeSeekable() const
782782
{
783-
GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, isLiveStream: %s", boolForPrinting(m_didErrorOccur), boolForPrinting(m_isLiveStream));
783+
GST_TRACE_OBJECT(pipeline(), "errorOccured: %s", boolForPrinting(m_didErrorOccur));
784784
if (m_didErrorOccur)
785785
return MediaTime::zeroTime();
786786

787-
if (m_isLiveStream.value_or(false))
788-
return MediaTime::zeroTime();
787+
bool isLiveStream = m_isLiveStream.value_or(false);
788+
GST_TRACE_OBJECT(pipeline(), "isLiveStream: %s", boolForPrinting(isLiveStream));
789+
if (isLiveStream)
790+
return MediaTime::positiveInfiniteTime();
789791

790792
if (isMediaStreamPlayer())
791793
return MediaTime::zeroTime();

0 commit comments

Comments
 (0)