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 {
|
type VideoConfig struct {
|
||||||
SubscribedQualityUpdateThrottle time.Duration `yaml:"subscribed_quality_update_throttle,omitempty"`
|
DynacastPauseDelay time.Duration `yaml:"dynacast_pause_delay,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisConfig struct {
|
type RedisConfig struct {
|
||||||
@@ -213,7 +213,7 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) {
|
|||||||
SmoothIntervals: 2,
|
SmoothIntervals: 2,
|
||||||
},
|
},
|
||||||
Video: VideoConfig{
|
Video: VideoConfig{
|
||||||
SubscribedQualityUpdateThrottle: 5 * time.Second,
|
DynacastPauseDelay: 5 * time.Second,
|
||||||
},
|
},
|
||||||
Redis: RedisConfig{},
|
Redis: RedisConfig{},
|
||||||
Room: RoomConfig{
|
Room: RoomConfig{
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ func TestSubscribedMaxQuality(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
VideoConfig: config.VideoConfig{
|
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
|
// muting "s1" also should disable all qualities
|
||||||
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_OFF)
|
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_OFF)
|
||||||
|
time.Sleep(110 * time.Millisecond)
|
||||||
|
|
||||||
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
||||||
{Quality: livekit.VideoQuality_LOW, Enabled: false},
|
{Quality: livekit.VideoQuality_LOW, Enabled: false},
|
||||||
@@ -251,6 +252,7 @@ func TestSubscribedMaxQuality(t *testing.T) {
|
|||||||
|
|
||||||
// unmuting "s1" should enable previously set max quality
|
// unmuting "s1" should enable previously set max quality
|
||||||
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_LOW)
|
mt.notifySubscriberMaxQuality("s1", livekit.VideoQuality_LOW)
|
||||||
|
time.Sleep(110 * time.Millisecond)
|
||||||
|
|
||||||
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
expectedSubscribedQualities = []*livekit.SubscribedQuality{
|
||||||
{Quality: livekit.VideoQuality_LOW, Enabled: true},
|
{Quality: livekit.VideoQuality_LOW, Enabled: true},
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func NewMediaTrackSubscriptions(params MediaTrackSubscriptionsParams) *MediaTrac
|
|||||||
maxSubscriberQuality: make(map[livekit.ParticipantID]livekit.VideoQuality),
|
maxSubscriberQuality: make(map[livekit.ParticipantID]livekit.VideoQuality),
|
||||||
maxSubscriberNodeQuality: make(map[livekit.NodeID]livekit.VideoQuality),
|
maxSubscriberNodeQuality: make(map[livekit.NodeID]livekit.VideoQuality),
|
||||||
maxSubscribedQuality: livekit.VideoQuality_LOW,
|
maxSubscribedQuality: livekit.VideoQuality_LOW,
|
||||||
maxSubscribedQualityDebounce: debounce.New(params.VideoConfig.SubscribedQualityUpdateThrottle),
|
maxSubscribedQualityDebounce: debounce.New(params.VideoConfig.DynacastPauseDelay),
|
||||||
}
|
}
|
||||||
|
|
||||||
return t
|
return t
|
||||||
@@ -511,8 +511,11 @@ func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.maxSubscribedQuality != livekit.VideoQuality_OFF && maxSubscribedQuality != livekit.VideoQuality_OFF) &&
|
// if quality comes down(or become OFF), delay notify to publisher
|
||||||
t.maxSubscribedQuality > maxSubscribedQuality && !force {
|
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.params.Logger.Debugw("throttle quality change", "from", t.maxSubscribedQuality, "to", maxSubscribedQuality)
|
||||||
t.maxQualityLock.Unlock()
|
t.maxQualityLock.Unlock()
|
||||||
t.maxSubscribedQualityDebounce(func() {
|
t.maxSubscribedQualityDebounce(func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user