mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 22:05:39 +00:00
Force send dynacast update on unmute. (#802)
As there is a queue to send dynacast update, forcing an update on unmute should be fine. That will send the current state. If the subscribers change it, an update will be sent as necessary. This addresses the case of subscription changes happening when the published track is muted. Dynacast updates are not sent when publisher tarck is muted. If on unmute, if subscribers do not have any changes, an update is missed (i. e. the changes that happen when publisher track is muted is not sent).
This commit is contained in:
@@ -128,6 +128,13 @@ func (t *MediaTrackSubscriptions) OnDownTrackCreated(f func(downTrack *sfu.DownT
|
||||
}
|
||||
|
||||
func (t *MediaTrackSubscriptions) SetMuted(muted bool) {
|
||||
// update quality based on subscription if unmuting.
|
||||
// This will queue up the current state, but subscriber
|
||||
// driven changes could update it.
|
||||
if !muted {
|
||||
t.updateQualityChange(true)
|
||||
}
|
||||
|
||||
// update mute of all subscribed tracks
|
||||
for _, st := range t.getAllSubscribedTracks() {
|
||||
st.SetPublisherMuted(muted)
|
||||
@@ -641,7 +648,7 @@ func (t *MediaTrackSubscriptions) notifySubscriberMaxQuality(subscriberID liveki
|
||||
}
|
||||
t.maxQualityLock.Unlock()
|
||||
|
||||
t.UpdateQualityChange(false)
|
||||
t.updateQualityChange(false)
|
||||
}
|
||||
|
||||
func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.NodeID, qualities []types.SubscribedCodecQuality) {
|
||||
@@ -687,10 +694,10 @@ func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.
|
||||
}
|
||||
t.maxQualityLock.Unlock()
|
||||
|
||||
t.UpdateQualityChange(false)
|
||||
t.updateQualityChange(false)
|
||||
}
|
||||
|
||||
func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
||||
func (t *MediaTrackSubscriptions) updateQualityChange(force bool) {
|
||||
if t.params.MediaTrack.Kind() != livekit.TrackType_VIDEO {
|
||||
return
|
||||
}
|
||||
@@ -753,11 +760,11 @@ func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
||||
noChangeCount++
|
||||
}
|
||||
}
|
||||
t.params.Logger.Debugw("updating quality change",
|
||||
t.params.Logger.Debugw("updated quality change",
|
||||
"changed", changed,
|
||||
"maxSubscribedQuality", maxSubscribedQuality,
|
||||
"t.maxSubscribedQuality", t.maxSubscribedQuality,
|
||||
"comesDownQuality", qualityDowngrades)
|
||||
"qualityDowngrades", qualityDowngrades)
|
||||
|
||||
if !changed && !force {
|
||||
t.maxQualityLock.Unlock()
|
||||
@@ -767,7 +774,7 @@ func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
||||
// if quality downgrade (or become OFF), delay notify to publisher if needed
|
||||
if len(qualityDowngrades) > 0 && !force {
|
||||
t.maxSubscribedQualityDebounce(func() {
|
||||
t.UpdateQualityChange(true)
|
||||
t.updateQualityChange(true)
|
||||
})
|
||||
|
||||
// no quality upgrades
|
||||
@@ -829,7 +836,7 @@ func (t *MediaTrackSubscriptions) startMaxQualityTimer(force bool) {
|
||||
|
||||
t.maxQualityTimer = time.AfterFunc(initialQualityUpdateWait, func() {
|
||||
t.stopMaxQualityTimer()
|
||||
t.UpdateQualityChange(force)
|
||||
t.updateQualityChange(force)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user