Commit 118ad7a3 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Display actual rate in statistics.

parent 5dd27e50
......@@ -644,6 +644,7 @@ type connStats struct {
type trackStats struct {
bitrate uint64
maxBitrate uint64
loss uint8
}
......@@ -693,7 +694,8 @@ func getClientStats(c *client) clientStats {
expected = 1
}
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),
})
}
......@@ -708,7 +710,8 @@ 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),
bitrate: uint64(t.rate.Estimate()) * 8,
maxBitrate: atomic.LoadUint64(&t.maxBitrate.bitrate),
loss: uint8((loss * 100) / 256),
})
}
......
......@@ -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,
......
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