refine dynacast pause delay (#558)
* refine dynacast pause delay * fix test
This commit is contained in:
@@ -175,7 +175,7 @@ func TestSubscribedMaxQuality(t *testing.T) {
|
||||
},
|
||||
},
|
||||
VideoConfig: config.VideoConfig{
|
||||
SubscribedQualityUpdateThrottle: 100 * time.Millisecond,
|
||||
DynacastPauseDelay: 100 * time.Millisecond,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -240,6 +240,7 @@ func TestSubscribedMaxQuality(t *testing.T) {
|
||||
|
||||
// muting "s1" also should disable all qualities
|
||||
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_OFF)
|
||||
time.Sleep(110 * time.Millisecond)
|
||||
|
||||
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
||||
{Quality: livekit.VideoQuality_LOW, Enabled: false},
|
||||
@@ -251,6 +252,7 @@ func TestSubscribedMaxQuality(t *testing.T) {
|
||||
|
||||
// unmuting "s1" should enable previously set max quality
|
||||
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_LOW)
|
||||
time.Sleep(110 * time.Millisecond)
|
||||
|
||||
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
||||
{Quality: livekit.VideoQuality_LOW, Enabled: true},
|
||||
|
||||
@@ -65,7 +65,7 @@ func NewMediaTrackSubscriptions(params MediaTrackSubscriptionsParams) *MediaTrac
|
||||
maxSubscriberQuality: make(map[livekit.ParticipantID]livekit.VideoQuality),
|
||||
maxSubscriberNodeQuality: make(map[livekit.NodeID]livekit.VideoQuality),
|
||||
maxSubscribedQuality: livekit.VideoQuality_LOW,
|
||||
maxSubscribedQualityDebounce: debounce.New(params.VideoConfig.SubscribedQualityUpdateThrottle),
|
||||
maxSubscribedQualityDebounce: debounce.New(params.VideoConfig.DynacastPauseDelay),
|
||||
}
|
||||
|
||||
return t
|
||||
@@ -511,8 +511,11 @@ func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if (t.maxSubscribedQuality != livekit.VideoQuality_OFF && maxSubscribedQuality != livekit.VideoQuality_OFF) &&
|
||||
t.maxSubscribedQuality > maxSubscribedQuality && !force {
|
||||
// if quality comes down(or become OFF), delay notify to publisher
|
||||
if (t.maxSubscribedQuality != livekit.VideoQuality_OFF) &&
|
||||
(t.maxSubscribedQuality > maxSubscribedQuality || maxSubscribedQuality == livekit.VideoQuality_OFF) &&
|
||||
t.params.VideoConfig.DynacastPauseDelay > 0 && !force {
|
||||
|
||||
t.params.Logger.Debugw("throttle quality change", "from", t.maxSubscribedQuality, "to", maxSubscribedQuality)
|
||||
t.maxQualityLock.Unlock()
|
||||
t.maxSubscribedQualityDebounce(func() {
|
||||
|
||||
Reference in New Issue
Block a user