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:
Raja Subramanian
2022-07-03 09:50:14 +05:30
committed by GitHub
parent 41c57f737c
commit d0bbea6e91

View File

@@ -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)
})
}