Expected vs actual Layer based connection quality. (#1509)

* Expected vs actual Layer based connection quality.

With VBR streams (like screen share), bit rate is not a good indicator
of whether desired layer (spatial/temporal) is achieved due to high
variance.

Using expected vs actual layer (i. e. distance to desired) can capture
any short fall and include it in quality scoring.

This PR uses distance to desired, i. e. how many steps it would take to
go from actual spatial/temporal -> desired spatial/temporal and that
distance is propotionally used (currently it is just linear) to decrease
score.

* wire up layer transitions for screen share tracks
This commit is contained in:
Raja Subramanian
2023-03-10 13:08:36 +05:30
committed by GitHub
parent e893d30fd0
commit c70aa616a9
9 changed files with 419 additions and 104 deletions
+20 -10
View File
@@ -29,6 +29,7 @@ type TrackSender interface {
UpTrackLayersChange()
UpTrackBitrateAvailabilityChange()
UpTrackMaxPublishedLayerChange(maxPublishedLayer int32)
UpTrackMaxTemporalLayerSeenChange(maxTemporalLayerSeen int32)
UpTrackBitrateReport(availableLayers []int32, bitrates Bitrates)
WriteRTP(p *buffer.ExtPacket, layer int32) error
Close()
@@ -877,21 +878,29 @@ func (d *DownTrack) UpTrackMaxPublishedLayerChange(maxPublishedLayer int32) {
}
}
func (d *DownTrack) maybeAddTransition(bitrate int64) {
func (d *DownTrack) UpTrackMaxTemporalLayerSeenChange(maxTemporalLayerSeen int32) {
d.forwarder.SetMaxTemporalLayerSeen(maxTemporalLayerSeen)
}
func (d *DownTrack) maybeAddTransition(bitrate int64, distance float64) {
if d.kind == webrtc.RTPCodecTypeAudio {
return
}
ti := d.receiver.TrackInfo()
if ti == nil || ti.Source == livekit.TrackSource_SCREEN_SHARE {
if ti == nil {
return
}
d.connectionStats.AddTransition(bitrate, time.Now())
if ti.Source == livekit.TrackSource_SCREEN_SHARE {
d.connectionStats.AddLayerTransition(distance, time.Now())
}
d.connectionStats.AddBitrateTransition(bitrate, time.Now())
}
func (d *DownTrack) UpTrackBitrateReport(_availableLayers []int32, bitrates Bitrates) {
d.maybeAddTransition(d.forwarder.GetOptimalBandwidthNeeded(bitrates))
d.maybeAddTransition(d.forwarder.GetOptimalBandwidthNeeded(bitrates), d.forwarder.DistanceToDesired(bitrates))
}
// OnCloseHandler method to be called on remote tracked removed
@@ -974,15 +983,16 @@ func (d *DownTrack) BandwidthRequested() int64 {
return d.forwarder.BandwidthRequested(brs)
}
func (d *DownTrack) DistanceToDesired() int32 {
return d.forwarder.DistanceToDesired()
func (d *DownTrack) DistanceToDesired() float64 {
_, brs := d.receiver.GetLayeredBitrate()
return d.forwarder.DistanceToDesired(brs)
}
func (d *DownTrack) AllocateOptimal(allowOvershoot bool) VideoAllocation {
al, brs := d.receiver.GetLayeredBitrate()
allocation := d.forwarder.AllocateOptimal(al, brs, allowOvershoot)
d.maybeStartKeyFrameRequester()
d.maybeAddTransition(allocation.bandwidthNeeded)
d.maybeAddTransition(allocation.bandwidthNeeded, allocation.distanceToDesired)
return allocation
}
@@ -1010,7 +1020,7 @@ func (d *DownTrack) ProvisionalAllocateGetBestWeightedTransition() VideoTransiti
func (d *DownTrack) ProvisionalAllocateCommit() VideoAllocation {
allocation := d.forwarder.ProvisionalAllocateCommit()
d.maybeStartKeyFrameRequester()
d.maybeAddTransition(allocation.bandwidthNeeded)
d.maybeAddTransition(allocation.bandwidthNeeded, allocation.distanceToDesired)
return allocation
}
@@ -1018,7 +1028,7 @@ func (d *DownTrack) AllocateNextHigher(availableChannelCapacity int64, allowOver
_, brs := d.receiver.GetLayeredBitrate()
allocation, available := d.forwarder.AllocateNextHigher(availableChannelCapacity, brs, allowOvershoot)
d.maybeStartKeyFrameRequester()
d.maybeAddTransition(allocation.bandwidthNeeded)
d.maybeAddTransition(allocation.bandwidthNeeded, allocation.distanceToDesired)
return allocation, available
}
@@ -1033,7 +1043,7 @@ func (d *DownTrack) Pause() VideoAllocation {
_, brs := d.receiver.GetLayeredBitrate()
allocation := d.forwarder.Pause(brs)
d.maybeStartKeyFrameRequester()
d.maybeAddTransition(allocation.bandwidthNeeded)
d.maybeAddTransition(allocation.bandwidthNeeded, allocation.distanceToDesired)
return allocation
}