Skip to content

Commit a44c4c2

Browse files
fippochromium-wpt-export-bot
authored andcommitted
webrtc: check for allowed payload types in createOffer
this will intentionally break when adding new codecs and we can not add new codecs anymore because we do not have enough payload types. BUG=webrtc:12194 Change-Id: Ic1dff5f479377280111729f6443fc60a7d2e2658 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550806 Commit-Queue: Philipp Hancke <[email protected]> Reviewed-by: Harald Alvestrand <[email protected]> Cr-Commit-Position: refs/heads/master@{#830996}
1 parent b1d491e commit a44c4c2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>RTCPeerConnection RTP payload types</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
</head>
8+
<body>
9+
<script>
10+
11+
// Test that when creating an offer we do not run out of valid payload types.
12+
promise_test(async t => {
13+
const pc1 = new RTCPeerConnection();
14+
t.add_cleanup(() => pc1.close());
15+
16+
const offer = await pc1.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
17+
18+
// Extract all payload types from the m= lines.
19+
const payloadTypes = offer.sdp.split('\n')
20+
.map(line => line.trim())
21+
.filter(line => line.startsWith('m='))
22+
.map(line => line.split(' ').slice(3).join(' '))
23+
.join(' ')
24+
.split(' ')
25+
.map(payloadType => parseInt(payloadType, 10));
26+
27+
// The list of allowed payload types is taken from here
28+
// https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-1.
29+
const forbiddenPayloadTypes = payloadTypes
30+
.filter(payloadType => {
31+
if (payloadType >= 96 && payloadType <= 127) {
32+
return false;
33+
}
34+
if (payloadType >= 72 && payloadType < 96) {
35+
return true;
36+
}
37+
if (payloadType >= 35 && payloadType < 72) {
38+
return false;
39+
}
40+
// TODO: Check against static payload type list.
41+
return false;
42+
});
43+
assert_equals(forbiddenPayloadTypes.length, 0)
44+
}, 'createOffer with the maximum set of codecs does not generate invalid payload types');
45+
</script>
46+
</body>
47+
</html>

0 commit comments

Comments
 (0)