-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WebRTC
Daniel Raeder edited this page Mar 6, 2022
·
1 revision
Here is the W3C standards compliant way to gather statistics from a WebRTC connection. This should work in all modern browsers.
// The async function allows using "await". You can also do pc.getStats().then(callback) in a non-async context.
(async () => {
const report = await pc.getStats();
for (let dictionary of report.values()) {
console.log(dictionary.type);
console.log(' id: ' + dictionary.id);
console.log(' timestamp: ' + dictionary.timestamp);
Object.keys(dictionary).forEach(key => {
if (key != 'type' && key != 'id' && key != 'timestamp')
console.log(' ' + key + ': ' + dictionary[key]);
});
}
})();
The list of statistics that will be returned can be found here.