Title: [236688] releases/WebKitGTK/webkit-2.22/Source/WebCore
Revision
236688
Author
ape...@igalia.com
Date
2018-10-01 13:07:40 -0700 (Mon, 01 Oct 2018)

Log Message

Merge r236679 - [MSE][GStreamer] Set a minimum sample duration
https://bugs.webkit.org/show_bug.cgi?id=190125

Reviewed by Xabier Rodriguez-Calvar.

The last sample of the audio track in the asset used in this test
player has a tiny duration (100 ns):

http://orange-opensource.github.io/hasplayer.js/1.2.0/player.html?url=""

So small, we were truncating it to zero. We're not supposed to have
frames with zero duration. Instead, lets set a minimum frame duration
for those fringe cases.

* platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
(WebCore::MediaSampleGStreamer::MediaSampleGStreamer):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog (236687 => 236688)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-10-01 19:57:52 UTC (rev 236687)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-10-01 20:07:40 UTC (rev 236688)
@@ -1,3 +1,22 @@
+2018-10-01  Alicia Boya GarcĂ­a  <ab...@igalia.com>
+
+        [MSE][GStreamer] Set a minimum sample duration
+        https://bugs.webkit.org/show_bug.cgi?id=190125
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The last sample of the audio track in the asset used in this test
+        player has a tiny duration (100 ns):
+
+        http://orange-opensource.github.io/hasplayer.js/1.2.0/player.html?url=""
+
+        So small, we were truncating it to zero. We're not supposed to have
+        frames with zero duration. Instead, lets set a minimum frame duration
+        for those fringe cases.
+
+        * platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
+        (WebCore::MediaSampleGStreamer::MediaSampleGStreamer):
+
 2018-10-01  Olivier Blin  <olivier.b...@softathome.com>
 
         [WPE] fix buffer over-read in RenderThemeWPE::mediaControlsStyleSheet()

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp (236687 => 236688)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp	2018-10-01 19:57:52 UTC (rev 236687)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp	2018-10-01 20:07:40 UTC (rev 236688)
@@ -23,6 +23,8 @@
 
 #include "GStreamerCommon.h"
 
+#include <algorithm>
+
 #if ENABLE(VIDEO) && USE(GSTREAMER)
 
 namespace WebCore {
@@ -34,6 +36,7 @@
     , m_trackId(trackId)
     , m_presentationSize(presentationSize)
 {
+    const GstClockTime minimumDuration = 1000; // 1 us
     ASSERT(sample);
     GstBuffer* buffer = gst_sample_get_buffer(sample.get());
     RELEASE_ASSERT(buffer);
@@ -47,9 +50,14 @@
         m_pts = createMediaTime(GST_BUFFER_PTS(buffer));
     if (GST_BUFFER_DTS_IS_VALID(buffer) || GST_BUFFER_PTS_IS_VALID(buffer))
         m_dts = createMediaTime(GST_BUFFER_DTS_OR_PTS(buffer));
-    if (GST_BUFFER_DURATION_IS_VALID(buffer))
-        m_duration = createMediaTime(GST_BUFFER_DURATION(buffer));
-    else {
+    if (GST_BUFFER_DURATION_IS_VALID(buffer)) {
+        // Sometimes (albeit rarely, so far seen only at the end of a track)
+        // frames have very small durations, so small that may be under the
+        // precision we are working with and be truncated to zero.
+        // SourceBuffer algorithms are not expecting frames with zero-duration,
+        // so let's use something very small instead in those fringe cases.
+        m_duration = createMediaTime(std::max(GST_BUFFER_DURATION(buffer), minimumDuration));
+    } else {
         // Unfortunately, sometimes samples don't provide a duration. This can never happen in MP4 because of the way
         // the format is laid out, but it's pretty common in WebM.
         // The good part is that durations don't matter for playback, just for buffered ranges and coded frame deletion.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to