Commit 34bad36a authored by Philipp Hancke's avatar Philipp Hancke Committed by Commit Bot

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 <philipp.hancke@googlemail.com>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830996}
parent d53fdbe9
<!DOCTYPE html>
<html>
<head>
<title>RTCPeerConnection RTP payload types</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
// Test that when creating an offer we do not run out of valid payload types.
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const offer = await pc1.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
// Extract all payload types from the m= lines.
const payloadTypes = offer.sdp.split('\n')
.map(line => line.trim())
.filter(line => line.startsWith('m='))
.map(line => line.split(' ').slice(3).join(' '))
.join(' ')
.split(' ')
.map(payloadType => parseInt(payloadType, 10));
// The list of allowed payload types is taken from here
// https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-1.
const forbiddenPayloadTypes = payloadTypes
.filter(payloadType => {
if (payloadType >= 96 && payloadType <= 127) {
return false;
}
if (payloadType >= 72 && payloadType < 96) {
return true;
}
if (payloadType >= 35 && payloadType < 72) {
return false;
}
// TODO: Check against static payload type list.
return false;
});
assert_equals(forbiddenPayloadTypes.length, 0)
}, 'createOffer with the maximum set of codecs does not generate invalid payload types');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>RTCPeerConnection RTP payload types</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
// Test that when creating an offer we do not run out of valid payload types.
// This uses the deprecated RTP datachannels which means an extra payload
// type is allocated.
const legacy_datachannel_constraint = {
optional: [{ RtpDataChannels: true }]
}
promise_test(async t => {
const pc1 = new RTCPeerConnection(null, legacy_datachannel_constraint);
t.add_cleanup(() => pc1.close());
const offer = await pc1.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
// Extract all payload types from the m= lines.
const payloadTypes = offer.sdp.split('\n')
.map(line => line.trim())
.filter(line => line.startsWith('m='))
.map(line => line.split(' ').slice(3).join(' '))
.join(' ')
.split(' ')
.map(payloadType => parseInt(payloadType, 10));
// The list of allowed payload types is taken from here
// https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-1.
const forbiddenPayloadTypes = payloadTypes
.filter(payloadType => {
if (payloadType >= 96 && payloadType <= 127) {
return false;
}
if (payloadType >= 72 && payloadType < 96) {
return true;
}
if (payloadType >= 35 && payloadType < 72) {
return false;
}
// TODO: Check against static payload type list.
return false;
});
assert_equals(forbiddenPayloadTypes.length, 0)
}, 'createOffer with the maximum set of codecs and RTP datachannels does not generate invalid payload types');
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment