Commit 98a1776c authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Include jitter in track statistics.

parent 4dd24571
......@@ -654,6 +654,7 @@ type trackStats struct {
bitrate uint64
maxBitrate uint64
loss uint8
jitter time.Duration
}
func getGroupStats() []groupStats {
......@@ -701,10 +702,14 @@ func getClientStats(c *client) clientStats {
if expected == 0 {
expected = 1
}
loss := uint8(lost * 100 / expected)
jitter := time.Duration(t.jitter.Jitter()) *
(time.Second / time.Duration(t.jitter.HZ()))
conns.tracks = append(conns.tracks, trackStats{
bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: atomic.LoadUint64(&t.maxBitrate),
loss: uint8(lost * 100 / expected),
loss: loss,
jitter: jitter,
})
}
cs.up = append(cs.up, conns)
......@@ -717,10 +722,14 @@ func getClientStats(c *client) clientStats {
conns := connStats{id: down.id}
for _, t := range down.tracks {
loss := atomic.LoadUint32(&t.loss)
jitter := time.Duration(atomic.LoadUint32(&t.jitter)) *
time.Second /
time.Duration(t.track.Codec().ClockRate)
conns.tracks = append(conns.tracks, trackStats{
bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: t.maxBitrate.Get(mono.Microseconds()),
loss: uint8((loss * 100) / 256),
jitter: jitter,
})
}
cs.down = append(cs.down, conns)
......
......@@ -171,9 +171,15 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<td>")
printBitrate(w, t.bitrate, t.maxBitrate)
fmt.Fprintf(w, "</td>")
fmt.Fprintf(w, "<td>%d%%</td></tr>\n",
fmt.Fprintf(w, "<td>%d%%</td>",
t.loss,
)
if t.jitter > 0 {
fmt.Fprintf(w, "<td>%v</td>", t.jitter)
} else {
fmt.Fprintf(w, "<td></td>")
}
fmt.Fprintf(w, "</tr>")
}
for _, gs := range stats {
......
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