Skip to content

Commit c7fd2ce

Browse files
na-gmoz-wptsync-bot
authored andcommitted
update rtp-stats-creation.html WPT outbound-rtp timing expectations
The spec has been updated such that RtcRtpOutboundStreamStats are reported as soon as negotiation is complete. This means that packets can now be zero. We should check that the stats do not exist prior to negotiation and that they do appear after negotiation. Differential Revision: https://phabricator.services.mozilla.com/D250591 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1967577 gecko-commit: 59e7ba1d605ad0d25a4cf70b639d77fea52b4161 gecko-reviewers: dbaker, jib
1 parent c557cd5 commit c7fd2ce

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

webrtc-stats/rtp-stats-creation.html

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,26 @@
3838
localPc.addTrack(...await createTrackAndStreamWithCleanup(test, "audio"));
3939
localPc.addTrack(...await createTrackAndStreamWithCleanup(test, "video"));
4040
exchangeIceCandidates(localPc, remotePc);
41-
await Promise.all([
42-
exchangeOfferAnswer(localPc, remotePc),
43-
new Promise(r => remotePc.ontrack = e => e.track.onunmute = r)
44-
]);
41+
42+
async function countOutboundRtp() {
43+
const stats = await localPc.getStats();
44+
return [...stats.values()]
45+
.filter(({ type }) => type == "outbound-rtp").length;
46+
}
47+
48+
assert_equals(await countOutboundRtp(), 0,
49+
"No outbound rtp stats before setLocalDescription");
50+
await localPc.setLocalDescription();
51+
const p = remotePc.setRemoteDescription(localPc.localDescription);
52+
assert_equals(await countOutboundRtp(), 0,
53+
"No outbound rtp stats after setLocalDescription but before setRemoteDescription");
54+
await p;
55+
await remotePc.setLocalDescription();
56+
await localPc.setRemoteDescription(remotePc.localDescription);
57+
4558
const start = performance.now();
4659
while (true) {
47-
const report = await localPc.getStats();
48-
const outbound =
49-
[...report.values()].filter(({type}) => type == "outbound-rtp");
50-
assert_true(outbound.every(({packetsSent}) => packetsSent > 0),
51-
"no outbound rtp stats before packets sent");
52-
if (outbound.length == 2) {
60+
if (await countOutboundRtp() == 2) {
5361
// One outbound stat for each track is present. We're done.
5462
break;
5563
}
@@ -58,7 +66,7 @@
5866
}
5967
await new Promise(r => test.step_timeout(r, 100));
6068
}
61-
}, "No RTCOutboundRtpStreamStats exist until packets have been sent");
69+
}, "No RTCRtpOutboundStreamStats should exist before negotiation completes");
6270

6371
promise_test(async (test) => {
6472
const localPc = createPeerConnectionWithCleanup(test);

0 commit comments

Comments
 (0)