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:
@@ -1384,7 +1384,7 @@ func (p *ParticipantImpl) onSubscriberOffer(offer webrtc.SessionDescription) err
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) removePublishedTrack(track types.MediaTrack) {
|
||||
p.RemovePublishedTrack(track, false, false)
|
||||
p.RemovePublishedTrack(track, false)
|
||||
if p.ProtocolVersion().SupportsUnpublish() {
|
||||
p.sendTrackUnpublished(track.ID())
|
||||
} else {
|
||||
|
||||
@@ -255,7 +255,7 @@ type Participant interface {
|
||||
IsPublisher() bool
|
||||
GetPublishedTrack(trackID livekit.TrackID) MediaTrack
|
||||
GetPublishedTracks() []MediaTrack
|
||||
RemovePublishedTrack(track MediaTrack, willBeResumed bool, shouldClose bool)
|
||||
RemovePublishedTrack(track MediaTrack, willBeResumed bool)
|
||||
|
||||
GetAudioLevel() (smoothedLevel float64, active bool)
|
||||
|
||||
|
||||
@@ -627,12 +627,11 @@ type FakeLocalParticipant struct {
|
||||
protocolVersionReturnsOnCall map[int]struct {
|
||||
result1 types.ProtocolVersion
|
||||
}
|
||||
RemovePublishedTrackStub func(types.MediaTrack, bool, bool)
|
||||
RemovePublishedTrackStub func(types.MediaTrack, bool)
|
||||
removePublishedTrackMutex sync.RWMutex
|
||||
removePublishedTrackArgsForCall []struct {
|
||||
arg1 types.MediaTrack
|
||||
arg2 bool
|
||||
arg3 bool
|
||||
}
|
||||
RemoveTrackFromSubscriberStub func(*webrtc.RTPSender) error
|
||||
removeTrackFromSubscriberMutex sync.RWMutex
|
||||
@@ -4267,18 +4266,17 @@ func (fake *FakeLocalParticipant) ProtocolVersionReturnsOnCall(i int, result1 ty
|
||||
}{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.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct {
|
||||
arg1 types.MediaTrack
|
||||
arg2 bool
|
||||
arg3 bool
|
||||
}{arg1, arg2, arg3})
|
||||
}{arg1, arg2})
|
||||
stub := fake.RemovePublishedTrackStub
|
||||
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2, arg3})
|
||||
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2})
|
||||
fake.removePublishedTrackMutex.Unlock()
|
||||
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)
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool, bool)) {
|
||||
func (fake *FakeLocalParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool)) {
|
||||
fake.removePublishedTrackMutex.Lock()
|
||||
defer fake.removePublishedTrackMutex.Unlock()
|
||||
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()
|
||||
defer fake.removePublishedTrackMutex.RUnlock()
|
||||
argsForCall := fake.removePublishedTrackArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) RemoveTrackFromSubscriber(arg1 *webrtc.RTPSender) error {
|
||||
|
||||
@@ -158,12 +158,11 @@ type FakeParticipant struct {
|
||||
isRecorderReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
}
|
||||
RemovePublishedTrackStub func(types.MediaTrack, bool, bool)
|
||||
RemovePublishedTrackStub func(types.MediaTrack, bool)
|
||||
removePublishedTrackMutex sync.RWMutex
|
||||
removePublishedTrackArgsForCall []struct {
|
||||
arg1 types.MediaTrack
|
||||
arg2 bool
|
||||
arg3 bool
|
||||
}
|
||||
SetMetadataStub func(string)
|
||||
setMetadataMutex sync.RWMutex
|
||||
@@ -1008,18 +1007,17 @@ func (fake *FakeParticipant) IsRecorderReturnsOnCall(i int, result1 bool) {
|
||||
}{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.removePublishedTrackArgsForCall = append(fake.removePublishedTrackArgsForCall, struct {
|
||||
arg1 types.MediaTrack
|
||||
arg2 bool
|
||||
arg3 bool
|
||||
}{arg1, arg2, arg3})
|
||||
}{arg1, arg2})
|
||||
stub := fake.RemovePublishedTrackStub
|
||||
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2, arg3})
|
||||
fake.recordInvocation("RemovePublishedTrack", []interface{}{arg1, arg2})
|
||||
fake.removePublishedTrackMutex.Unlock()
|
||||
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)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool, bool)) {
|
||||
func (fake *FakeParticipant) RemovePublishedTrackCalls(stub func(types.MediaTrack, bool)) {
|
||||
fake.removePublishedTrackMutex.Lock()
|
||||
defer fake.removePublishedTrackMutex.Unlock()
|
||||
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()
|
||||
defer fake.removePublishedTrackMutex.RUnlock()
|
||||
argsForCall := fake.removePublishedTrackArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SetMetadata(arg1 string) {
|
||||
|
||||
@@ -46,8 +46,8 @@ type UpTrackManager struct {
|
||||
closed bool
|
||||
|
||||
// publishedTracks that participant is publishing
|
||||
publishedTracks map[livekit.TrackID]types.MediaTrack
|
||||
subscriptionPermission *livekit.SubscriptionPermission
|
||||
publishedTracks map[livekit.TrackID]types.MediaTrack
|
||||
subscriptionPermission *livekit.SubscriptionPermission
|
||||
// subscriber permission for published tracks
|
||||
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) {
|
||||
if shouldClose {
|
||||
track.Close(willBeResumed)
|
||||
} else {
|
||||
track.ClearAllReceivers(willBeResumed)
|
||||
}
|
||||
func (u *UpTrackManager) RemovePublishedTrack(track types.MediaTrack, willBeResumed bool) {
|
||||
track.Close(willBeResumed)
|
||||
u.lock.Lock()
|
||||
delete(u.publishedTracks, track.ID())
|
||||
u.lock.Unlock()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 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
|
||||
// +build !wireinject
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ func (f *Forwarder) SetMaxPublishedLayer(maxPublishedLayer int32) bool {
|
||||
}
|
||||
|
||||
f.vls.SetMaxSeenSpatial(maxPublishedLayer)
|
||||
f.logger.Debugw("setting max published layer", "maxPublishedLayer", maxPublishedLayer)
|
||||
f.logger.Debugw("setting max published layer", "layer", maxPublishedLayer)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user