Revert "Temporary change: use pre-defined rids" (#3769)
* Revert "Temporary change: use pre-defined rids (#3767)"
This reverts commit d11da5f5fa.
* clean up
* add test and simplify
* clean up
This commit is contained in:
@@ -348,11 +348,8 @@ func GetSpatialLayerForRid(rid string, ti *livekit.TrackInfo) int32 {
|
||||
}
|
||||
}
|
||||
|
||||
if len(ti.Layers) == 1 {
|
||||
// single layer without RID
|
||||
return 0
|
||||
} else if len(ti.Layers) > 1 {
|
||||
// RID present in codec, but not specified via signalling
|
||||
if len(ti.Layers) != 0 {
|
||||
// RID present in codec, but may not be specified via signalling
|
||||
// (happens with older browsers setting a rid for SVC codecs)
|
||||
hasRid := false
|
||||
for _, layer := range ti.Layers {
|
||||
|
||||
@@ -499,6 +499,20 @@ func TestGetSpatialLayerForRid(t *testing.T) {
|
||||
FullResolution: InvalidLayerSpatial,
|
||||
},
|
||||
},
|
||||
{
|
||||
"layers - no rid",
|
||||
&livekit.TrackInfo{
|
||||
Layers: []*livekit.VideoLayer{
|
||||
{Quality: livekit.VideoQuality_LOW, SpatialLayer: 0},
|
||||
{Quality: livekit.VideoQuality_MEDIUM, SpatialLayer: 1},
|
||||
},
|
||||
},
|
||||
map[string]int32{
|
||||
QuarterResolution: 0,
|
||||
HalfResolution: 0,
|
||||
FullResolution: 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
+2
-3
@@ -383,7 +383,7 @@ func (w *WebRTCReceiver) AddUpTrack(track TrackRemote, buff *buffer.Buffer) erro
|
||||
|
||||
layer := int32(0)
|
||||
if w.Kind() == webrtc.RTPCodecTypeVideo && !w.isSVC {
|
||||
layer = buffer.RidToSpatialLayer(track.RID(), w.trackInfo.Load(), buffer.DefaultVideoLayersRid)
|
||||
layer = buffer.GetSpatialLayerForRid(track.RID(), w.trackInfo.Load())
|
||||
}
|
||||
if layer < 0 {
|
||||
w.logger.Warnw(
|
||||
@@ -499,8 +499,7 @@ func (w *WebRTCReceiver) notifyMaxExpectedLayer(layer int32) {
|
||||
|
||||
expectedBitrate := int64(0)
|
||||
for _, vl := range ti.Layers {
|
||||
l := buffer.VideoQualityToSpatialLayer(vl.Quality, ti)
|
||||
if l <= layer {
|
||||
if vl.SpatialLayer <= layer {
|
||||
expectedBitrate += int64(vl.Bitrate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,8 +597,7 @@ func (s *StreamTrackerManager) maxExpectedLayerFromTrackInfoLocked() {
|
||||
ti := s.trackInfo.Load()
|
||||
if ti != nil {
|
||||
for _, layer := range ti.Layers {
|
||||
spatialLayer := buffer.VideoQualityToSpatialLayer(layer.Quality, ti)
|
||||
if spatialLayer > s.maxExpectedLayer {
|
||||
if layer.SpatialLayer > s.maxExpectedLayer {
|
||||
s.maxExpectedLayer = layer.SpatialLayer
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user