1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 18:25:58 +01:00

Display actual rate in statistics.

This commit is contained in:
Juliusz Chroboczek 2020-04-30 20:33:04 +02:00
parent 5dd27e5067
commit 118ad7a3a7
2 changed files with 14 additions and 9 deletions

View file

@ -643,8 +643,9 @@ type connStats struct {
}
type trackStats struct {
bitrate uint64
loss uint8
bitrate uint64
maxBitrate uint64
loss uint8
}
func getGroupStats() []groupStats {
@ -693,8 +694,9 @@ func getClientStats(c *client) clientStats {
expected = 1
}
conns.tracks = append(conns.tracks, trackStats{
bitrate: atomic.LoadUint64(&t.maxBitrate),
loss: uint8(lost * 100 / expected),
bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: atomic.LoadUint64(&t.maxBitrate),
loss: uint8(lost * 100 / expected),
})
}
cs.up = append(cs.up, conns)
@ -708,8 +710,9 @@ func getClientStats(c *client) clientStats {
for _, t := range down.tracks {
loss := atomic.LoadUint32(&t.loss)
conns.tracks = append(conns.tracks, trackStats{
bitrate: atomic.LoadUint64(&t.maxBitrate.bitrate),
loss: uint8((loss * 100) / 256),
bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: atomic.LoadUint64(&t.maxBitrate.bitrate),
loss: uint8((loss * 100) / 256),
})
}
cs.down = append(cs.down, conns)

8
sfu.go
View file

@ -156,9 +156,11 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<title>Stats</title>\n")
fmt.Fprintf(w, "<head><body>\n")
printBitrate := func(w io.Writer, rate uint64) error {
printBitrate := func(w io.Writer, rate, maxRate uint64) error {
var err error
if rate != 0 && rate != ^uint64(0) {
if maxRate != 0 && maxRate != ^uint64(0) {
_, err = fmt.Fprintf(w, "%v/%v", rate, maxRate)
} else {
_, err = fmt.Fprintf(w, "%v", rate)
}
return err
@ -167,7 +169,7 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
printTrack := func(w io.Writer, t trackStats) {
fmt.Fprintf(w, "<tr><td></td><td></td><td></td>")
fmt.Fprintf(w, "<td>")
printBitrate(w, t.bitrate)
printBitrate(w, t.bitrate, t.maxBitrate)
fmt.Fprintf(w, "</td>")
fmt.Fprintf(w, "<td>%d%%</td></tr>\n",
t.loss,