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
|
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
<script type="application/javascript" src="stats.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1091242",
title: "Multistream: Two audio/video streams"
});
runNetworkTest(async (options) => {
// Disable platform encodre for SW MFT encoder causes some stats
// exceeding the test thresholds.
// E.g. inbound-rtp.packetsDiscarded value=118 >= 100.
await matchPlatformH264CodecPrefs();
const test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true, video: true},
{audio: true, video: true}],
[{audio: true, video: true},
{audio: true, video: true}]);
// Test stats, including coalescing of codec stats.
test.chain.insertAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW",
[PC_LOCAL_TEST_LOCAL_STATS]);
test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW",
[PC_REMOTE_TEST_REMOTE_STATS]);
const testCoalescedCodecStats = stats => {
is([...stats.values()].filter(({type}) => type.endsWith("rtp")).length,
16,
"Expected: 4 outbound, 4 remote-inbound, 4 inbound, 4 remote-inbound");
const codecs = [...stats.values()]
.filter(({type}) => type == "codec")
.sort((a, b) => a.mimeType > b.mimeType);
is(codecs.length, 2, "Should have registered two codecs (coalesced)");
is(new Set(codecs.map(({transportId}) => transportId)).size, 1,
"Should have registered only one transport with BUNDLE");
const codecTypes = new Set(codecs.map(({codecType}) => codecType));
is(codecTypes.size, 1,
"Should have identical encode and decode configurations (and stats)");
is(codecTypes[0], undefined,
"Should have identical encode and decode configurations (and stats)");
is(codecs[0].mimeType.slice(0, 5), "audio",
"Should have registered an audio codec");
is(codecs[1].mimeType.slice(0, 5), "video",
"Should have registered a video codec");
};
test.chain.append([
async function PC_LOCAL_TEST_COALESCED_CODEC_STATS() {
testCoalescedCodecStats(await test.pcLocal._pc.getStats());
},
async function PC_REMOTE_TEST_COALESCED_CODEC_STATS() {
testCoalescedCodecStats(await test.pcRemote._pc.getStats());
},
]);
return test.run();
});
</script>
</pre>
</body>
</html>
|