Maintain subscription count. (#2515)
* Maintain subscription count. Does not affect function as it is not decremented only if limits are configured. But, good to maintain proper count anyway. * wire
This commit is contained in:
@@ -464,7 +464,7 @@ func (p *ParticipantImpl) SetPermission(permission *livekit.ParticipantPermissio
|
|||||||
|
|
||||||
if canSubscribe {
|
if canSubscribe {
|
||||||
// reconcile everything
|
// reconcile everything
|
||||||
p.SubscriptionManager.queueReconcile("")
|
p.SubscriptionManager.ReconcileAll()
|
||||||
} else {
|
} else {
|
||||||
// revoke all subscriptions
|
// revoke all subscriptions
|
||||||
for _, st := range p.SubscriptionManager.GetSubscribedTracks() {
|
for _, st := range p.SubscriptionManager.GetSubscribedTracks() {
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ func (m *SubscriptionManager) WaitUntilSubscribed(timeout time.Duration) error {
|
|||||||
return context.DeadlineExceeded
|
return context.DeadlineExceeded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *SubscriptionManager) ReconcileAll() {
|
||||||
|
m.queueReconcile(trackIDForReconcileSubscriptions)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *SubscriptionManager) setDesired(trackID livekit.TrackID, desired bool) (*trackSubscription, bool) {
|
func (m *SubscriptionManager) setDesired(trackID livekit.TrackID, desired bool) (*trackSubscription, bool) {
|
||||||
m.lock.RLock()
|
m.lock.RLock()
|
||||||
defer m.lock.RUnlock()
|
defer m.lock.RUnlock()
|
||||||
@@ -628,9 +632,11 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *trackSubscription, w
|
|||||||
var relieveFromLimits bool
|
var relieveFromLimits bool
|
||||||
switch subTrack.MediaTrack().Kind() {
|
switch subTrack.MediaTrack().Kind() {
|
||||||
case livekit.TrackType_VIDEO:
|
case livekit.TrackType_VIDEO:
|
||||||
relieveFromLimits = m.params.SubscriptionLimitVideo > 0 && m.subscribedVideoCount.Dec() == m.params.SubscriptionLimitVideo-1
|
videoCount := m.subscribedVideoCount.Dec()
|
||||||
|
relieveFromLimits = m.params.SubscriptionLimitVideo > 0 && videoCount == m.params.SubscriptionLimitVideo-1
|
||||||
case livekit.TrackType_AUDIO:
|
case livekit.TrackType_AUDIO:
|
||||||
relieveFromLimits = m.params.SubscriptionLimitAudio > 0 && m.subscribedAudioCount.Dec() == m.params.SubscriptionLimitAudio-1
|
audioCount := m.subscribedAudioCount.Dec()
|
||||||
|
relieveFromLimits = m.params.SubscriptionLimitAudio > 0 && audioCount == m.params.SubscriptionLimitAudio-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove from subscribedTo
|
// remove from subscribedTo
|
||||||
|
|||||||
Reference in New Issue
Block a user