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
57
58
59
60
61
62
63
|
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
<script type="application/javascript" src="parser_rtp.js"></script>
<script type="application/javascript" src="sdpUtils.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1416932",
title: "Basic audio-only peer connection and verify rtp header extensions"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
// pc.js uses video elements by default, we want to test audio elements here
test.pcLocal.audioElementsOnly = true;
let getRtpPacket = (pc) => {
// we only examine received packets
let sending = false;
pc.mozEnablePacketDump(0, "rtp", sending);
return new Promise((res, rej) =>
pc.mozSetPacketCallback((...args) => {
res([...args]);
pc.mozSetPacketCallback(() => {});
pc.mozDisablePacketDump(0, "rtp", sending);
})
);
}
const pc = SpecialPowers.wrap(test.pcRemote._pc);
const haveFirstPacket = getRtpPacket(pc);
test.chain.insertBefore('PC_REMOTE_WAIT_FOR_MEDIA_FLOW', [
async function PC_REMOTE_CHECK_RTP_HEADER_EXTS_AGAINST_SDP() {
const sdpExtmapIds = sdputils.findExtmapIds(test.originalAnswer.sdp);
const [level, type, sending, data] = await haveFirstPacket;
const extensions = ParseRtpPacket(data).header.extensions;
// make sure we got the same number of rtp header extensions in
// the received packet as were negotiated in the sdp. Then
// check to make sure each of the received extension ids were in
// the sdp.
is(sdpExtmapIds.length, extensions.length, "number of received ids match sdp ids");
// note, we are comparing a number (from the parsed rtp packet)
// and a string (from the answer sdp)
ok(extensions.every((ext) => sdpExtmapIds.includes(""+ext.id)), "extension id arrays equivalent");
}
]);
return test.run();
});
</script>
</pre>
</body>
</html>
|