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

Export the max requested rate in track statistics.

This commit is contained in:
Juliusz Chroboczek 2021-08-03 03:28:36 +02:00
parent 200c0dd68c
commit 56226a2934
2 changed files with 48 additions and 44 deletions

View file

@ -853,6 +853,49 @@ func rtcpUpListener(track *rtpUpTrack) {
} }
} }
func maxUpBitrate(t *rtpUpTrack) uint64 {
minrate := ^uint64(0)
maxrate := uint64(group.MinBitrate)
maxsid := 0
maxtid := 0
local := t.getLocal()
for _, down := range local {
r, sid, tid := down.GetMaxBitrate()
if maxsid < sid {
maxsid = sid
}
if maxtid < tid {
maxtid = tid
}
if r < group.MinBitrate {
r = group.MinBitrate
}
if minrate > r {
minrate = r
}
if maxrate < r {
maxrate = r
}
}
// assume that lower spatial layers take up 1/5 of
// the throughput
if maxsid > 0 {
maxrate = maxrate * 5 / 4
}
// assume that each layer takes two times less
// throughput than the higher one. Then we've
// got enough slack for a factor of 2^(layers-1).
for i := 0; i < maxtid; i++ {
if minrate < ^uint64(0)/2 {
minrate *= 2
}
}
if minrate < maxrate {
return minrate
}
return maxrate
}
func sendUpRTCP(up *rtpUpConnection) error { func sendUpRTCP(up *rtpUpConnection) error {
tracks := up.getTracks() tracks := up.getTracks()
@ -923,47 +966,7 @@ func sendUpRTCP(up *rtpUpConnection) error {
} else if t.Label() == "l" { } else if t.Label() == "l" {
rate += group.LowBitrate rate += group.LowBitrate
} else { } else {
minrate := ^uint64(0) rate += maxUpBitrate(t)
maxrate := uint64(group.MinBitrate)
maxsid := 0
maxtid := 0
local := t.getLocal()
for _, down := range local {
r, sid, tid := down.GetMaxBitrate()
if maxsid < sid {
maxsid = sid
}
if maxtid < tid {
maxtid = tid
}
if r < group.MinBitrate {
r = group.MinBitrate
}
if minrate > r {
minrate = r
}
if maxrate < r {
maxrate = r
}
}
// assume that lower spatial layers take up 1/5 of
// the throughput
if maxsid > 0 {
maxrate = maxrate * 5 / 4
}
// assume that each layer takes two times less
// throughput than the higher one. Then we've
// got enough slack for a factor of 2^(layers-1).
for i := 0; i < maxtid; i++ {
if minrate < ^uint64(0)/2 {
minrate *= 2
}
}
if minrate < maxrate {
rate += minrate
} else {
rate += maxrate
}
} }
} }

View file

@ -32,9 +32,10 @@ func (c *webClient) GetStats() *stats.Client {
(time.Second / time.Duration(t.jitter.HZ())) (time.Second / time.Duration(t.jitter.HZ()))
rate, _ := t.rate.Estimate() rate, _ := t.rate.Estimate()
conns.Tracks = append(conns.Tracks, stats.Track{ conns.Tracks = append(conns.Tracks, stats.Track{
Bitrate: uint64(rate) * 8, Bitrate: uint64(rate) * 8,
Loss: loss, MaxBitrate: maxUpBitrate(t),
Jitter: stats.Duration(jitter), Loss: loss,
Jitter: stats.Duration(jitter),
}) })
} }
cs.Up = append(cs.Up, conns) cs.Up = append(cs.Up, conns)