Commit 825f094c authored by 神楽坂玲奈's avatar 神楽坂玲奈 Committed by 铃兰

jitter

parent 5d7de5f9
......@@ -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;
......@@ -75,7 +81,7 @@ export class Peer implements Hello, PeerQuality, RouterConfig {
return {
delay: Math.round(this.delay),
jitter: 0,
jitter: Math.round(this.jitter),
reliability: this.reliability
};
}
......
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