Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
add stats logging with max 600 values backlog - fixes #2
Philipp Hanckec1d9917e001a
diff --git a/app.js b/app.jsindex 79605bd833..1a811351ab 100644--- a/app.js+++ b/app.js@@ -513,8 +513,13 @@ function dump(elem, filename){var session = connection.jingle.sessions[sid];if (session.peerconnection && session.peerconnection.updateLog) {// FIXME: should probably be a .dump call+ var stats = JSON.parse(JSON.stringify(session.peerconnection.stats));+ Object.keys(stats).forEach(function (name) {+ stats[name].values = JSON.stringify(stats[name].values);+ });data["jingle_" + session.sid] = {updateLog: session.peerconnection.updateLog,+ stats: stats,url: window.location.href};}diff --git a/libs/strophejingle.bundle.js b/libs/strophejingle.bundle.jsindex b5512f3e6a..215da23a50 100644--- a/libs/strophejingle.bundle.js+++ b/libs/strophejingle.bundle.js@@ -4,6 +4,7 @@ function TraceablePeerConnection(ice_config, constraints) {var RTCPeerconnection = navigator.mozGetUserMedia ? mozRTCPeerConnection : webkitRTCPeerConnection;this.peerconnection = new RTCPeerconnection(ice_config, constraints);this.updateLog = [];+ this.stats = {};// override as desiredthis.trace = function(what, info) {@@ -16,7 +17,7 @@ function TraceablePeerConnection(ice_config, constraints) {};this.onicecandidate = null;this.peerconnection.onicecandidate = function (event) {- self.trace('onicecandidate', JSON.stringify(event.candidate));+ self.trace('onicecandidate', JSON.stringify(event.candidate, null, ' '));if (self.onicecandidate !== null) {self.onicecandidate(event);}@@ -63,6 +64,32 @@ function TraceablePeerConnection(ice_config, constraints) {self.ondatachannel(event);}}+ this.maxstats = 600; // limit to 600 values, i.e. 10 minutes+ this.statsinterval = window.setInterval(function() {+ self.peerconnection.getStats(function(stats) {+ var results = stats.result();+ for (var i = 0; i < results.length; ++i) {+ //console.log(results[i].type, results[i].id, results[i].names())+ var now = new Date();+ results[i].names().forEach(function (name) {+ var id = results[i].id + '-' + name;+ if (!self.stats[id]) {+ self.stats[id] = {+ startTime: now,+ endTime: now,+ values: []+ };+ }+ self.stats[id].values.push(results[i].stat(name));+ if (self.stats[id].values.length > self.maxstats) {+ self.stats[id].values.shift();+ }+ self.stats[id].endTime = now;+ });+ }+ });++ }, 1000);};dumpSDP = function(description) {@@ -126,7 +153,7 @@ TraceablePeerConnection.prototype.close = function () {TraceablePeerConnection.prototype.createOffer = function (successCallback, failureCallback, constraints) {var self = this;- this.trace('createOffer', JSON.stringify(constraints, null, " "));+ this.trace('createOffer', JSON.stringify(constraints, null, ' '));this.peerconnection.createOffer(function (offer) {self.trace('createOfferOnSuccess', dumpSDP(offer));@@ -142,7 +169,7 @@ TraceablePeerConnection.prototype.createOffer = function (successCallback, failuTraceablePeerConnection.prototype.createAnswer = function (successCallback, failureCallback, constraints) {var self = this;- this.trace('createAnswer', JSON.stringify(constraints, null, " "));+ this.trace('createAnswer', JSON.stringify(constraints, null, ' '));this.peerconnection.createAnswer(function (answer) {self.trace('createAnswerOnSuccess', dumpSDP(answer));@@ -158,7 +185,7 @@ TraceablePeerConnection.prototype.createAnswer = function (successCallback, failTraceablePeerConnection.prototype.addIceCandidate = function (candidate, successCallback, failureCallback) {var self = this;- this.trace('addIceCandidate', JSON.stringify(candidate));+ this.trace('addIceCandidate', JSON.stringify(candidate, null, ' '));this.peerconnection.addIceCandidate(candidate);/* maybe laterthis.peerconnection.addIceCandidate(candidate,