1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Include jitter in track statistics.

This commit is contained in:
Juliusz Chroboczek 2020-05-02 16:32:34 +02:00
parent 4dd245712f
commit 98a1776ce7
2 changed files with 17 additions and 2 deletions

View file

@ -654,6 +654,7 @@ type trackStats struct {
bitrate uint64 bitrate uint64
maxBitrate uint64 maxBitrate uint64
loss uint8 loss uint8
jitter time.Duration
} }
func getGroupStats() []groupStats { func getGroupStats() []groupStats {
@ -701,10 +702,14 @@ func getClientStats(c *client) clientStats {
if expected == 0 { if expected == 0 {
expected = 1 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{ conns.tracks = append(conns.tracks, trackStats{
bitrate: uint64(t.rate.Estimate()) * 8, bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: atomic.LoadUint64(&t.maxBitrate), maxBitrate: atomic.LoadUint64(&t.maxBitrate),
loss: uint8(lost * 100 / expected), loss: loss,
jitter: jitter,
}) })
} }
cs.up = append(cs.up, conns) cs.up = append(cs.up, conns)
@ -717,10 +722,14 @@ func getClientStats(c *client) clientStats {
conns := connStats{id: down.id} conns := connStats{id: down.id}
for _, t := range down.tracks { for _, t := range down.tracks {
loss := atomic.LoadUint32(&t.loss) 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{ conns.tracks = append(conns.tracks, trackStats{
bitrate: uint64(t.rate.Estimate()) * 8, bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: t.maxBitrate.Get(mono.Microseconds()), maxBitrate: t.maxBitrate.Get(mono.Microseconds()),
loss: uint8((loss * 100) / 256), loss: uint8((loss * 100) / 256),
jitter: jitter,
}) })
} }
cs.down = append(cs.down, conns) cs.down = append(cs.down, conns)

8
sfu.go
View file

@ -171,9 +171,15 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<td>") fmt.Fprintf(w, "<td>")
printBitrate(w, t.bitrate, t.maxBitrate) printBitrate(w, t.bitrate, t.maxBitrate)
fmt.Fprintf(w, "</td>") fmt.Fprintf(w, "</td>")
fmt.Fprintf(w, "<td>%d%%</td></tr>\n", fmt.Fprintf(w, "<td>%d%%</td>",
t.loss, 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 { for _, gs := range stats {