tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_peerConnection_setParameters_maxFramerate.html (1784B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5 </head>
      6 <body>
      7 <pre id="test">
      8 <script type="application/javascript">
      9 createHTML({
     10  bug: "1611957",
     11  title: "Live-updating maxFramerate"
     12 });
     13 
     14 let sender, receiver;
     15 
     16 async function checkMaxFrameRate(rate) {
     17  const parameters = sender.getParameters();
     18  parameters.encodings[0].maxFramerate = rate;
     19  await sender.setParameters(parameters);
     20  await wait(2000);
     21  const stats = Array.from((await receiver.getStats()).values());
     22  const inboundRtp = stats.find(stat => stat.type == "inbound-rtp");
     23  info(`inbound-rtp stats: ${JSON.stringify(inboundRtp)}`);
     24  const fps = inboundRtp.framesPerSecond;
     25  ok(fps <= (rate * 1.1) + 1,
     26    `fps is an appropriate value (${fps}) for rate (${rate})`);
     27 }
     28 
     29 runNetworkTest(async function (options) {
     30  let test = new PeerConnectionTest(options);
     31  test.setMediaConstraints([{video: true}], []);
     32  test.chain.append([
     33    function CHECK_PRECONDITIONS() {
     34      is(test.pcLocal._pc.getSenders().length, 1,
     35        "Should have 1 local sender");
     36      is(test.pcRemote._pc.getReceivers().length, 1,
     37        "Should have 1 remote receiver");
     38 
     39      sender = test.pcLocal._pc.getSenders()[0];
     40      receiver = test.pcRemote._pc.getReceivers()[0];
     41    },
     42    function PC_LOCAL_SET_MAX_FRAMERATE_2() {
     43      return checkMaxFrameRate(2);
     44    },
     45    function PC_LOCAL_SET_MAX_FRAMERATE_4() {
     46      return checkMaxFrameRate(4);
     47    },
     48    function PC_LOCAL_SET_MAX_FRAMERATE_15() {
     49      return checkMaxFrameRate(15);
     50    },
     51    function PC_LOCAL_SET_MAX_FRAMERATE_8() {
     52      return checkMaxFrameRate(8);
     53    },
     54    function PC_LOCAL_SET_MAX_FRAMERATE_1() {
     55      return checkMaxFrameRate(1);
     56    },
     57  ]);
     58  await test.run();
     59 });
     60 </script>
     61 </pre>
     62 </body>
     63 </html>