Skip to content

Commit

Permalink
Cherry-pick 274643@main (3e214ab). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=269203

    [GStreamer] Buffer end equals video duration for progressive video
    https://bugs.webkit.org/show_bug.cgi?id=269203

    Reviewed by Philippe Normand.

    On some long regular videos, the current buffer management mechanism
    reports 100% of the video as loaded when that's not actually happening.
    This causes document.getElementsByTagName('video')[0].buffered.end(0) to
    be equal to document.getElementsByTagName('video')[0].duration when that
    should clearly not the case.

    The current default way of computing m_maxTimeLoaded isn't working
    properly because oftern, when the buffering messages are received by
    MediaPlayerPrivateGStreamer, the duration is still unknown and the code
    in charge of computing the fill status bails out.

    The WebKitWebSrc network downloading statistics provide a much more
    accurate source of information for the buffered data, and should be used
    in more cases when available. The download statistics tend to arrive
    later than the buffer fill messages and at that moment duration is
    already available, leading to a proper computation of m_maxTimeLoaded.

    See: WebPlatformForEmbedded/WPEWebKit#1238

    This patch calls updateMaxTimeLoaded() when the network statistics are
    received. That update must be done here because the current system in
    place to perform such update is based on m_fillTimer, and when the
    network stats are received the timer is usually already stopped. This
    method works fine both with on-disk cache and without it (the typical
    use case on set-top-box devices).

    Original patch authored by: suresh-khurdiya-epam <skhurdiya.contractor@libertyglobal.com>

    * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
    (WebCore::MediaPlayerPrivateGStreamer::handleMessage): When a webkit-network-statistics message is received, compute the fill status and update m_maxTimeLoaded.

    Canonical link: https://commits.webkit.org/274643@main
  • Loading branch information
eocanha authored and aperezdc committed Feb 20, 2024
1 parent 22216da commit dc51c55
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2063,8 +2063,18 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
}
}
} else if (gst_structure_has_name(structure, "webkit-network-statistics")) {
if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr))
if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr)) {
GST_LOG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize);

auto mediaDuration = MediaTime::createWithDouble(duration());

// Update maxTimeLoaded only if the media duration is available. Otherwise we can't compute it.
if (mediaDuration && m_httpResponseTotalSize) {
const double fillStatus = 100.0 * (static_cast<double>(m_networkReadPosition) / static_cast<double>(m_httpResponseTotalSize));
updateMaxTimeLoaded(fillStatus);
GST_DEBUG("Updated maxTimeLoaded base on network read position: %s", m_maxTimeLoaded.toString().utf8().data());
}
}
} else if (gst_structure_has_name(structure, "GstCacheDownloadComplete")) {
GST_INFO_OBJECT(pipeline(), "Stream is fully downloaded, stopping monitoring downloading progress.");
m_fillTimer.stop();
Expand Down

0 comments on commit dc51c55

Please sign in to comment.