Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- 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;
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]] });
await matchPlatformH264CodecPrefs();
const pts = await supportedVideoPayloadTypes();
ok(pts.includes("120"), "VP8 is supported");
ok(pts.includes("121"), "VP9 is supported");
if (pts.length > 2) {
is(pts.length, 8, "Expected VP8, VP9, four variants of H264, ULPFEC, and RED");
ok(pts.includes("97"), "H264 with no packetization-mode is supported");
ok(pts.includes("126"), "H264 with packetization-mode=1 is supported");
ok(pts.includes("103"), "H264 Baseline with no packetization-mode is supported");
ok(pts.includes("105"), "H264 Baseline with packetization-mode=1 is supported");
ok(pts.includes("122"), "RED is supported");
ok(pts.includes("123"), "ULPFEC is supported");
}
for (const pt of pts) {
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>