|
38 | 38 | localPc.addTrack(...await createTrackAndStreamWithCleanup(test, "audio"));
|
39 | 39 | localPc.addTrack(...await createTrackAndStreamWithCleanup(test, "video"));
|
40 | 40 | 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 | + |
45 | 58 | const start = performance.now();
|
46 | 59 | 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) { |
53 | 61 | // One outbound stat for each track is present. We're done.
|
54 | 62 | break;
|
55 | 63 | }
|
|
58 | 66 | }
|
59 | 67 | await new Promise(r => test.step_timeout(r, 100));
|
60 | 68 | }
|
61 |
| -}, "No RTCOutboundRtpStreamStats exist until packets have been sent"); |
| 69 | +}, "No RTCRtpOutboundStreamStats should exist before negotiation completes"); |
62 | 70 |
|
63 | 71 | promise_test(async (test) => {
|
64 | 72 | const localPc = createPeerConnectionWithCleanup(test);
|
|
0 commit comments