mirror of
https://github.com/livekit/livekit.git
synced 2026-08-28 05:04:10 +00:00
refine dynacast pause delay (#558)
* refine dynacast pause delay * fix test
This commit is contained in:
@@ -114,7 +114,7 @@ type AudioConfig struct {
|
||||
}
|
||||
|
||||
type VideoConfig struct {
|
||||
SubscribedQualityUpdateThrottle time.Duration `yaml:"subscribed_quality_update_throttle,omitempty"`
|
||||
DynacastPauseDelay time.Duration `yaml:"dynacast_pause_delay,omitempty"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
@@ -213,7 +213,7 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) {
|
||||
SmoothIntervals: 2,
|
||||
},
|
||||
Video: VideoConfig{
|
||||
SubscribedQualityUpdateThrottle: 5 * time.Second,
|
||||
DynacastPauseDelay: 5 * time.Second,
|
||||
},
|
||||
Redis: RedisConfig{},
|
||||
Room: RoomConfig{
|
||||
|
||||
@@ -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