Go to:
https://webrtc.github.io/samples/src/content/peerconnection/pc1/
Start the video and the call.
The RTCPeerConnections are under the variables pc1
and pc2
. In the console, run:
const stats1 = await pc1.getStats()
const stats2 = await pc2.getStats()
And then you should be able to get data from that as is described here, though I've not quite been able to get that data out yet: https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport
Two examples with stats being displayed:
- https://webrtc.github.io/samples/src/content/peerconnection/constraints/
- https://webrtc.github.io/samples/src/content/peerconnection/old-new-stats/
Replace the dumpStats
function in https://webrtc.github.io/samples/src/content/peerconnection/constraints/ with the following to get JSON output in the console and in the webpage:
function dumpStats(results) {
let statsObject = {}
results.forEach(res => {
statsObject.type = res.type;
statsObject.id = res.id;
statsObject.timestamp = res.timestamp;
Object.keys(res).forEach(k => {
if (k !== 'timestamp' && k !== 'type' && k !== 'id') {
statsObject[k] = res[k]
}
});
});
console.log(statsObject)
return JSON.stringify(statsObject);
}
How to extract PeerConnection:
// @returns Array<RTCPeerConnection>
function getPeerConnectionObjects(room) {
return [...room._signaling._peerConnectionManager._peerConnections.values()].map(pc => pc._peerConnection._peerConnection);
}