Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android' OR os == 'mac' && os_version == '14.70' && processor == 'x86_64'
- Manifest: dom/media/webrtc/tests/mochitests/mochitest_peerconnection.toml
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1039666",
title: "Basic screenshare-only peer connection"
});
async function supportedVideoPayloadTypes() {
const pc = new RTCPeerConnection();
const offer = await pc.createOffer({offerToReceiveVideo: true});
return sdputils.getPayloadTypes(offer.sdp);
}
async function testScreenshare(payloadType) {
const options = {};
options.h264 = payloadType == 97 || payloadType == 126 || payloadType == 103 || payloadType == 105;
options.av1 = payloadType == 99;
const test = new PeerConnectionTest(options);
const constraints = {
video: { mediaSource: "screen" },
};
test.setMediaConstraints([constraints], []);
test.chain.insertAfterEach("PC_LOCAL_CREATE_OFFER", [
function PC_LOCAL_ISOLATE_CODEC() {
info(`Forcing payload type ${payloadType}. Note that other associated ` +
`payload types, like RTX, are removed too.`);
test.originalOffer.sdp =
sdputils.removeAllButPayloadType(test.originalOffer.sdp, payloadType);
},
]);
await test.run();
}
runNetworkTest(async () => {
await SpecialPowers.pushPrefEnv({ set: [["media.navigator.video.red_ulpfec_enabled", true]] });
await SpecialPowers.pushPrefEnv({ set: [["media.navigator.video.disable_h264_baseline", false]] });
let hasH264 = await matchPlatformH264CodecPrefs();
let hasAv1 = await matchPlatformAV1CodecPrefs();
const allPts = await supportedVideoPayloadTypes();
const pts = {
pts: allPts,
take(pt) {
const result = this.pts.includes(pt);
this.pts = this.pts.filter(p => pt != p);
return result;
},
empty() {
return !this.pts.length;
},
};
ok(pts.take("120"), "VP8 is supported");
ok(pts.take("121"), "VP9 is supported");
if (hasAv1.any) {
ok(pts.take("99"), "AV1 is supported");
}
if (hasH264.any) {
ok(pts.take("97"), "H264 with no packetization-mode is supported");
ok(pts.take("126"), "H264 with packetization-mode=1 is supported");
ok(pts.take("103"), "H264 Baseline with no packetization-mode is supported");
ok(pts.take("105"), "H264 Baseline with packetization-mode=1 is supported");
ok(pts.take("122"), "RED is supported");
ok(pts.take("123"), "ULPFEC is supported");
}
ok(pts.empty(), `All supported codecs were tested. Untested codecs: ${JSON.stringify(pts.pts, null, 2)}`);
for (const pt of allPts) {
if (pt == "122" || pt == "123") {
// ULPFEC and RED are meant to work combined with other codecs.
// Forcing sdp with only one of them is not supported and will result in failures.
continue;
}
await testScreenshare(pt);
}
});
</script>
</pre>
</body>
</html>