Skip to content
Permalink
Browse files
[GStreamer][MSE] Player stalling too soon
https://bugs.webkit.org/show_bug.cgi?id=205117

Reviewed by Xabier Rodriguez-Calvar.

LayoutTests/imported/w3c:

Added the testcase used to report the bug, cleaned and adapted for
WPT.

* web-platform-tests/media-source/mediasource-h264-play-starved.html: Added.
* web-platform-tests/media-source/mp4/h264-starvation-init.mp4: Added.
* web-platform-tests/media-source/mp4/h264-starvation-media.mp4: Added.

Tools:

Backported patch to jhbuild.

Small modifications were necessary to make it apply on 1.16.1.

* gstreamer/jhbuild.modules:
* gstreamer/patches/libav-0001-gstavviddec-Limit-default-number-of-decoder-threads.patch: Added.


Canonical link: https://commits.webkit.org/218871@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ntrrgc committed Jan 3, 2020
1 parent 103532a commit 15a65239d70932bddbbd7386239e52b011dfa391
Showing 7 changed files with 130 additions and 1 deletion.
@@ -1,3 +1,17 @@
2020-01-03 Alicia Boya García <aboya@igalia.com>

[GStreamer][MSE] Player stalling too soon
https://bugs.webkit.org/show_bug.cgi?id=205117

Reviewed by Xabier Rodriguez-Calvar.

Added the testcase used to report the bug, cleaned and adapted for
WPT.

* web-platform-tests/media-source/mediasource-h264-play-starved.html: Added.
* web-platform-tests/media-source/mp4/h264-starvation-init.mp4: Added.
* web-platform-tests/media-source/mp4/h264-starvation-media.mp4: Added.

2020-01-03 Rob Buis <rbuis@igalia.com>

<link> with non-CSS type should not be retrieved
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<title>Test MediaSource behavior when the decoder is starved.</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="timeout" content="long">
<link rel="author" title="Alicia Boya García" href="mailto:aboya@igalia.com"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
</head>
<body>
<div id="log"></div>
<script>
mediasource_test(function (test, video, mediaSource) {
if (!MediaSource.isTypeSupported('video/mp4; codecs="avc1.4d001e"')) {
// Format not supported, nothing to test in this platform.
test.done();
return;
}

let initSegment;
let mediaSegment;

const videoSB = mediaSource.addSourceBuffer('video/mp4; codecs="avc1.4d001e"');

MediaSourceUtil.loadBinaryData(test, "mp4/h264-starvation-init.mp4", initDownloaded);

function initDownloaded(data) {
initSegment = data;
MediaSourceUtil.loadBinaryData(test, "mp4/h264-starvation-media.mp4", mediaDownloaded);
}

function mediaDownloaded(data) {
mediaSegment = data;
videoSB.appendBuffer(initSegment);
videoSB.addEventListener("updateend", initSegmentAppended);
}

function initSegmentAppended() {
videoSB.removeEventListener("updateend", initSegmentAppended);
videoSB.appendBuffer(mediaSegment);
videoSB.addEventListener("updateend", mediaSegmentAppended)
}

function mediaSegmentAppended() {
video.play();

video.addEventListener('timeupdate', function onTimeUpdate() {
if (video.currentTime >= 2)
test.done();
});
}
}, "Enough frames are played when the decoder is starved.")
</script>
</body>
</html>
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,17 @@
2020-01-03 Alicia Boya García <aboya@igalia.com>

[GStreamer][MSE] Player stalling too soon
https://bugs.webkit.org/show_bug.cgi?id=205117

Reviewed by Xabier Rodriguez-Calvar.

Backported patch to jhbuild.

Small modifications were necessary to make it apply on 1.16.1.

* gstreamer/jhbuild.modules:
* gstreamer/patches/libav-0001-gstavviddec-Limit-default-number-of-decoder-threads.patch: Added.

2020-01-02 Alex Christensen <achristensen@webkit.org>

Add SPI to disable CORS on requests to URLs matching a pattern
@@ -107,7 +107,9 @@
<dep package="gst-plugins-base"/>
<dep package="ffmpeg"/>
</dependencies>
<branch hash="sha256:e8a5748ae9a4a7be9696512182ea9ffa6efe0be9b7976916548e9d4381ca61c4" module="gst-libav/gst-libav-${version}.tar.xz" repo="gstreamer" version="1.16.1" />
<branch hash="sha256:e8a5748ae9a4a7be9696512182ea9ffa6efe0be9b7976916548e9d4381ca61c4" module="gst-libav/gst-libav-${version}.tar.xz" repo="gstreamer" version="1.16.1">
<patch file="libav-0001-gstavviddec-Limit-default-number-of-decoder-threads.patch" strip="1"/> <!-- Merged, should be shipped in 1.16.3 https://gitlab.freedesktop.org/gstreamer/gst-libav/merge_requests/56 -->
</branch>
</meson>

<meson id="gstreamer-vaapi" mesonargs="-Dgtk_doc=disabled -Dexamples=disabled">
@@ -0,0 +1,42 @@
From b7d450b11834d0a510fdcb661ce105860338e2d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alicia=20Boya=20Garc=C3=ADa?= <ntrrgc@gmail.com>
Date: Thu, 19 Dec 2019 17:58:56 +0100
Subject: [PATCH] gstavviddec: Limit default number of decoder threads

When the `max-threads` property is not specified, GStreamer defaults to
the amount of CPU threads in the system.

The number of threads used in avdec has a direct impact on the latency
of the decoder, which is of as many frames as threads. Therefore, big
numbers of threads can make latency levels that can be problematic in
some applications.

For this reason, ffmpeg emits a warning when more than 16 threads are
requested.

This patch limits the default number of threads to 16. This affects only
computers with more than 16 CPU threads when using avviddec without
setting `max-threads`.

Backport for 1.16.1.
---
ext/libav/gstavviddec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c
index 650de2d..edde934 100644
--- a/ext/libav/gstavviddec.c
+++ b/ext/libav/gstavviddec.c
@@ -494,7 +494,8 @@

if (ffmpegdec->max_threads == 0) {
if (!(oclass->in_plugin->capabilities & AV_CODEC_CAP_AUTO_THREADS))
- ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
+ ffmpegdec->context->thread_count =
+ MIN (gst_ffmpeg_auto_max_threads (), 16);
else
ffmpegdec->context->thread_count = 0;
} else
--
2.23.0

0 comments on commit 15a6523

Please sign in to comment.