summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc/protocol/rtp-payloadtypes.html
blob: af7656d131ea45779334ef43a52d6e0b343a6721 (plain)
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
<!doctype html>
<meta charset=utf-8>
<title>payload type handling (assuming rtcp-mux)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../RTCPeerConnection-helper.js"></script>
<script>
'use strict';
// Tests behaviour from https://tools.ietf.org/html/rfc5761#section-4

function createOfferSdp(opusPayloadType) {
  return `v=0
o=- 0 3 IN IP4 127.0.0.1
s=-
t=0 0
a=fingerprint:sha-256 A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:AD:7E:77:43:2A:29:EC:93
a=ice-ufrag:6HHHdzzeIhkE0CKj
a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew
m=audio 9 RTP/SAVPF ${opusPayloadType}
c=IN IP4 0.0.0.0
a=rtcp-mux
a=sendonly
a=mid:audio
a=rtpmap:${opusPayloadType} opus/48000/2
a=setup:actpass
`;
}

promise_test(async t => {
  for (let payloadType = 96; payloadType <= 127; payloadType++) {
    const pc = new RTCPeerConnection();
    await pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(payloadType)});
    const answer = await pc.createAnswer();
    assert_true(answer.sdp.includes(`a=rtpmap:${payloadType} opus/48000/2`));
    pc.close();
  }
}, 'setRemoteDescription with a codec in the range 96-127 works');

// This is written as a separate test since it currently fails in Chrome.
promise_test(async t => {
  for (let payloadType = 35; payloadType <= 63; payloadType++) {
    const pc = new RTCPeerConnection();
    await pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(payloadType)});
    const answer = await pc.createAnswer();
    assert_true(answer.sdp.includes(`a=rtpmap:${payloadType} opus/48000/2`));
    pc.close();
  }
}, 'setRemoteDescription with a codec in the range 35-63 works');

promise_test(async t => {
  for (let payloadType = 64; payloadType <= 95; payloadType++) {
    const pc = new RTCPeerConnection();
    await promise_rejects_dom(t, 'InvalidAccessError',
                              pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(payloadType)}),
                              'Failed to reject on PT ' + payloadType);


    pc.close();
  }
}, 'setRemoteDescription with a codec in the range 64-95 throws an InvalidAccessError');
</script>