mirror of
https://github.com/jech/galene.git
synced 2024-12-22 15:25:48 +01:00
Export the max requested rate in track statistics.
This commit is contained in:
parent
200c0dd68c
commit
56226a2934
2 changed files with 48 additions and 44 deletions
|
@ -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 {
|
||||
tracks := up.getTracks()
|
||||
|
||||
|
@ -923,47 +966,7 @@ func sendUpRTCP(up *rtpUpConnection) error {
|
|||
} else if t.Label() == "l" {
|
||||
rate += group.LowBitrate
|
||||
} else {
|
||||
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 {
|
||||
rate += minrate
|
||||
} else {
|
||||
rate += maxrate
|
||||
}
|
||||
rate += maxUpBitrate(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,10 @@ func (c *webClient) GetStats() *stats.Client {
|
|||
(time.Second / time.Duration(t.jitter.HZ()))
|
||||
rate, _ := t.rate.Estimate()
|
||||
conns.Tracks = append(conns.Tracks, stats.Track{
|
||||
Bitrate: uint64(rate) * 8,
|
||||
Loss: loss,
|
||||
Jitter: stats.Duration(jitter),
|
||||
Bitrate: uint64(rate) * 8,
|
||||
MaxBitrate: maxUpBitrate(t),
|
||||
Loss: loss,
|
||||
Jitter: stats.Duration(jitter),
|
||||
})
|
||||
}
|
||||
cs.Up = append(cs.Up, conns)
|
||||
|
|
Loading…
Reference in a new issue