Title: [242034] trunk/Source/WebCore
Revision
242034
Author
[email protected]
Date
2019-02-25 02:11:57 -0800 (Mon, 25 Feb 2019)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242033 => 242034)


--- trunk/Source/WebCore/ChangeLog	2019-02-25 09:20:01 UTC (rev 242033)
+++ trunk/Source/WebCore/ChangeLog	2019-02-25 10:11:57 UTC (rev 242034)
@@ -1,3 +1,24 @@
+2019-02-25  Alicia Boya GarcĂ­a  <[email protected]>
+
+        [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:
+
 2019-02-25  Miguel Gomez  <[email protected]>
 
         [WPE] Add support for holepunch using an external video player

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp (242033 => 242034)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2019-02-25 09:20:01 UTC (rev 242033)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2019-02-25 10:11:57 UTC (rev 242034)
@@ -512,10 +512,15 @@
 
     GRefPtr<GstSample> sample;
     int batchedSampleCount = 0;
+    // In some cases each frame increases the duration of the movie.
+    // Batch duration changes so that if we pick 100 of such samples we don't have to run 100 times
+    // layout for the video controls, but only once.
+    m_playerPrivate->blockDurationChanges();
     while ((sample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_appsink.get()), 0)))) {
         appsinkNewSample(WTFMove(sample));
         batchedSampleCount++;
     }
+    m_playerPrivate->unblockDurationChanges();
 
     GST_TRACE_OBJECT(m_pipeline.get(), "batchedSampleCount = %d", batchedSampleCount);
 }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (242033 => 242034)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2019-02-25 09:20:01 UTC (rev 242033)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2019-02-25 10:11:57 UTC (rev 242034)
@@ -661,8 +661,28 @@
     return m_mediaSourceClient;
 }
 
+void MediaPlayerPrivateGStreamerMSE::blockDurationChanges()
+{
+    ASSERT(isMainThread());
+    m_areDurationChangesBlocked = true;
+    m_shouldReportDurationWhenUnblocking = false;
+}
+
+void MediaPlayerPrivateGStreamerMSE::unblockDurationChanges()
+{
+    ASSERT(isMainThread());
+    if (m_shouldReportDurationWhenUnblocking) {
+        m_player->durationChanged();
+        m_playbackPipeline->notifyDurationChanged();
+        m_shouldReportDurationWhenUnblocking = false;
+    }
+
+    m_areDurationChangesBlocked = false;
+}
+
 void MediaPlayerPrivateGStreamerMSE::durationChanged()
 {
+    ASSERT(isMainThread());
     if (!m_mediaSourceClient) {
         GST_DEBUG("m_mediaSourceClient is null, doing nothing");
         return;
@@ -676,8 +696,11 @@
     // Avoid emiting durationchanged in the case where the previous duration was 0 because that case is already handled
     // by the HTMLMediaElement.
     if (m_mediaTimeDuration != previousDuration && m_mediaTimeDuration.isValid() && previousDuration.isValid()) {
-        m_player->durationChanged();
-        m_playbackPipeline->notifyDurationChanged();
+        if (!m_areDurationChangesBlocked) {
+            m_player->durationChanged();
+            m_playbackPipeline->notifyDurationChanged();
+        } else
+            m_shouldReportDurationWhenUnblocking = true;
         m_mediaSource->durationChanged(m_mediaTimeDuration);
     }
 }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (242033 => 242034)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2019-02-25 09:20:01 UTC (rev 242033)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2019-02-25 10:11:57 UTC (rev 242034)
@@ -82,6 +82,9 @@
     void trackDetected(RefPtr<AppendPipeline>, RefPtr<WebCore::TrackPrivateBase>, bool firstTrackDetected);
     void notifySeekNeedsDataForTime(const MediaTime&);
 
+    void blockDurationChanges();
+    void unblockDurationChanges();
+
 private:
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
@@ -111,6 +114,8 @@
     RefPtr<MediaSourceClientGStreamerMSE> m_mediaSourceClient;
     MediaTime m_mediaTimeDuration;
     bool m_mseSeekCompleted = true;
+    bool m_areDurationChangesBlocked = false;
+    bool m_shouldReportDurationWhenUnblocking = false;
     RefPtr<PlaybackPipeline> m_playbackPipeline;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to