Add Close method for UpDataTrackManager and call it on participant (#4432)
* Add `Close` method for UpDataTrackManager and call it on participant close. * include out-of-order packets in total packets
This commit is contained in:
@@ -34,6 +34,7 @@ type UpDataTrackManager struct {
|
||||
|
||||
lock sync.RWMutex
|
||||
dataTracks map[uint16]types.DataTrack
|
||||
closed bool
|
||||
|
||||
onDataTrackPublished func(types.Participant, types.DataTrack)
|
||||
onDataTrackUnpublished func(types.Participant, types.DataTrack)
|
||||
@@ -46,6 +47,24 @@ func NewUpDataTrackManager(params UpDataTrackManagerParams) *UpDataTrackManager
|
||||
}
|
||||
}
|
||||
|
||||
func (u *UpDataTrackManager) Close() {
|
||||
u.lock.Lock()
|
||||
if u.closed {
|
||||
u.lock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
u.closed = true
|
||||
|
||||
dataTracks := u.dataTracks
|
||||
u.dataTracks = make(map[uint16]types.DataTrack)
|
||||
u.lock.Unlock()
|
||||
|
||||
for _, t := range dataTracks {
|
||||
t.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (u *UpDataTrackManager) AddPublishedDataTrack(dt types.DataTrack) {
|
||||
u.lock.Lock()
|
||||
u.dataTracks[dt.PubHandle()] = dt
|
||||
|
||||
Reference in New Issue
Block a user