Skip to content

Commit

Permalink
Test simulcast screenshare in webrtc/simulcast/screenshare.https.html…
Browse files Browse the repository at this point in the history
… WPT.

Depends on D189663

Differential Revision: https://phabricator.services.mozilla.com/D189677

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1692873
gecko-commit: efbb9e1af880f1a6fc1aee81e670b399906a8698
gecko-reviewers: bwc
  • Loading branch information
jan-ivar authored and moz-wptsync-bot committed Nov 20, 2024
1 parent 79ffeb2 commit 92f1c29
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion webrtc/simulcast/basic.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

return negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2);
}, 'Basic simulcast setup with two spatial layers');
</script>
2 changes: 1 addition & 1 deletion webrtc/simulcast/getStats.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2);

const outboundStats = [];
const senderStats = await pc1.getSenders()[0].getStats();
Expand Down
3 changes: 2 additions & 1 deletion webrtc/simulcast/h264.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

return negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2, {mimeType: 'video/H264'});
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2,
{mimeType: 'video/H264'});
}, 'H264 simulcast setup with two streams');
</script>
28 changes: 28 additions & 0 deletions webrtc/simulcast/screenshare.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<meta charset=utf-8>
<title>RTCPeerConnection Screen-sharing Simulcast Tests</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>
promise_test(async t => {
// Test getDisplayMedia with simulcast
await test_driver.bless('getDisplayMedia');
const stream = await navigator.mediaDevices.getDisplayMedia({
video: {width: 1280, height: 720}
});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const rids = [0, 1];
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

return negotiateSimulcastAndWaitForVideo(t, stream, rids, pc1, pc2);
}, 'Basic simulcast setup with two spatial layers');
</script>
6 changes: 3 additions & 3 deletions webrtc/simulcast/setParameters-active.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2);

// Deactivate first sender.
const parameters = pc1.getSenders()[0].getParameters();
Expand All @@ -58,7 +58,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2);

// Deactivate second sender.
const parameters = pc1.getSenders()[0].getParameters();
Expand All @@ -83,7 +83,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
await negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2);

// Deactivate all senders.
const parameters = pc1.getSenders()[0].getParameters();
Expand Down
14 changes: 9 additions & 5 deletions webrtc/simulcast/simulcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function swapRidAndMidExtensionsInSimulcastAnswer(answer, localDescription, rids
}

async function negotiateSimulcastAndWaitForVideo(
t, rids, pc1, pc2, codec, scalabilityMode = undefined) {
t, stream, rids, pc1, pc2, codec, scalabilityMode = undefined) {
exchangeIceCandidates(pc1, pc2);

const metadataToBeLoaded = [];
Expand Down Expand Up @@ -251,10 +251,6 @@ async function negotiateSimulcastAndWaitForVideo(
scaleResolutionDownBy *= 2;
}

// Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.
await setMediaPermission();
const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const transceiver = pc1.addTransceiver(stream.getVideoTracks()[0], {
streams: [stream],
sendEncodings: sendEncodings,
Expand All @@ -278,3 +274,11 @@ async function negotiateSimulcastAndWaitForVideo(
assert_equals(metadataToBeLoaded.length, rids.length);
return Promise.all(metadataToBeLoaded);
}

async function getCameraStream(t) {
// Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.
await setMediaPermission();
const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
return stream;
}
3 changes: 2 additions & 1 deletion webrtc/simulcast/vp8.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

return negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2, {mimeType: 'video/VP8'});
return negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2,
{mimeType: 'video/VP8'});
}, 'VP8 simulcast setup with two streams');
</script>
5 changes: 3 additions & 2 deletions webrtc/simulcast/vp9-scalability-mode.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

// This is not a scalability mode test (see wpt/webrtc-svc/ for those) but a
// VP9 simulcast test. Setting `scalabilityMode` should not be needed, however
// many browsers interprets multiple VP9 encodings to mean multiple spatial
// some browsers interpret multiple VP9 encodings to mean multiple spatial
// layers by default. During a transition period, Chromium-based browsers
// requires explicitly specifying the scalability mode as a way to opt-in to
// spec-compliant simulcast. See also wpt/webrtc/simulcast/vp9.https.html for
// a version of this test that does not set the scalability mode.
const scalabilityMode = 'L1T2';
return negotiateSimulcastAndWaitForVideo(
t, rids, pc1, pc2, {mimeType: 'video/VP9'}, scalabilityMode);
t, await getCameraStream(t), rids, pc1, pc2, {mimeType: 'video/VP9'},
scalabilityMode);
}, 'VP9 simulcast setup with two streams and L1T2 set');
</script>
3 changes: 2 additions & 1 deletion webrtc/simulcast/vp9.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

return negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2, {mimeType: 'video/VP9'});
return negotiateSimulcastAndWaitForVideo(t, await getCameraStream(t), rids, pc1, pc2,
{mimeType: 'video/VP9'});
}, 'VP9 simulcast setup with two streams');
</script>

0 comments on commit 92f1c29

Please sign in to comment.