|
| 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