mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Display actual rate in statistics.
This commit is contained in:
parent
5dd27e5067
commit
118ad7a3a7
2 changed files with 14 additions and 9 deletions
7
group.go
7
group.go
|
@ -644,6 +644,7 @@ type connStats struct {
|
||||||
|
|
||||||
type trackStats struct {
|
type trackStats struct {
|
||||||
bitrate uint64
|
bitrate uint64
|
||||||
|
maxBitrate uint64
|
||||||
loss uint8
|
loss uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +694,8 @@ func getClientStats(c *client) clientStats {
|
||||||
expected = 1
|
expected = 1
|
||||||
}
|
}
|
||||||
conns.tracks = append(conns.tracks, trackStats{
|
conns.tracks = append(conns.tracks, trackStats{
|
||||||
bitrate: atomic.LoadUint64(&t.maxBitrate),
|
bitrate: uint64(t.rate.Estimate()) * 8,
|
||||||
|
maxBitrate: atomic.LoadUint64(&t.maxBitrate),
|
||||||
loss: uint8(lost * 100 / expected),
|
loss: uint8(lost * 100 / expected),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -708,7 +710,8 @@ func getClientStats(c *client) clientStats {
|
||||||
for _, t := range down.tracks {
|
for _, t := range down.tracks {
|
||||||
loss := atomic.LoadUint32(&t.loss)
|
loss := atomic.LoadUint32(&t.loss)
|
||||||
conns.tracks = append(conns.tracks, trackStats{
|
conns.tracks = append(conns.tracks, trackStats{
|
||||||
bitrate: atomic.LoadUint64(&t.maxBitrate.bitrate),
|
bitrate: uint64(t.rate.Estimate()) * 8,
|
||||||
|
maxBitrate: atomic.LoadUint64(&t.maxBitrate.bitrate),
|
||||||
loss: uint8((loss * 100) / 256),
|
loss: uint8((loss * 100) / 256),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
8
sfu.go
8
sfu.go
|
@ -156,9 +156,11 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "<title>Stats</title>\n")
|
fmt.Fprintf(w, "<title>Stats</title>\n")
|
||||||
fmt.Fprintf(w, "<head><body>\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
|
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)
|
_, err = fmt.Fprintf(w, "%v", rate)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -167,7 +169,7 @@ func statsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
printTrack := func(w io.Writer, t trackStats) {
|
printTrack := func(w io.Writer, t trackStats) {
|
||||||
fmt.Fprintf(w, "<tr><td></td><td></td><td></td>")
|
fmt.Fprintf(w, "<tr><td></td><td></td><td></td>")
|
||||||
fmt.Fprintf(w, "<td>")
|
fmt.Fprintf(w, "<td>")
|
||||||
printBitrate(w, t.bitrate)
|
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></tr>\n",
|
||||||
t.loss,
|
t.loss,
|
||||||
|
|
Loading…
Reference in a new issue