Commit 95846ae4 authored by 神楽坂玲奈's avatar 神楽坂玲奈

Merge remote-tracking branch 'origin/master'

parents d41f24ce c5954785
......@@ -28,6 +28,7 @@ export class Peer implements Hello, PeerQuality, RouterConfig {
reset() {
this.delay = 0;
this.reliability = 0;
this.jitter = 0;
this.seq = 0;
this.time = 0;
this.history = [];
......@@ -59,6 +60,11 @@ export class Peer implements Hello, PeerQuality, RouterConfig {
this.reliability = history.length / config.history;
this.delay = _.mean(history) || 0;
let jitterSum = 0;
for (let i = 0; i < history.length - 1; i++) {
jitterSum[i] += Math.abs(history[i] - history[i + 1]);
}
this.jitter = (jitterSum / history.length - 1) || 0;
this.seq = data.seq;
this.time = time;
......@@ -73,10 +79,12 @@ export class Peer implements Hello, PeerQuality, RouterConfig {
}
}
const lost = Math.max(0, (time - this.time) / config.interval - 2);
return {
delay: Math.round(this.delay),
jitter: 0,
reliability: this.reliability
jitter: Math.round(this.jitter),
reliability: Math.max(0, this.reliability - lost / config.history)
};
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment