summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc-extensions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /testing/web-platform/tests/webrtc-extensions
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc-extensions')
-rw-r--r--testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html18
-rw-r--r--testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats-helper.js70
-rw-r--r--testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats.html96
-rw-r--r--testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-video-jitterBufferTarget-stats.html18
4 files changed, 106 insertions, 96 deletions
diff --git a/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html
new file mode 100644
index 0000000000..d728ec5a9c
--- /dev/null
+++ b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-audio-jitterBufferTarget-stats.https.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>Tests RTCRtpReceiver-jitterBufferTarget verified with stats</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/webrtc/RTCPeerConnection-helper.js"></script>
+<script src="/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats-helper.js"></script>
+<body>
+<script>
+'use strict'
+
+promise_test(async t => {
+ await applyJitterBufferTarget(t, "audio", 300);
+}, `measure raising and lowering audio jitterBufferTarget`);
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats-helper.js b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats-helper.js
new file mode 100644
index 0000000000..31d80926d3
--- /dev/null
+++ b/testing/web-platform/tests/webrtc-extensions/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-extensions/RTCRtpReceiver-jitterBufferTarget-stats.html b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats.html
deleted file mode 100644
index 33f71800bd..0000000000
--- a/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats.html
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<meta name="timeout" content="long">
-<title>Tests RTCRtpReceiver-jitterBufferTarget verified with stats</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="/webrtc/RTCPeerConnection-helper.js"></script>
-<body>
-<script>
-'use strict'
-
-function async_promise_test(func, name, properties) {
- async_test(t => {
- Promise.resolve(func(t))
- .catch(t.step_func(e => { throw e; }))
- .then(() => t.done());
- }, name, properties);
-}
-
-async_promise_test(t => applyJitterBufferTarget(t, "video", 4000),
- "measure raising and lowering video jitterBufferTarget");
-async_promise_test(t => applyJitterBufferTarget(t, "audio", 4000),
- "measure raising and lowering audio jitterBufferTarget");
-
-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]});
- caller.addTransceiver(stream.getTracks()[0], {streams: [stream]});
-
- exchangeIceCandidates(caller, callee);
- await exchangeOffer(caller, callee);
- const [unconstrainedReceiver, constrainedReceiver] = callee.getReceivers();
- const haveRtp = Promise.all([
- new Promise(r => constrainedReceiver.track.onunmute = r),
- new Promise(r => unconstrainedReceiver.track.onunmute = r)
- ]);
- await exchangeAnswer(caller, callee);
- const chromeTimeout = new Promise(r => t.step_timeout(r, 1000)); // crbug.com/1295295
- await Promise.race([haveRtp, chromeTimeout]);
-
- // Allow some data to be processed to let the jitter buffer to stabilize a bit before measuring
- await new Promise(r => t.step_timeout(r, 5000));
-
- t.step(() => assert_equals(constrainedReceiver.jitterBufferTarget, null,
- `jitterBufferTarget supported for ${kind}`));
-
- constrainedReceiver.jitterBufferTarget = target;
- t.step(() => assert_equals(constrainedReceiver.jitterBufferTarget, target,
- `jitterBufferTarget increase target for ${kind}`));
-
- const [increased, base] = await Promise.all([
- measureDelayFromStats(t, constrainedReceiver, 20),
- measureDelayFromStats(t, unconstrainedReceiver, 20)
- ]);
-
- t.step(() => assert_greater_than(increased , base,
- `${kind} increased delay ${increased} ` +
- ` greater than base delay ${base}`));
-
- constrainedReceiver.jitterBufferTarget = 0;
-
- // Allow the jitter buffer to stabilize a bit before measuring
- await new Promise(r => t.step_timeout(r, 5000));
- t.step(() => assert_equals(constrainedReceiver.jitterBufferTarget, 0,
- `jitterBufferTarget decrease target for ${kind}`));
-
- const decreased = await measureDelayFromStats(t, constrainedReceiver, 20);
-
- t.step(() => assert_less_than(decreased, increased,
- `${kind} decreasedDelay ${decreased} ` +
- `less than increased delay ${increased}`));
-}
-
-async function measureDelayFromStats(t, receiver, cycles) {
-
- let statsReport = await receiver.getStats();
- const oldInboundStats = [...statsReport.values()].find(({type}) => type == "inbound-rtp");
-
- await new Promise(r => t.step_timeout(r, 1000 * cycles));
-
- statsReport = await receiver.getStats();
- const inboundStats = [...statsReport.values()].find(({type}) => type == "inbound-rtp");
-
- const delay = ((inboundStats.jitterBufferDelay - oldInboundStats.jitterBufferDelay) /
- (inboundStats.jitterBufferEmittedCount - oldInboundStats.jitterBufferEmittedCount) * 1000);
-
- return delay;
-}
-</script>
-</body>
diff --git a/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-video-jitterBufferTarget-stats.html b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-video-jitterBufferTarget-stats.html
new file mode 100644
index 0000000000..022dbe70c5
--- /dev/null
+++ b/testing/web-platform/tests/webrtc-extensions/RTCRtpReceiver-video-jitterBufferTarget-stats.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>Tests RTCRtpReceiver-jitterBufferTarget verified with stats</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/webrtc/RTCPeerConnection-helper.js"></script>
+<script src="/webrtc-extensions/RTCRtpReceiver-jitterBufferTarget-stats-helper.js"></script>
+<body>
+<script>
+'use strict'
+
+promise_test(async t => {
+ await applyJitterBufferTarget(t, "video", 1000);
+}, `measure raising and lowering video jitterBufferTarget`);
+
+</script>
+</body>