1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<!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;
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 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, 4, "Expected VP8, VP9 and two variants of H264");
ok(pts.includes("97"), "H264 with no packetization-mode is supported");
ok(pts.includes("126"), "H264 with packetization-mode=1 is supported");
}
for (const pt of pts) {
await testScreenshare(pt);
}
});
</script>
</pre>
</body>
</html>
|