Skip to content
Permalink
Browse files
[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:


Canonical link: https://commits.webkit.org/209358@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ntrrgc committed Feb 25, 2019
1 parent 4df2ab7 commit 5e1a95623b8dc8fbc91afefa8e9e3d73fe7b902a
Showing 4 changed files with 56 additions and 2 deletions.
@@ -1,3 +1,24 @@
2019-02-25 Alicia Boya García <aboya@igalia.com>

[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 <magomez@igalia.com>

[WPE] Add support for holepunch using an external video player
@@ -512,10 +512,15 @@ void AppendPipeline::consumeAppsinkAvailableSamples()

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);
}
@@ -661,8 +661,28 @@ RefPtr<MediaSourceClientGStreamerMSE> MediaPlayerPrivateGStreamerMSE::mediaSourc
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 @@ void MediaPlayerPrivateGStreamerMSE::durationChanged()
// 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);
}
}
@@ -82,6 +82,9 @@ class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer {
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 @@ class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer {
RefPtr<MediaSourceClientGStreamerMSE> m_mediaSourceClient;
MediaTime m_mediaTimeDuration;
bool m_mseSeekCompleted = true;
bool m_areDurationChangesBlocked = false;
bool m_shouldReportDurationWhenUnblocking = false;
RefPtr<PlaybackPipeline> m_playbackPipeline;
};

0 comments on commit 5e1a956

Please sign in to comment.