From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- ...eiver-audio-jitterBufferTarget-stats.https.html | 18 +++ ...CRtpReceiver-jitterBufferTarget-stats-helper.js | 70 +++++++++++ .../webrtc/RTCRtpReceiver-jitterBufferTarget.html | 130 +++++++++++++++++++++ ...RtpReceiver-video-jitterBufferTarget-stats.html | 18 +++ testing/web-platform/tests/webrtc/WEB_FEATURES.yml | 4 + ...che-with-open-webrtc-connection.https.window.js | 1 + 6 files changed, 241 insertions(+) create mode 100644 testing/web-platform/tests/webrtc/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html create mode 100644 testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget-stats-helper.js create mode 100644 testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget.html create mode 100644 testing/web-platform/tests/webrtc/RTCRtpReceiver-video-jitterBufferTarget-stats.html create mode 100644 testing/web-platform/tests/webrtc/WEB_FEATURES.yml (limited to 'testing/web-platform/tests/webrtc') diff --git a/testing/web-platform/tests/webrtc/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html b/testing/web-platform/tests/webrtc/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html new file mode 100644 index 0000000000..d728ec5a9c --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html @@ -0,0 +1,18 @@ + + + +Tests RTCRtpReceiver-jitterBufferTarget verified with stats + + + + + + + diff --git a/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget-stats-helper.js b/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget-stats-helper.js new file mode 100644 index 0000000000..31d80926d3 --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget-stats-helper.js @@ -0,0 +1,70 @@ +async function measureDelayFromStats(t, receiver, cycles, targetDelay, tolerance) { + let oldInboundStats; + + for (let i = 0; i < cycles; i++) { + const statsReport = await receiver.getStats(); + const inboundStats = [...statsReport.values()].find(({type}) => type == "inbound-rtp"); + + if (inboundStats) { + if (oldInboundStats) { + const emittedCount = inboundStats.jitterBufferEmittedCount - oldInboundStats.jitterBufferEmittedCount; + + if (emittedCount) { + const delay = 1000 * (inboundStats.jitterBufferDelay - oldInboundStats.jitterBufferDelay) / emittedCount; + + if (Math.abs(delay - targetDelay) < tolerance) { + return true; + } + } + } + oldInboundStats = inboundStats; + } + await new Promise(r => t.step_timeout(r, 1000)); + } + + return false; +} + +async function applyJitterBufferTarget(t, kind, target) { + const caller = new RTCPeerConnection(); + t.add_cleanup(() => caller.close()); + const callee = new RTCPeerConnection(); + t.add_cleanup(() => callee.close()); + + const stream = await getNoiseStream({[kind]:true}); + t.add_cleanup(() => stream.getTracks().forEach(track => track.stop())); + caller.addTransceiver(stream.getTracks()[0], {streams: [stream]}); + + exchangeIceCandidates(caller, callee); + await exchangeOffer(caller, callee); + await exchangeAnswer(caller, callee); + + const receiver = callee.getReceivers()[0]; + + // Workaround for Chromium to pull audio from jitter buffer. + if (kind === "audio") { + const audio = document.createElement("audio"); + + audio.srcObject = new MediaStream([receiver.track]); + audio.play(); + } + assert_equals(receiver.jitterBufferTarget, null, + `jitterBufferTarget supported for ${kind}`); + + let result = await measureDelayFromStats(t, receiver, 5, 0, 100); + assert_true(result, 'jitter buffer is not stabilised'); + + receiver.jitterBufferTarget = target; + assert_equals(receiver.jitterBufferTarget, target, + `jitterBufferTarget increase target for ${kind}`); + + result = await measureDelayFromStats(t, receiver, 10, target, 20); + assert_true(result, 'jitterBuffer does not reach target'); + + receiver.jitterBufferTarget = 0; + assert_equals(receiver.jitterBufferTarget, 0, + `jitterBufferTarget decrease target for ${kind}`); + + result = await measureDelayFromStats(t, receiver, 10, 0, 100); + assert_true(result, 'jitter buffer delay is not back to normal'); +} diff --git a/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget.html b/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget.html new file mode 100644 index 0000000000..448162d3a2 --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCRtpReceiver-jitterBufferTarget.html @@ -0,0 +1,130 @@ + + +Tests for RTCRtpReceiver-jitterBufferTarget attribute + + + + + diff --git a/testing/web-platform/tests/webrtc/RTCRtpReceiver-video-jitterBufferTarget-stats.html b/testing/web-platform/tests/webrtc/RTCRtpReceiver-video-jitterBufferTarget-stats.html new file mode 100644 index 0000000000..022dbe70c5 --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCRtpReceiver-video-jitterBufferTarget-stats.html @@ -0,0 +1,18 @@ + + + +Tests RTCRtpReceiver-jitterBufferTarget verified with stats + + + + + + + diff --git a/testing/web-platform/tests/webrtc/WEB_FEATURES.yml b/testing/web-platform/tests/webrtc/WEB_FEATURES.yml new file mode 100644 index 0000000000..117b04f81f --- /dev/null +++ b/testing/web-platform/tests/webrtc/WEB_FEATURES.yml @@ -0,0 +1,4 @@ +features: +- name: webrtc-sctp + files: + - RTCSctpTransport-* diff --git a/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js b/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js index fe41a9cfd5..de797b3f2c 100644 --- a/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js +++ b/testing/web-platform/tests/webrtc/back-forward-cache-with-open-webrtc-connection.https.window.js @@ -4,6 +4,7 @@ // META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js // META: script=resources/webrtc-test-helpers.sub.js +// META: timeout=long 'use strict'; -- cgit v1.2.3