Bug 1634114 [wpt PR 23315] - webrtc: refactor simulcast wpt, a=testonly
authorPhilipp Hancke <philipp.hancke@googlemail.com>
Wed, 13 May 2020 03:57:15 +0000
changeset 593699 1c3968f96da6779457a5b3bb1b8043914961b5ac
parent 593698 7e65c7d4c10c670730bff58f009881b885795df8
child 593700 2c37cd98181c5df10a41c1e5cbc44d0af4875b4d
push id13186
push userffxbld-merge
push dateMon, 01 Jun 2020 09:52:46 +0000
treeherdermozilla-beta@3e7c70a1e4a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1634114, 23315, 2172425, 764221
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1634114 [wpt PR 23315] - webrtc: refactor simulcast wpt, a=testonly Automatic update from web-platform-tests webrtc: refactor simulcast wpt and add a test asserting the rids in getStats BUG=webrtc:9547 Change-Id: I5369bc2cb6be9c6369bb3efb1c9c9ff2e46e0639 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2172425 Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com> Reviewed-by: Henrik Boström <hbos@chromium.org> Cr-Commit-Position: refs/heads/master@{#764221} -- wpt-commits: 71940d7ce6a7c4de1c27815e32da20e37d57da2b wpt-pr: 23315
testing/web-platform/tests/webrtc/simulcast/basic.https.html
testing/web-platform/tests/webrtc/simulcast/getStats.https.html
testing/web-platform/tests/webrtc/simulcast/simulcast.js
--- a/testing/web-platform/tests/webrtc/simulcast/basic.https.html
+++ b/testing/web-platform/tests/webrtc/simulcast/basic.https.html
@@ -9,48 +9,11 @@
 <script>
 promise_test(async t => {
   const rids = [0, 1, 2];
   const pc1 = new RTCPeerConnection();
   t.add_cleanup(() => pc1.close());
   const pc2 = new RTCPeerConnection();
   t.add_cleanup(() => pc2.close());
 
-  exchangeIceCandidates(pc1, pc2);
-
-  const metadataToBeLoaded = [];
-  pc2.ontrack = (e) => {
-    const stream = e.streams[0];
-    const v = document.createElement('video');
-    v.autoplay = true;
-    v.srcObject = stream;
-    v.id = stream.id
-    metadataToBeLoaded.push(new Promise((resolve) => {
-        v.addEventListener('loadedmetadata', () => {
-            resolve();
-        });
-    }));
-  };
-
-  // Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.
-  const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
-  t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
-  pc1.addTransceiver(stream.getVideoTracks()[0], {
-    streams: [stream],
-    sendEncodings: rids.map(rid => {rid}),
-  });
-
-  const offer = await pc1.createOffer();
-  await pc1.setLocalDescription(offer),
-  await pc2.setRemoteDescription({
-    type: 'offer',
-    sdp: swapRidAndMidExtensionsInSimulcastOffer(offer, rids),
-  });
-  const answer = await pc2.createAnswer();
-  await pc2.setLocalDescription(answer);
-  await pc1.setRemoteDescription({
-    type: 'answer',
-    sdp: swapRidAndMidExtensionsInSimulcastAnswer(answer, pc1.localDescription, rids),
-  });
-  assert_equals(metadataToBeLoaded.length, 3);
-  return Promise.all(metadataToBeLoaded);
+  return negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
 }, 'Basic simulcast setup with three spatial layers');
 </script>
--- a/testing/web-platform/tests/webrtc/simulcast/getStats.https.html
+++ b/testing/web-platform/tests/webrtc/simulcast/getStats.https.html
@@ -9,57 +9,40 @@
 <script>
 promise_test(async t => {
   const rids = [0, 1, 2];
   const pc1 = new RTCPeerConnection();
   t.add_cleanup(() => pc1.close());
   const pc2 = new RTCPeerConnection();
   t.add_cleanup(() => pc2.close());
 
-  exchangeIceCandidates(pc1, pc2);
-
-  const metadataToBeLoaded = [];
-  pc2.ontrack = (e) => {
-    const stream = e.streams[0];
-    const v = document.createElement('video');
-    v.autoplay = true;
-    v.srcObject = stream;
-    v.id = stream.id
-    metadataToBeLoaded.push(new Promise((resolve) => {
-        v.addEventListener('loadedmetadata', () => {
-            resolve();
-        });
-    }));
-  };
-
-  // Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.
-  const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
-  t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
-  pc1.addTransceiver(stream.getVideoTracks()[0], {
-    streams: [stream],
-    sendEncodings: rids.map(rid => {rid}),
-  });
-
-  const offer = await pc1.createOffer();
-  await pc1.setLocalDescription(offer),
-  await pc2.setRemoteDescription({
-    type: 'offer',
-    sdp: swapRidAndMidExtensionsInSimulcastOffer(offer, rids),
-  });
-  const answer = await pc2.createAnswer();
-  await pc2.setLocalDescription(answer);
-  await pc1.setRemoteDescription({
-    type: 'answer',
-    sdp: swapRidAndMidExtensionsInSimulcastAnswer(answer, pc1.localDescription, rids),
-  });
-  assert_equals(metadataToBeLoaded.length, 3);
-  await Promise.all(metadataToBeLoaded);
+  await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
 
   const outboundStats = [];
   const senderStats = await pc1.getSenders()[0].getStats();
   senderStats.forEach(stat => {
     if (stat.type === 'outbound-rtp') {
       outboundStats.push(stat);
     }
   });
   assert_equals(outboundStats.length, 3);
 }, 'Simulcast getStats contains as many outbound-rtp reports as spatial layers');
+
+promise_test(async t => {
+  const rids = [0, 1, 2];
+  const pc1 = new RTCPeerConnection();
+  t.add_cleanup(() => pc1.close());
+  const pc2 = new RTCPeerConnection();
+  t.add_cleanup(() => pc2.close());
+
+  await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
+
+  const outboundStats = [];
+  const senderStats = await pc1.getSenders()[0].getStats();
+  senderStats.forEach(stat => {
+    if (stat.type === 'outbound-rtp') {
+      outboundStats.push(stat);
+    }
+  });
+  const statsRids = outboundStats.map(stat => parseInt(stat.rid, 10));
+  assert_array_equals(rids, statsRids.sort());
+}, 'Simulcast getStats contains rid stats matching the rids provided');
 </script>
--- a/testing/web-platform/tests/webrtc/simulcast/simulcast.js
+++ b/testing/web-platform/tests/webrtc/simulcast/simulcast.js
@@ -70,8 +70,49 @@ function swapRidAndMidExtensionsInSimulc
   const headerExtensions = SDPUtils.parseRtpParameters(SDPUtils.splitSections(localDescription.sdp)[1]).headerExtensions;
   headerExtensions.forEach(ext => {
     if (extensionsToFilter.includes(ext.uri)) {
       sdp += 'a=extmap:' + ext.id + ' ' + ext.uri + '\r\n';
     }
   });
   return sdp;
 }
