diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html')
-rw-r--r-- | testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html b/testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html new file mode 100644 index 0000000000..54191059a0 --- /dev/null +++ b/testing/web-platform/tests/webrtc/simulcast/setParameters-active.https.html @@ -0,0 +1,106 @@ +<!doctype html> +<meta charset=utf-8> +<title>RTCPeerConnection Simulcast Tests - setParameters/active</title> +<meta name="timeout" content="long"> +<script src="../third_party/sdp/sdp.js"></script> +<script src="simulcast.js"></script> +<script src="../RTCPeerConnection-helper.js"></script> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="../../mediacapture-streams/permission-helper.js"></script> +<script> +async function queryReceiverStats(pc) { + const inboundStats = + await Promise.all(pc.getReceivers().map(async receiver => { + const receiverStats = await receiver.getStats(); + let inboundStat; + receiverStats.forEach(stat => { + if (stat.type === 'inbound-rtp') { + inboundStat = stat; + } + }); + return inboundStat; + })); + return inboundStats.map(s => s.framesDecoded); +} + +promise_test(async t => { + const rids = [0, 1]; + const pc1 = new RTCPeerConnection(); + t.add_cleanup(() => pc1.close()); + const pc2 = new RTCPeerConnection(); + t.add_cleanup(() => pc2.close()); + + await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2); + + // Deactivate first sender. + const parameters = pc1.getSenders()[0].getParameters(); + parameters.encodings[0].active = false; + await pc1.getSenders()[0].setParameters(parameters); + + // Assert (almost) no new frames are received on the first encoding. + // Without any action we would expect to have received around 30fps. + await new Promise(resolve => t.step_timeout(resolve, 200)); // Wait a bit. + const initialStats = await queryReceiverStats(pc2); + await new Promise(resolve => t.step_timeout(resolve, 1000)); // Wait more. + const subsequentStats = await queryReceiverStats(pc2); + + assert_equals(subsequentStats[0], initialStats[0]); + assert_greater_than(subsequentStats[1], initialStats[1]); +}, 'Simulcast setParameters active=false on first encoding stops sending frames for that encoding'); + +promise_test(async t => { + const rids = [0, 1]; + const pc1 = new RTCPeerConnection(); + t.add_cleanup(() => pc1.close()); + const pc2 = new RTCPeerConnection(); + t.add_cleanup(() => pc2.close()); + + await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2); + + // Deactivate second sender. + const parameters = pc1.getSenders()[0].getParameters(); + parameters.encodings[1].active = false; + await pc1.getSenders()[0].setParameters(parameters); + + // Assert (almost) no new frames are received on the second encoding. + // Without any action we would expect to have received around 30fps. + await new Promise(resolve => t.step_timeout(resolve, 200)); // Wait a bit. + const initialStats = await queryReceiverStats(pc2); + await new Promise(resolve => t.step_timeout(resolve, 1000)); // Wait more. + const subsequentStats = await queryReceiverStats(pc2); + + assert_equals(subsequentStats[1], initialStats[1]); + assert_greater_than(subsequentStats[0], initialStats[0]); +}, 'Simulcast setParameters active=false on second encoding stops sending frames for that encoding'); + +promise_test(async t => { + const rids = [0, 1]; + const pc1 = new RTCPeerConnection(); + t.add_cleanup(() => pc1.close()); + const pc2 = new RTCPeerConnection(); + t.add_cleanup(() => pc2.close()); + + await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2); + + // Deactivate all senders. + const parameters = pc1.getSenders()[0].getParameters(); + parameters.encodings.forEach(e => { + e.active = false; + }); + await pc1.getSenders()[0].setParameters(parameters); + + // Assert (almost) no new frames are received. + // Without any action we would expect to have received around 30fps. + await new Promise(resolve => t.step_timeout(resolve, 200)); // Wait a bit. + const initialStats = await queryReceiverStats(pc2); + await new Promise(resolve => t.step_timeout(resolve, 1000)); // Wait more. + const subsequentStats = await queryReceiverStats(pc2); + + subsequentStats.forEach((framesDecoded, idx) => { + assert_equals(framesDecoded, initialStats[idx]); + }); +}, 'Simulcast setParameters active=false stops sending frames'); +</script> |