Separate out max layer setting (#201)
Small step on the way to making StreamAllocator prioritization of tracks. With the new callback into StreamAllocator, the idea is to use the max layer information to do track prioritization. Testing: -------- Sanity check that sample app works
This commit is contained in:
@@ -462,6 +462,7 @@ func (t *MediaTrack) GetQualityForDimension(width, height uint32) livekit.VideoQ
|
||||
return quality
|
||||
}
|
||||
|
||||
// LK-TODO: this should probably left up to auto size management and StreamAllocator
|
||||
// this function assumes caller holds lock
|
||||
func (t *MediaTrack) shouldStartWithBestQuality() bool {
|
||||
return len(t.subscribedTracks) < 10
|
||||
|
||||
@@ -62,10 +62,17 @@ func (t *SubscribedTrack) UpdateSubscriberSettings(enabled bool, quality livekit
|
||||
t.subMuted.TrySet(!enabled)
|
||||
t.updateDownTrackMute()
|
||||
if enabled && t.dt.Kind() == webrtc.RTPCodecTypeVideo {
|
||||
err := t.dt.SwitchSpatialLayer(spatialLayerForQuality(quality), true)
|
||||
err := t.dt.SetMaxSpatialLayer(spatialLayerForQuality(quality))
|
||||
// LK-TODO-START
|
||||
// For now, this set max calls into switchSpatialLayer and returns the result.
|
||||
// When StreamAllocator becomes the one true way to allocate layers,
|
||||
// there will not a ErrSpatialLayerNotFound error as the allocation
|
||||
// logic will automatically the best available layer under the max layer.
|
||||
// So, this check should be removed when enabling StreamAllocator
|
||||
// LK-TODO-END
|
||||
if err == sfu.ErrSpatialLayerNotFound && quality != livekit.VideoQuality_MEDIUM {
|
||||
// try to switch to middle layer
|
||||
_ = t.dt.SwitchSpatialLayer(spatialLayerForQuality(livekit.VideoQuality_MEDIUM), true)
|
||||
_ = t.dt.SetMaxSpatialLayer(spatialLayerForQuality(livekit.VideoQuality_MEDIUM))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user