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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
<!doctype html>
<meta charset=utf-8>
<title>RTX codec integrity checks</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../RTCPeerConnection-helper.js"></script>
<script src="../third_party/sdp/sdp.js"></script>
<script>
'use strict';
// Tests for conformance to rules for RTX codecs.
// Basic rule: Offers and answers must contain RTX codecs, and the
// RTX codecs must have an a=fmtp line that points to a non-RTX codec.
// Helper function for doing one round of offer/answer exchange
// between two local peer connections.
// Calls setRemoteDescription(offer/answer) before
// setLocalDescription(offer/answer) to ensure the remote description
// is set and candidates can be added before the local peer connection
// starts generating candidates and ICE checks.
async function doSignalingHandshake(localPc, remotePc, options={}) {
let offer = await localPc.createOffer();
// Modify offer if callback has been provided
if (options.modifyOffer) {
offer = await options.modifyOffer(offer);
}
// Apply offer.
await remotePc.setRemoteDescription(offer);
await localPc.setLocalDescription(offer);
let answer = await remotePc.createAnswer();
// Modify answer if callback has been provided
if (options.modifyAnswer) {
answer = await options.modifyAnswer(answer);
}
// Apply answer.
await localPc.setRemoteDescription(answer);
await remotePc.setLocalDescription(answer);
}
function verifyRtxReferences(description) {
const mediaSection = SDPUtils.getMediaSections(description.sdp)[0];
const rtpParameters = SDPUtils.parseRtpParameters(mediaSection);
for (const codec of rtpParameters.codecs) {
if (codec.name === 'rtx') {
assert_own_property(codec.parameters, 'apt', 'rtx codec has apt parameter');
const referenced_codec = rtpParameters.codecs.find(
c => c.payloadType === parseInt(codec.parameters.apt));
assert_true(referenced_codec !== undefined, `Found referenced codec`);
}
}
}
promise_test(async t => {
const pc = new RTCPeerConnection();
const offer = await generateVideoReceiveOnlyOffer(pc);
verifyRtxReferences(offer);
}, 'Initial offer should have sensible RTX mappings');
async function negotiateAndReturnAnswer(t) {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
let [track, streams] = await getTrackFromUserMedia('video');
const sender = pc1.addTrack(track);
await doSignalingHandshake(pc1, pc2);
return pc2.localDescription;
}
promise_test(async t => {
const answer = await negotiateAndReturnAnswer(t);
verifyRtxReferences(answer);
}, 'Self-negotiated answer should have sensible RTX parameters');
promise_test(async t => {
const sampleOffer = `v=0
o=- 1878890426675213188 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:RGPK
a=ice-pwd:rAyHEAKC7ckxQgWaRZXukz+Z
a=ice-options:trickle
a=fingerprint:sha-256 8C:29:0A:8F:11:06:BF:1C:58:B3:CA:E6:F1:F1:DC:99:4C:6C:89:E9:FF:BC:D4:38:11:18:1F:40:19:C8:49:37
a=setup:actpass
a=mid:video
a=recvonly
a=rtcp-mux
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=98
a=rtpmap:98 VP8/90000
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
`;
const pc = new RTCPeerConnection();
let [track, streams] = await getTrackFromUserMedia('video');
const sender = pc.addTrack(track);
await pc.setRemoteDescription({type: 'offer', sdp: sampleOffer});
const answer = await pc.createAnswer();
verifyRtxReferences(answer);
}, 'A remote offer generates sensible RTX references in answer');
promise_test(async t => {
const sampleOffer = `v=0
o=- 1878890426675213188 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:RGPK
a=ice-pwd:rAyHEAKC7ckxQgWaRZXukz+Z
a=ice-options:trickle
a=fingerprint:sha-256 8C:29:0A:8F:11:06:BF:1C:58:B3:CA:E6:F1:F1:DC:99:4C:6C:89:E9:FF:BC:D4:38:11:18:1F:40:19:C8:49:37
a=setup:actpass
a=mid:video
a=recvonly
a=rtcp-mux
a=rtpmap:96 VP8/90000
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=98
a=rtpmap:98 VP8/90000
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=96
`;
const pc = new RTCPeerConnection();
let [track, streams] = await getTrackFromUserMedia('video');
const sender = pc.addTrack(track);
await pc.setRemoteDescription({type: 'offer', sdp: sampleOffer});
const answer = await pc.createAnswer();
verifyRtxReferences(answer);
}, 'A remote offer with duplicate codecs generates sensible RTX references in answer');
</script>
|