Close published track always. (#2508)

Simplify and close published track always. Avoid the round about path of
unbind to close.
This commit is contained in:
Raja Subramanian
2024-02-25 13:46:55 +05:30
committed by GitHub
parent eed457d8be
commit 6696c1e63d
7 changed files with 24 additions and 32 deletions
+1 -1
View File
@@ -1384,7 +1384,7 @@ func (p *ParticipantImpl) onSubscriberOffer(offer webrtc.SessionDescription) err
} }
func (p *ParticipantImpl) removePublishedTrack(track types.MediaTrack) { func (p *ParticipantImpl) removePublishedTrack(track types.MediaTrack) {
p.RemovePublishedTrack(track, false, false) p.RemovePublishedTrack(track, false)
if p.ProtocolVersion().SupportsUnpublish() { if p.ProtocolVersion().SupportsUnpublish() {
p.sendTrackUnpublished(track.ID()) p.sendTrackUnpublished(track.ID())
} else { } else {
+1 -1
View File
@@ -255,7 +255,7 @@ type Participant interface {
IsPublisher() bool IsPublisher() bool
GetPublishedTrack(trackID livekit.TrackID) MediaTrack GetPublishedTrack(trackID livekit.TrackID) MediaTrack
GetPublishedTracks() []MediaTrack GetPublishedTracks() []MediaTrack
RemovePublishedTrack(track MediaTrack, willBeResumed bool, shouldClose bool) RemovePublishedTrack(track MediaTrack, willBeResumed bool)
GetAudioLevel() (smoothedLevel float64, active bool) GetAudioLevel() (smoothedLevel float64, active bool)
@@ -627,12 +627,11 @@ type FakeLocalParticipant struct {
protocolVersionReturnsOnCall map[int]struct { protocolVersionReturnsOnCall map[int]struct {
result1 types.ProtocolVersion result1 types.ProtocolVersion
} }
RemovePublishedTrackStub func(types.MediaTrack, bool, bool) RemovePublishedTrackStub func(types.MediaTrack, bool)
removePublishedTrackMutex sync.RWMutex removePublishedTrackMutex sync.RWMutex
removePublishedTrackArgsForCall []struct { removePublishedTrackArgsForCall []struct {
arg1 types.MediaTrack arg1 types.MediaTrack
arg2 bool arg2 bool
arg3 bool
} }
RemoveTrackFromSubscriberStub func(*webrtc.RTPSender) error RemoveTrackFromSubscriberStub func(*webrtc.RTPSender) error
removeTrackFromSubscriberMutex sync.RWMutex removeTrackFromSubscriberMutex sync.RWMutex
@@ -4267,18 +4266,17 @@ func (fake *FakeLocalParticipant) ProtocolVersionReturnsOnCall(i int, result1 ty
}{result1} }{result1}
} }
func (fake *FakeLocalParticipant) RemovePublishedTrack(arg1 types.MediaTrack, arg2 bool, arg3 bool) { func (fake *FakeLocalParticipant) RemovePublishedTrack(arg1 types.MediaTrack, arg2 bool) {
fake.removePublishedTrackMutex.Lock() fake.removePublishedTrackMutex.Lock()
fake.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct { fake.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct {
arg1 types.MediaTrack arg1 types.MediaTrack
arg2 bool arg2 bool
arg3 bool }{arg1, arg2})
}{arg1, arg2, arg3})
stub := fake.RemovePublishedTrackStub stub := fake.RemovePublishedTrackStub
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2})
fake.removePublishedTrackMutex.Unlock() fake.removePublishedTrackMutex.Unlock()
if stub != nil { if stub != nil {
fake.RemovePublishedTrackStub(arg1, arg2, arg3) fake.RemovePublishedTrackStub(arg1, arg2)
} }
} }
@@ -4288,17 +4286,17 @@ func (fake *FakeLocalParticipant) RemovePublishedTrackCallCount() int {
return len(fake.removePublishedTrackArgsForCall) return len(fake.removePublishedTrackArgsForCall)
} }
func (fake *FakeLocalParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool, bool)) { func (fake *FakeLocalParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool)) {
fake.removePublishedTrackMutex.Lock() fake.removePublishedTrackMutex.Lock()
defer fake.removePublishedTrackMutex.Unlock() defer fake.removePublishedTrackMutex.Unlock()
fake.RemovePublishedTrackStub = stub fake.RemovePublishedTrackStub = stub
} }
func (fake *FakeLocalParticipant) RemovePublishedTrackArgsForCall(i int) (types.MediaTrack, bool, bool) { func (fake *FakeLocalParticipant) RemovePublishedTrackArgsForCall(i int) (types.MediaTrack, bool) {
fake.removePublishedTrackMutex.RLock() fake.removePublishedTrackMutex.RLock()
defer fake.removePublishedTrackMutex.RUnlock() defer fake.removePublishedTrackMutex.RUnlock()
argsForCall := fake.removePublishedTrackArgsForCall[i] argsForCall := fake.removePublishedTrackArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2
} }
func (fake *FakeLocalParticipant) RemoveTrackFromSubscriber(arg1 *webrtc.RTPSender) error { func (fake *FakeLocalParticipant) RemoveTrackFromSubscriber(arg1 *webrtc.RTPSender) error {
+8 -10
View File
@@ -158,12 +158,11 @@ type FakeParticipant struct {
isRecorderReturnsOnCall map[int]struct { isRecorderReturnsOnCall map[int]struct {
result1 bool result1 bool
} }
RemovePublishedTrackStub func(types.MediaTrack, bool, bool) RemovePublishedTrackStub func(types.MediaTrack, bool)
removePublishedTrackMutex sync.RWMutex removePublishedTrackMutex sync.RWMutex
removePublishedTrackArgsForCall []struct { removePublishedTrackArgsForCall []struct {
arg1 types.MediaTrack arg1 types.MediaTrack
arg2 bool arg2 bool
arg3 bool
} }
SetMetadataStub func(string) SetMetadataStub func(string)
setMetadataMutex sync.RWMutex setMetadataMutex sync.RWMutex
@@ -1008,18 +1007,17 @@ func (fake *FakeParticipant) IsRecorderReturnsOnCall(i int, result1 bool) {
}{result1} }{result1}
} }
func (fake *FakeParticipant) RemovePublishedTrack(arg1 types.MediaTrack, arg2 bool, arg3 bool) { func (fake *FakeParticipant) RemovePublishedTrack(arg1 types.MediaTrack, arg2 bool) {
fake.removePublishedTrackMutex.Lock() fake.removePublishedTrackMutex.Lock()
fake.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct { fake.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct {
arg1 types.MediaTrack arg1 types.MediaTrack
arg2 bool arg2 bool
arg3 bool }{arg1, arg2})
}{arg1, arg2, arg3})
stub := fake.RemovePublishedTrackStub stub := fake.RemovePublishedTrackStub
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2})
fake.removePublishedTrackMutex.Unlock() fake.removePublishedTrackMutex.Unlock()
if stub != nil { if stub != nil {
fake.RemovePublishedTrackStub(arg1, arg2, arg3) fake.RemovePublishedTrackStub(arg1, arg2)
} }
} }
@@ -1029,17 +1027,17 @@ func (fake *FakeParticipant) RemovePublishedTrackCallCount() int {
return len(fake.removePublishedTrackArgsForCall) return len(fake.removePublishedTrackArgsForCall)
} }
func (fake *FakeParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool, bool)) { func (fake *FakeParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool)) {
fake.removePublishedTrackMutex.Lock() fake.removePublishedTrackMutex.Lock()
defer fake.removePublishedTrackMutex.Unlock() defer fake.removePublishedTrackMutex.Unlock()
fake.RemovePublishedTrackStub = stub fake.RemovePublishedTrackStub = stub
} }
func (fake *FakeParticipant) RemovePublishedTrackArgsForCall(i int) (types.MediaTrack, bool, bool) { func (fake *FakeParticipant) RemovePublishedTrackArgsForCall(i int) (types.MediaTrack, bool) {
fake.removePublishedTrackMutex.RLock() fake.removePublishedTrackMutex.RLock()
defer fake.removePublishedTrackMutex.RUnlock() defer fake.removePublishedTrackMutex.RUnlock()
argsForCall := fake.removePublishedTrackArgsForCall[i] argsForCall := fake.removePublishedTrackArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2
} }
func (fake *FakeParticipant) SetMetadata(arg1 string) { func (fake *FakeParticipant) SetMetadata(arg1 string) {
+4 -8
View File
@@ -46,8 +46,8 @@ type UpTrackManager struct {
closed bool closed bool
// publishedTracks that participant is publishing // publishedTracks that participant is publishing
publishedTracks map[livekit.TrackID]types.MediaTrack publishedTracks map[livekit.TrackID]types.MediaTrack
subscriptionPermission *livekit.SubscriptionPermission subscriptionPermission *livekit.SubscriptionPermission
// subscriber permission for published tracks // subscriber permission for published tracks
subscriberPermissions map[livekit.ParticipantIdentity]*livekit.TrackPermission // subscriberIdentity => *livekit.TrackPermission subscriberPermissions map[livekit.ParticipantIdentity]*livekit.TrackPermission // subscriberIdentity => *livekit.TrackPermission
@@ -268,12 +268,8 @@ func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
}) })
} }
func (u *UpTrackManager) RemovePublishedTrack(track types.MediaTrack, willBeResumed bool, shouldClose bool) { func (u *UpTrackManager) RemovePublishedTrack(track types.MediaTrack, willBeResumed bool) {
if shouldClose { track.Close(willBeResumed)
track.Close(willBeResumed)
} else {
track.ClearAllReceivers(willBeResumed)
}
u.lock.Lock() u.lock.Lock()
delete(u.publishedTracks, track.ID()) delete(u.publishedTracks, track.ID())
u.lock.Unlock() u.lock.Unlock()
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run -mod=mod github.com/google/wire/cmd/wire //go:generate go run github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject
+1 -1
View File
@@ -247,7 +247,7 @@ func (f *Forwarder) SetMaxPublishedLayer(maxPublishedLayer int32) bool {
} }
f.vls.SetMaxSeenSpatial(maxPublishedLayer) f.vls.SetMaxSeenSpatial(maxPublishedLayer)
f.logger.Debugw("setting max published layer", "maxPublishedLayer", maxPublishedLayer) f.logger.Debugw("setting max published layer", "layer", maxPublishedLayer)
return true return true
} }