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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1377299",
title: "Check that packet dump hooks generate callbacks"
});
function waitForPacket(pc, checkFunction) {
return new Promise(resolve => {
function onPacket(level, type, sending, packet) {
if (checkFunction(level, type, sending, packet)) {
SpecialPowers.wrap(pc).mozSetPacketCallback(() => {});
resolve();
}
}
SpecialPowers.wrap(pc).mozSetPacketCallback(onPacket);
}
);
}
async function waitForSendPacket(pc, type, level) {
await SpecialPowers.wrap(pc).mozEnablePacketDump(level, type, true);
await timeout(
waitForPacket(pc, (obsLevel, obsType, sending) => {
is(obsLevel, level, "Level for packet is " + level);
is(obsType, type, "Type for packet is " + type);
ok(sending, "This is a send packet");
return true;
}),
10000, "Timeout waiting for " + type + " send packet on level " + level);
await SpecialPowers.wrap(pc).mozDisablePacketDump(level, type, true);
}
async function waitForRecvPacket(pc, type, level) {
await SpecialPowers.wrap(pc).mozEnablePacketDump(level, type, false);
await timeout(
waitForPacket(pc, (obsLevel, obsType, sending) => {
is(obsLevel, level, "Level for packet is " + level);
is(obsType, type, "Type for packet is " + type);
ok(!sending, "This is a recv packet");
return true;
}),
10000, "Timeout waiting for " + type + " recv packet on level " + level);
await SpecialPowers.wrap(pc).mozDisablePacketDump(level, type, false);
}
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true, video: true}],
[{audio: true, video: true}]);
// pc.js uses video elements by default, we want to test audio elements here
test.pcLocal.audioElementsOnly = true;
test.chain.insertBefore('PC_LOCAL_WAIT_FOR_MEDIA_FLOW',[
async function PC_LOCAL_CHECK_PACKET_DUMP_HOOKS() {
await waitForRecvPacket(test.pcLocal._pc, "rtp", 0);
await waitForRecvPacket(test.pcLocal._pc, "rtcp", 0);
await waitForRecvPacket(test.pcLocal._pc, "srtp", 0);
await waitForRecvPacket(test.pcLocal._pc, "srtcp", 0);
await waitForSendPacket(test.pcLocal._pc, "rtp", 0);
await waitForSendPacket(test.pcLocal._pc, "rtcp", 0);
await waitForSendPacket(test.pcLocal._pc, "srtp", 0);
await waitForSendPacket(test.pcLocal._pc, "srtcp", 0);
await waitForRecvPacket(test.pcLocal._pc, "rtp", 1);
await waitForRecvPacket(test.pcLocal._pc, "rtcp", 1);
await waitForRecvPacket(test.pcLocal._pc, "srtp", 1);
await waitForRecvPacket(test.pcLocal._pc, "srtcp", 1);
await waitForSendPacket(test.pcLocal._pc, "rtp", 1);
await waitForSendPacket(test.pcLocal._pc, "rtcp", 1);
await waitForSendPacket(test.pcLocal._pc, "srtp", 1);
await waitForSendPacket(test.pcLocal._pc, "srtcp", 1);
},
async function PC_REMOTE_CHECK_PACKET_DUMP_HOOKS() {
await waitForRecvPacket(test.pcRemote._pc, "rtp", 0);
await waitForRecvPacket(test.pcRemote._pc, "rtcp", 0);
await waitForRecvPacket(test.pcRemote._pc, "srtp", 0);
await waitForRecvPacket(test.pcRemote._pc, "srtcp", 0);
await waitForSendPacket(test.pcRemote._pc, "rtp", 0);
await waitForSendPacket(test.pcRemote._pc, "rtcp", 0);
await waitForSendPacket(test.pcRemote._pc, "srtp", 0);
await waitForSendPacket(test.pcRemote._pc, "srtcp", 0);
await waitForRecvPacket(test.pcRemote._pc, "rtp", 1);
await waitForRecvPacket(test.pcRemote._pc, "rtcp", 1);
await waitForRecvPacket(test.pcRemote._pc, "srtp", 1);
await waitForRecvPacket(test.pcRemote._pc, "srtcp", 1);
await waitForSendPacket(test.pcRemote._pc, "rtp", 1);
await waitForSendPacket(test.pcRemote._pc, "rtcp", 1);
await waitForSendPacket(test.pcRemote._pc, "srtp", 1);
await waitForSendPacket(test.pcRemote._pc, "srtcp", 1);
}
]);
return test.run();
});
</script>
</pre>
</body>
</html>
|