Files
Testing/videocall1/getStats/dev/wrapper.js
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

31 lines
1.0 KiB
JavaScript

// a wrapper around getStats which hides the differences (where possible)
// following code-snippet is taken from somewhere on the github
function getStatsWrapper(cb) {
// if !peer or peer.signalingState == 'closed' then return;
if (typeof window.InstallTrigger !== 'undefined' || isSafari) { // maybe "isEdge?"
peer.getStats(window.mediaStreamTrack || null).then(function(res) {
var items = [];
res.forEach(function(r) {
items.push(r);
});
cb(items);
}).catch(cb);
} else {
peer.getStats(function(res) {
var items = [];
res.result().forEach(function(res) {
var item = {};
res.names().forEach(function(name) {
item[name] = res.stat(name);
});
item.id = res.id;
item.type = res.type;
item.timestamp = res.timestamp;
items.push(item);
});
cb(items);
});
}
};