From 91fa6937091d808bf17ec261427db6404cc1d7ce Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 17 May 2021 13:51:29 +0200 Subject: [PATCH] Display max layer in stats. --- rtpconn/rtpstats.go | 6 +++--- static/stats.js | 3 ++- stats/stats.go | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rtpconn/rtpstats.go b/rtpconn/rtpstats.go index dee64b9..98f17c4 100644 --- a/rtpconn/rtpstats.go +++ b/rtpconn/rtpstats.go @@ -49,8 +49,7 @@ func (c *webClient) GetStats() *stats.Client { Id: down.id, } for _, t := range down.tracks { - l, _, _ := t.getLayerInfo() - layer := int(l) + l, _, ml := t.getLayerInfo() rate, _ := t.rate.Estimate() rtt := rtptime.ToDuration(t.getRTT(), rtptime.JiffiesPerSec) @@ -58,7 +57,8 @@ func (c *webClient) GetStats() *stats.Client { j := time.Duration(jitter) * time.Second / time.Duration(t.track.Codec().ClockRate) conns.Tracks = append(conns.Tracks, stats.Track{ - Layer: &layer, + Layer: &l, + MaxLayer: &ml, Bitrate: uint64(rate) * 8, MaxBitrate: t.maxBitrate.Get(jiffies), Loss: float64(loss) / 256.0, diff --git a/static/stats.js b/static/stats.js index 6290015..bb67547 100644 --- a/static/stats.js +++ b/static/stats.js @@ -95,7 +95,8 @@ function formatTrack(table, track) { tr.appendChild(document.createElement('td')); tr.appendChild(document.createElement('td')); let td = document.createElement('td'); - td.textContent = track.layer; + if(track.layer && track.maxLayer) + td.textContent = `${track.layer}/${track.maxLayer}`; tr.appendChild(td); let td2 = document.createElement('td'); if(track.maxBitrate) diff --git a/stats/stats.go b/stats/stats.go index 073e218..1a0d0b6 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -47,7 +47,8 @@ func (d *Duration) UnmarshalJSON(buf []byte) error { } type Track struct { - Layer *int `json:"layer,omitempty"` + Layer *uint8 `json:"layer,omitempty"` + MaxLayer *uint8 `json:"maxLayer,omitempty"` Bitrate uint64 `json:"bitrate"` MaxBitrate uint64 `json:"maxBitrate,omitempty"` Loss float64 `json:"loss"`