Edit in JSFiddle

var pc1 = new RTCPeerConnection(), pc2 = new RTCPeerConnection();

new Promise(resolve => pc2.oniceconnectionstatechange = () =>
            pc2.iceConnectionState == "connected" && resolve())
.then(() => setInterval(() => Promise.all([pc1.getStats(), pc2.getStats()])
  .then(([pc1Stats, pc2Stats]) => {
    let html = "<h4>Sender side</h4>";
    pc1Stats.forEach(stat => {
      if (stat.type == "outbound-rtp" && !stat.isRemote) {
        html += dumpOutbound(stat);
        let rtcp = pc1Stats.get(stat.remoteId);
        if (rtcp) html += "<br>RTCP " + dumpInbound(rtcp);
      }
    });
    html += "<h4>Receiver side</h4>";
    pc2Stats.forEach(stat => {
      if (stat.type == "inbound-rtp" && !stat.isRemote) {
        html += dumpInbound(stat);
        let rtcp = pc2Stats.get(stat.remoteId);
        if (rtcp) html += "<br>RTCP " + dumpOutbound(rtcp);
      }
    });
    update(statsdiv, "<small>"+ html +"</small>");
  }).catch(e => log(e)), 100))
.catch(e => log(e));

let mb = bytes => (bytes/1024000).toFixed(2);

let dumpHeader = o => `${o.type} ${o.mediaType} ${new Date(o.timestamp).toTimeString()}<br>SSRC: ${o.ssrc} `;
var dumpOutbound = o => dumpHeader(o) + `Sent: ${o.packetsSent} packets (${mb(o.bytesSent)} MB)<br>Dropped frames: ${o.droppedFrames}<br>`;
var dumpInbound = o => dumpHeader(o) + `Received: ${o.packetsReceived} packets (${mb(o.bytesReceived)} MB) Lost: ${o.packetsLost}<br>Discarded packets: ${o.discardedPackets} Jitter: ${o.jitter}<br>`;

navigator.mediaDevices.getUserMedia({video: true})
  .then(stream => pc1.addStream(video1.srcObject = stream))
  .catch(e => log(e));

pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);
pc2.ontrack = e => video2.srcObject = e.streams[0];
pc1.onnegotiationneeded = e =>
  pc1.createOffer().then(d => pc1.setLocalDescription(d))
  .then(() => pc2.setRemoteDescription(pc1.localDescription))
  .then(() => pc2.createAnswer()).then(d => pc2.setLocalDescription(d))
  .then(() => pc1.setRemoteDescription(pc2.localDescription))
  .catch(e => log(e));

var mute = () => video1.srcObject.getTracks().forEach(t => t.enabled = !t.enabled);
var log = msg => div.innerHTML = div.innerHTML + msg +"<br>";
var update = (div, msg) => div.innerHTML = msg;
<video id="video1" width="160" height="120" autoplay muted></video>
<video id="video2" width="160" height="120" autoplay></video><br>
<label><input type="checkbox" onclick="mute()">mute</label>
<div id="div"></div><br><div id="statsdiv"></div>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>