+
+async function negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2) {
+  exchangeIceCandidates(pc1, pc2);
+
+  const metadataToBeLoaded = [];
+  pc2.ontrack = (e) => {
+    const stream = e.streams[0];
+    const v = document.createElement('video');
+    v.autoplay = true;
+    v.srcObject = stream;
+    v.id = stream.id
+    metadataToBeLoaded.push(new Promise((resolve) => {
+        v.addEventListener('loadedmetadata', () => {
+            resolve();
+        });
+    }));
+  };
+
+  // Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.
+  const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
+  t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
+  pc1.addTransceiver(stream.getVideoTracks()[0], {
+    streams: [stream],
+    sendEncodings: rids.map(rid => {rid}),
+  });
+
+  const offer = await pc1.createOffer();
+  await pc1.setLocalDescription(offer),
+  await pc2.setRemoteDescription({
+    type: 'offer',
+    sdp: swapRidAndMidExtensionsInSimulcastOffer(offer, rids),
+  });
+  const answer = await pc2.createAnswer();
+  await pc2.setLocalDescription(answer);
+  await pc1.setRemoteDescription({
+    type: 'answer',
+    sdp: swapRidAndMidExtensionsInSimulcastAnswer(answer, pc1.localDescription, rids),
+  });
+  assert_equals(metadataToBeLoaded.length, rids.length);
+  return Promise.all(metadataToBeLoaded);
+}