Changeset 242034 in webkit


Ignore:
Timestamp:
Feb 25, 2019 2:11:57 AM (5 years ago)
Author:
aboya@igalia.com
Message:

[MSE][GStreamer] Batch player duration updates
https://bugs.webkit.org/show_bug.cgi?id=194220

Reviewed by Xabier Rodriguez-Calvar.

This saves up a ton of CPU cycles doing layout unnecessarily when all
the appended frames extend the duration of the movie, like in
YTTV 2018 59.DASHLatencyVP9.

This patch is an optimization that introduces no new behavior.

  • platform/graphics/gstreamer/mse/AppendPipeline.cpp:

(WebCore::AppendPipeline::consumeAppsinkAvailableSamples):

  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:

(WebCore::MediaPlayerPrivateGStreamerMSE::blockDurationChanges):
(WebCore::MediaPlayerPrivateGStreamerMSE::unblockDurationChanges):
(WebCore::MediaPlayerPrivateGStreamerMSE::durationChanged):

  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242033 r242034  
     12019-02-25  Alicia Boya García  <aboya@igalia.com>
     2
     3        [MSE][GStreamer] Batch player duration updates
     4        https://bugs.webkit.org/show_bug.cgi?id=194220
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        This saves up a ton of CPU cycles doing layout unnecessarily when all
     9        the appended frames extend the duration of the movie, like in
     10        YTTV 2018 59.DASHLatencyVP9.
     11
     12        This patch is an optimization that introduces no new behavior.
     13
     14        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
     15        (WebCore::AppendPipeline::consumeAppsinkAvailableSamples):
     16        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
     17        (WebCore::MediaPlayerPrivateGStreamerMSE::blockDurationChanges):
     18        (WebCore::MediaPlayerPrivateGStreamerMSE::unblockDurationChanges):
     19        (WebCore::MediaPlayerPrivateGStreamerMSE::durationChanged):
     20        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
     21
    1222019-02-25  Miguel Gomez  <magomez@igalia.com>
    223
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r241587 r242034  
    513513    GRefPtr<GstSample> sample;
    514514    int batchedSampleCount = 0;
     515    // In some cases each frame increases the duration of the movie.
     516    // Batch duration changes so that if we pick 100 of such samples we don't have to run 100 times
     517    // layout for the video controls, but only once.
     518    m_playerPrivate->blockDurationChanges();
    515519    while ((sample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_appsink.get()), 0)))) {
    516520        appsinkNewSample(WTFMove(sample));
    517521        batchedSampleCount++;
    518522    }
     523    m_playerPrivate->unblockDurationChanges();
    519524
    520525    GST_TRACE_OBJECT(m_pipeline.get(), "batchedSampleCount = %d", batchedSampleCount);
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r241587 r242034  
    662662}
    663663
     664void MediaPlayerPrivateGStreamerMSE::blockDurationChanges()
     665{
     666    ASSERT(isMainThread());
     667    m_areDurationChangesBlocked = true;
     668    m_shouldReportDurationWhenUnblocking = false;
     669}
     670
     671void MediaPlayerPrivateGStreamerMSE::unblockDurationChanges()
     672{
     673    ASSERT(isMainThread());
     674    if (m_shouldReportDurationWhenUnblocking) {
     675        m_player->durationChanged();
     676        m_playbackPipeline->notifyDurationChanged();
     677        m_shouldReportDurationWhenUnblocking = false;
     678    }
     679
     680    m_areDurationChangesBlocked = false;
     681}
     682
    664683void MediaPlayerPrivateGStreamerMSE::durationChanged()
    665684{
     685    ASSERT(isMainThread());
    666686    if (!m_mediaSourceClient) {
    667687        GST_DEBUG("m_mediaSourceClient is null, doing nothing");
     
    677697    // by the HTMLMediaElement.
    678698    if (m_mediaTimeDuration != previousDuration && m_mediaTimeDuration.isValid() && previousDuration.isValid()) {
    679         m_player->durationChanged();
    680         m_playbackPipeline->notifyDurationChanged();
     699        if (!m_areDurationChangesBlocked) {
     700            m_player->durationChanged();
     701            m_playbackPipeline->notifyDurationChanged();
     702        } else
     703            m_shouldReportDurationWhenUnblocking = true;
    681704        m_mediaSource->durationChanged(m_mediaTimeDuration);
    682705    }
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h

    r241585 r242034  
    8383    void notifySeekNeedsDataForTime(const MediaTime&);
    8484
     85    void blockDurationChanges();
     86    void unblockDurationChanges();
     87
    8588private:
    8689    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     
    112115    MediaTime m_mediaTimeDuration;
    113116    bool m_mseSeekCompleted = true;
     117    bool m_areDurationChangesBlocked = false;
     118    bool m_shouldReportDurationWhenUnblocking = false;
    114119    RefPtr<PlaybackPipeline> m_playbackPipeline;
    115120};
Note: See TracChangeset for help on using the changeset viewer.