DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6d82b1a6b02)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
  createHTML({
    bug: "1355220",
    title: "RTCRtpSender.getStats() and RTCRtpReceiver.getStats()",
    visible: true
  });

  var checkStats = (sndReport, rcvReport, mediaType) => {
    ok(sndReport instanceof window.RTCStatsReport, "sender stats are a RTCStatsReport");
    ok(rcvReport instanceof window.RTCStatsReport, "receiver stats are a RTCStatsReport");
    // Returns SSRCs and checks that the tracks are of the correct mediaType
    let getSsrcs = (report, kind) => {
      return [...report.values()]
        .filter(stat => stat.type.endsWith("bound-rtp")).map(stat =>{
          is(stat.mediaType, kind, "mediaType of " + stat.id
              + " is expected type " + kind);
          return stat.ssrc;
      }).sort().join("|");
    };
    let sndSsrcs = getSsrcs(sndReport, mediaType);
    let rcvSsrcs = getSsrcs(rcvReport, mediaType);
    ok(sndSsrcs, "sender SSRCs is not empty");
    ok(rcvSsrcs, "receiver SSRCs is not empty");
    is(sndSsrcs, rcvSsrcs, "sender SSRCs match receiver SSRCs");
  };

  // This MUST be run after PC_*_WAIT_FOR_MEDIA_FLOW to ensure that we have RTP
  // before checking for RTCP.
  // It will throw UnsyncedRtcpError if it times out waiting for sync.

  var test;
  runNetworkTest(function (options) {
    test = new PeerConnectionTest(options);
    test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW",
      async function PC_LOCAL_AND_REMOTE_CHECK_SENDER_RECEIVER_STATS(test) {
        return Promise.all([test.pcLocal.waitForSyncedRtcp(),
                  test.pcRemote.waitForSyncedRtcp()])
          .then(async () => {
            let senders = test.pcLocal.getSenders();
            let receivers = test.pcRemote.getReceivers();
            is(senders.length, 2, "Have exactly two senders.");
            is(receivers.length, 2, "Have exactly two receivers.");
            for(let kind of ["audio", "video"]) {
              let senderStats =
                  await senders.find(s => s.track.kind == kind).getStats();
              is(senders.filter(s => s.track.kind == kind).length, 1,
                  "Exactly 1 sender of kind " + kind);
              let receiverStats =
                  await receivers.find(r => r.track.kind == kind).getStats();
              is(receivers.filter(r => r.track.kind == kind).length, 1,
                  "Exactly 1 receiver of kind " + kind);

              checkStats(senderStats, receiverStats, kind);
            }
          })
        });
    test.setMediaConstraints([{audio: true}, {video: true}], []);
    test.run();
  });

</script>
</pre>
</body>
</html>