Use current layer for actual dimension when calculating quality of muxed (#773)

tracks.
This commit is contained in:
Raja Subramanian authored and GitHub committed 2022-06-21 11:31:51 +05:30
1 parent 301bd2771c
commit ac1e55fa27
2 files changed
+23 -10

No files matched your search

+20 -10
View File
@@ -19,16 +19,17 @@ const (
)
type ConnectionStatsParams struct {
UpdateInterval time.Duration
CodecType webrtc.RTPCodecType
CodecName string
MimeType string
GetDeltaStats func() map[uint32]*buffer.StreamStatsWithLayers
IsDtxDisabled func() bool
GetLayerDimension func(int32) (uint32, uint32)
GetMaxExpectedLayer func() *livekit.VideoLayer
GetIsReducedQuality func() bool
Logger logger.Logger
UpdateInterval time.Duration
CodecType webrtc.RTPCodecType
CodecName string
MimeType string
GetDeltaStats func() map[uint32]*buffer.StreamStatsWithLayers
IsDtxDisabled func() bool
GetLayerDimension func(int32) (uint32, uint32)
GetMaxExpectedLayer func() *livekit.VideoLayer
GetCurrentLayerSpatial func() int32
GetIsReducedQuality func() bool
Logger logger.Logger
}
type ConnectionStats struct {
@@ -130,6 +131,15 @@ func (cs *ConnectionStats) updateScore(streams map[uint32]*buffer.StreamStatsWit
}
if maxAvailableLayerStats != nil {
// for muxed tracks, i. e. simulcast publisher muxed into a single track,
// use the current spatial layer.
// NOTE: This is still not perfect as muxing means layers could have changed
// in the analysis window. Needs a more complex design to keep track of all layer
// switches to be able to do precise calculations. As the window is small,
// using the current and maximum is a reasonable approximation.
if cs.params.GetCurrentLayerSpatial != nil {
maxAvailableLayer = cs.params.GetCurrentLayerSpatial()
}
params.ActualWidth, params.ActualHeight = cs.params.GetLayerDimension(maxAvailableLayer)
}
+3
View File
@@ -233,6 +233,9 @@ func NewDownTrack(
width, height := d.receiver.GetLayerDimension(maxLayer)
return &livekit.VideoLayer{Quality: utils.QualityForSpatialLayer(maxLayer), Width: width, Height: height}
},
GetCurrentLayerSpatial: func() int32 {
return d.forwarder.CurrentLayers().Spatial
},
GetIsReducedQuality: func() bool {
return d.GetForwardingStatus() != ForwardingStatusOptimal
},