mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Include jitter in track statistics.
This commit is contained in:
parent
4dd245712f
commit
98a1776ce7
2 changed files with 17 additions and 2 deletions
11
group.go
11
group.go
|
@ -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)
|
||||
|
|
8
sfu.go
8
sfu.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue