diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index f0e6dd09f..51c577418 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -376,7 +376,7 @@ func (r *Room) UpdateSubscriptions( return err } } else { - publisher.RemoveSubscriber(participant, trackID) + publisher.RemoveSubscriber(participant, trackID, false) } } return nil @@ -397,7 +397,7 @@ func (r *Room) RemoveDisallowedSubscriptions(sub types.LocalParticipant, disallo continue } - pub.RemoveSubscriber(sub, trackID) + pub.RemoveSubscriber(sub, trackID, false) } } diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index 09cf38f55..cd765bd14 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -45,7 +45,7 @@ type Participant interface { GetPublishedTracks() []MediaTrack AddSubscriber(op LocalParticipant, params AddSubscriberParams) (int, error) - RemoveSubscriber(op LocalParticipant, trackID livekit.TrackID) + RemoveSubscriber(op LocalParticipant, trackID livekit.TrackID, resume bool) // permissions Hidden() bool diff --git a/pkg/rtc/types/typesfakes/fake_local_participant.go b/pkg/rtc/types/typesfakes/fake_local_participant.go index 9f95dcafb..7bf8b31e7 100644 --- a/pkg/rtc/types/typesfakes/fake_local_participant.go +++ b/pkg/rtc/types/typesfakes/fake_local_participant.go @@ -342,11 +342,12 @@ type FakeLocalParticipant struct { removeSubscribedTrackArgsForCall []struct { arg1 types.SubscribedTrack } - RemoveSubscriberStub func(types.LocalParticipant, livekit.TrackID) + RemoveSubscriberStub func(types.LocalParticipant, livekit.TrackID, bool) removeSubscriberMutex sync.RWMutex removeSubscriberArgsForCall []struct { arg1 types.LocalParticipant arg2 livekit.TrackID + arg3 bool } SendConnectionQualityUpdateStub func(*livekit.ConnectionQualityUpdate) error sendConnectionQualityUpdateMutex sync.RWMutex @@ -2363,17 +2364,18 @@ func (fake *FakeLocalParticipant) RemoveSubscribedTrackArgsForCall(i int) types. return argsForCall.arg1 } -func (fake *FakeLocalParticipant) RemoveSubscriber(arg1 types.LocalParticipant, arg2 livekit.TrackID) { +func (fake *FakeLocalParticipant) RemoveSubscriber(arg1 types.LocalParticipant, arg2 livekit.TrackID, arg3 bool) { fake.removeSubscriberMutex.Lock() fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { arg1 types.LocalParticipant arg2 livekit.TrackID - }{arg1, arg2}) + arg3 bool + }{arg1, arg2, arg3}) stub := fake.RemoveSubscriberStub - fake.recordInvocation("RemoveSubscriber", []interface{}{arg1, arg2}) + fake.recordInvocation("RemoveSubscriber", []interface{}{arg1, arg2, arg3}) fake.removeSubscriberMutex.Unlock() if stub != nil { - fake.RemoveSubscriberStub(arg1, arg2) + fake.RemoveSubscriberStub(arg1, arg2, arg3) } } @@ -2383,17 +2385,17 @@ func (fake *FakeLocalParticipant) RemoveSubscriberCallCount() int { return len(fake.removeSubscriberArgsForCall) } -func (fake *FakeLocalParticipant) RemoveSubscriberCalls(stub func(types.LocalParticipant, livekit.TrackID)) { +func (fake *FakeLocalParticipant) RemoveSubscriberCalls(stub func(types.LocalParticipant, livekit.TrackID, bool)) { fake.removeSubscriberMutex.Lock() defer fake.removeSubscriberMutex.Unlock() fake.RemoveSubscriberStub = stub } -func (fake *FakeLocalParticipant) RemoveSubscriberArgsForCall(i int) (types.LocalParticipant, livekit.TrackID) { +func (fake *FakeLocalParticipant) RemoveSubscriberArgsForCall(i int) (types.LocalParticipant, livekit.TrackID, bool) { fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() argsForCall := fake.removeSubscriberArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeLocalParticipant) SendConnectionQualityUpdate(arg1 *livekit.ConnectionQualityUpdate) error { diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index cc3f266b3..edaeecf85 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -95,11 +95,12 @@ type FakeParticipant struct { identityReturnsOnCall map[int]struct { result1 livekit.ParticipantIdentity } - RemoveSubscriberStub func(types.LocalParticipant, livekit.TrackID) + RemoveSubscriberStub func(types.LocalParticipant, livekit.TrackID, bool) removeSubscriberMutex sync.RWMutex removeSubscriberArgsForCall []struct { arg1 types.LocalParticipant arg2 livekit.TrackID + arg3 bool } SetMetadataStub func(string) setMetadataMutex sync.RWMutex @@ -635,17 +636,18 @@ func (fake *FakeParticipant) IdentityReturnsOnCall(i int, result1 livekit.Partic }{result1} } -func (fake *FakeParticipant) RemoveSubscriber(arg1 types.LocalParticipant, arg2 livekit.TrackID) { +func (fake *FakeParticipant) RemoveSubscriber(arg1 types.LocalParticipant, arg2 livekit.TrackID, arg3 bool) { fake.removeSubscriberMutex.Lock() fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { arg1 types.LocalParticipant arg2 livekit.TrackID - }{arg1, arg2}) + arg3 bool + }{arg1, arg2, arg3}) stub := fake.RemoveSubscriberStub - fake.recordInvocation("RemoveSubscriber", []interface{}{arg1, arg2}) + fake.recordInvocation("RemoveSubscriber", []interface{}{arg1, arg2, arg3}) fake.removeSubscriberMutex.Unlock() if stub != nil { - fake.RemoveSubscriberStub(arg1, arg2) + fake.RemoveSubscriberStub(arg1, arg2, arg3) } } @@ -655,17 +657,17 @@ func (fake *FakeParticipant) RemoveSubscriberCallCount() int { return len(fake.removeSubscriberArgsForCall) } -func (fake *FakeParticipant) RemoveSubscriberCalls(stub func(types.LocalParticipant, livekit.TrackID)) { +func (fake *FakeParticipant) RemoveSubscriberCalls(stub func(types.LocalParticipant, livekit.TrackID, bool)) { fake.removeSubscriberMutex.Lock() defer fake.removeSubscriberMutex.Unlock() fake.RemoveSubscriberStub = stub } -func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) (types.LocalParticipant, livekit.TrackID) { +func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) (types.LocalParticipant, livekit.TrackID, bool) { fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() argsForCall := fake.removeSubscriberArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeParticipant) SetMetadata(arg1 string) { diff --git a/pkg/rtc/uptrackmanager.go b/pkg/rtc/uptrackmanager.go index 8f2d65e81..168d29b96 100644 --- a/pkg/rtc/uptrackmanager.go +++ b/pkg/rtc/uptrackmanager.go @@ -128,10 +128,10 @@ func (u *UpTrackManager) AddSubscriber(sub types.LocalParticipant, params types. return n, nil } -func (u *UpTrackManager) RemoveSubscriber(sub types.LocalParticipant, trackID livekit.TrackID) { +func (u *UpTrackManager) RemoveSubscriber(sub types.LocalParticipant, trackID livekit.TrackID, resume bool) { track := u.GetPublishedTrack(trackID) if track != nil { - track.RemoveSubscriber(sub.ID(), false) + track.RemoveSubscriber(sub.ID(), resume) } u.lock.Lock()