tor-browser

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

test_peerConnection_twoAudioVideoStreamsCombinedNoBundle.html (3934B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5  <script type="application/javascript" src="stats.js"></script>
      6 </head>
      7 <body>
      8 <pre id="test">
      9 <script type="application/javascript">
     10 createHTML({
     11  bug: "1225722",
     12  title: "Multistream: Two audio/video streams without BUNDLE"
     13 });
     14 
     15 runNetworkTest(async (options = {}) => {
     16  options.bundle = false;
     17  const test = new PeerConnectionTest(options);
     18  test.setMediaConstraints(
     19    [{audio: true, video: {width: 50}}, {audio: true, video: {width: 50}}],
     20    [{audio: true, video: {width: 50}}, {audio: true, video: {width: 50}}]
     21  );
     22 
     23  // Test stats, including that codec stats do not coalesce without BUNDLE.
     24  const testNonBundledStats = async pc => {
     25    // This is basically PC_*_TEST_*_STATS fleshed out, but uses
     26    // sender/receiver.getStats instead of pc.getStats, since the codec stats
     27    // code assumes at most one sender and at most one receiver.
     28    await waitForSyncedRtcp(pc);
     29    const senderPromises = pc.getSenders().map(obj => obj.getStats());
     30    const receiverPromises = pc.getReceivers().map(obj => obj.getStats());
     31    const senderStats = await Promise.all(senderPromises);
     32    const receiverStats = await Promise.all(receiverPromises);
     33    for (const stats of [...senderStats, ...receiverStats]) {
     34      checkExpectedFields(stats);
     35      pedanticChecks(stats);
     36    }
     37    for (const stats of senderStats) {
     38      checkSenderStats(stats, 1);
     39    }
     40  };
     41 
     42  test.chain.insertAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", [
     43    async function PC_LOCAL_TEST_LOCAL_NONBUNDLED_STATS(test) {
     44      await testNonBundledStats(test.pcLocal._pc);
     45    },
     46  ]);
     47 
     48  test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW", [
     49    async function PC_REMOTE_TEST_LOCAL_NONBUNDLED_STATS(test) {
     50      await testNonBundledStats(test.pcRemote._pc);
     51    },
     52  ]);
     53 
     54  const testNonCoalescedCodecStats = stats => {
     55    const codecs = [...stats.values()]
     56          .filter(({type}) => type == "codec");
     57    is([...stats.values()].filter(({type}) => type.endsWith("rtp")).length, 16,
     58      "Expected: 4 outbound, 4 remote-inbound, 4 inbound, 4 remote-inbound");
     59    const codecTypes = new Set(codecs.map(({codecType}) => codecType));
     60    is(codecTypes.size, 1,
     61      "Should have identical encode and decode configurations (and stats)");
     62    is(codecTypes[0], undefined,
     63      "Should have identical encode and decode configurations (and stats)");
     64    const transportIds = new Set(codecs.map(({transportId}) => transportId));
     65    is(transportIds.size, 4,
     66      "Should have registered four transports for two sendrecv streams");
     67    for (const transportId of transportIds) {
     68      is(codecs.filter(c => c.transportId == transportId).length, 1,
     69        "Should have registered one codec per transport without BUNDLE");
     70    }
     71    for (const prefix of ["audio", "video"]) {
     72      const prefixed = codecs.filter(c => c.mimeType.startsWith(prefix));
     73      is(prefixed.length, 2, `Should have registered two ${prefix} codecs`);
     74      if (prefixed.length == 2) {
     75        is(prefixed[0].payloadType, prefixed[1].payloadType,
     76          "same payloadType");
     77        isnot(prefixed[0].transportId, prefixed[1].transportId,
     78          "different transportIds");
     79        is(prefixed[0].mimeType, prefixed[1].mimeType, "same mimeType");
     80        is(prefixed[0].clockRate, prefixed[1].clockRate, "same clockRate");
     81        is(prefixed[0].channels, prefixed[1].channels, "same channels");
     82        is(prefixed[0].sdpFmtpLine, prefixed[1].sdpFmtpLine,
     83          "same sdpFmtpLine");
     84      }
     85    }
     86  };
     87 
     88  test.chain.append([
     89    async function PC_LOCAL_TEST_NON_COALESCED_CODEC_STATS() {
     90      testNonCoalescedCodecStats(await test.pcLocal._pc.getStats());
     91    },
     92    async function PC_REMOTE_TEST_NON_COALESCED_CODEC_STATS() {
     93      testNonCoalescedCodecStats(await test.pcRemote._pc.getStats());
     94    },
     95  ]);
     96 
     97  return test.run();
     98 });
     99 </script>
    100 </pre>
    101 </body>
    102 </html>