Smoother dynacast transition (#390)

This commit is contained in:
Raja Subramanian
2022-01-31 07:47:24 +05:30
committed by GitHub
parent a1f88faed1
commit 745939ec24
10 changed files with 159 additions and 144 deletions
+23 -15
View File
@@ -117,11 +117,12 @@ const (
)
type TranslationParams struct {
shouldDrop bool
isDroppingRelevant bool
shouldSendPLI bool
rtp *TranslationParamsRTP
vp8 *TranslationParamsVP8
shouldDrop bool
isDroppingRelevant bool
shouldSendPLI bool
isSwitchingToMaxLayer bool
rtp *TranslationParamsRTP
vp8 *TranslationParamsVP8
}
type VideoLayers struct {
@@ -137,6 +138,10 @@ func (v VideoLayers) GreaterThan(v2 VideoLayers) bool {
return v.spatial > v2.spatial || (v.spatial == v2.spatial && v.temporal > v2.temporal)
}
func (v VideoLayers) SpatialGreaterThanOrEqual(v2 VideoLayers) bool {
return v.spatial >= v2.spatial
}
const (
InvalidLayerSpatial = int32(-1)
InvalidLayerTemporal = int32(-1)
@@ -211,49 +216,49 @@ func NewForwarder(codec webrtc.RTPCodecCapability, kind webrtc.RTPCodecType, log
return f
}
func (f *Forwarder) Mute(val bool) bool {
func (f *Forwarder) Mute(val bool) (bool, VideoLayers) {
f.lock.Lock()
defer f.lock.Unlock()
if f.muted == val {
return false
return false, f.maxLayers
}
f.muted = val
return true
return true, f.maxLayers
}
func (f *Forwarder) Muted() bool {
func (f *Forwarder) IsMuted() bool {
f.lock.RLock()
defer f.lock.RUnlock()
return f.muted
}
func (f *Forwarder) SetMaxSpatialLayer(spatialLayer int32) (bool, VideoLayers) {
func (f *Forwarder) SetMaxSpatialLayer(spatialLayer int32) (bool, VideoLayers, VideoLayers) {
f.lock.Lock()
defer f.lock.Unlock()
if f.kind == webrtc.RTPCodecTypeAudio || spatialLayer == f.maxLayers.spatial {
return false, InvalidLayers
return false, f.maxLayers, f.currentLayers
}
f.maxLayers.spatial = spatialLayer
return true, f.maxLayers
return true, f.maxLayers, f.currentLayers
}
func (f *Forwarder) SetMaxTemporalLayer(temporalLayer int32) (bool, VideoLayers) {
func (f *Forwarder) SetMaxTemporalLayer(temporalLayer int32) (bool, VideoLayers, VideoLayers) {
f.lock.Lock()
defer f.lock.Unlock()
if f.kind == webrtc.RTPCodecTypeAudio || temporalLayer == f.maxLayers.temporal {
return false, InvalidLayers
return false, f.maxLayers, f.currentLayers
}
f.maxLayers.temporal = temporalLayer
return true, f.maxLayers
return true, f.maxLayers, f.currentLayers
}
func (f *Forwarder) MaxLayers() VideoLayers {
@@ -1118,6 +1123,9 @@ func (f *Forwarder) getTranslationParamsVideo(extPkt *buffer.ExtPacket, layer in
if extPkt.KeyFrame {
// lock to target layer
f.currentLayers.spatial = f.targetLayers.spatial
if f.currentLayers.spatial == f.maxLayers.spatial {
tp.isSwitchingToMaxLayer = true
}
} else {
tp.shouldSendPLI = true
}