|
| 1 | +<!doctype html> |
| 2 | +<meta charset=utf-8> |
| 3 | +<title>payload type handling (assuming rtcp-mux)</title> |
| 4 | +<script src="/resources/testharness.js"></script> |
| 5 | +<script src="/resources/testharnessreport.js"></script> |
| 6 | +<script src="../RTCPeerConnection-helper.js"></script> |
| 7 | +<script> |
| 8 | +'use strict'; |
| 9 | +// Tests behaviour from https://tools.ietf.org/html/rfc5761#section-4 |
| 10 | + |
| 11 | +function createOfferSdp(opusPayloadType) { |
| 12 | + return `v=0 |
| 13 | +o=- 0 3 IN IP4 127.0.0.1 |
| 14 | +s=- |
| 15 | +t=0 0 |
| 16 | +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 |
| 17 | +a=ice-ufrag:6HHHdzzeIhkE0CKj |
| 18 | +a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew |
| 19 | +m=audio 9 RTP/SAVPF ${opusPayloadType} |
| 20 | +c=IN IP4 0.0.0.0 |
| 21 | +a=rtcp-mux |
| 22 | +a=sendonly |
| 23 | +a=mid:audio |
| 24 | +a=rtpmap:${opusPayloadType} opus/48000/2 |
| 25 | +a=setup:actpass |
| 26 | +`; |
| 27 | +} |
| 28 | + |
| 29 | +promise_test(async t => { |
| 30 | + for (let payloadType = 96; payloadType <= 127; payloadType++) { |
| 31 | + const pc = new RTCPeerConnection(); |
| 32 | + await pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(payloadType)}); |
| 33 | + const answer = await pc.createAnswer(); |
| 34 | + assert_true(answer.sdp.includes(`a=rtpmap:${payloadType} opus/48000/2`)); |
| 35 | + pc.close(); |
| 36 | + } |
| 37 | +}, 'setRemoteDescription with a codec in the range 96-127 works'); |
| 38 | + |
| 39 | +// This is written as a separate test since it currently fails in Chrome. |
| 40 | +promise_test(async t => { |
| 41 | + for (let payloadType = 35; payloadType <= 63; payloadType++) { |
| 42 | + const pc = new RTCPeerConnection(); |
| 43 | + await pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(payloadType)}); |
| 44 | + const answer = await pc.createAnswer(); |
| 45 | + assert_true(answer.sdp.includes(`a=rtpmap:${payloadType} opus/48000/2`)); |
| 46 | + pc.close(); |
| 47 | + } |
| 48 | +}, 'setRemoteDescription with a codec in the range 35-63 works'); |
| 49 | + |
| 50 | +promise_test(async t => { |
| 51 | + for (let payloadType = 64; payloadType <= 95; payloadType++) { |
| 52 | + const pc = new RTCPeerConnection(); |
| 53 | + await promise_rejects_dom(t, 'InvalidAccessError', |
| 54 | + pc.setRemoteDescription({type: 'offer', sdp: createOfferSdp(64)})); |
| 55 | + pc.close(); |
| 56 | + } |
| 57 | +}, 'setRemoteDescription with a codec in the range 64-95 throws an InvalidAccessError'); |
| 58 | +</script> |
0 commit comments