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:
@@ -65,6 +65,7 @@ func (d *dataTrackStats) Update(packet *datatrack.Packet, arrivalTime int64) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
case diff > (1 << 15): // out of order
|
case diff > (1 << 15): // out of order
|
||||||
|
d.numPackets++
|
||||||
d.numPacketsOutOfOrder++
|
d.numPacketsOutOfOrder++
|
||||||
if d.numPacketsLost > 0 {
|
if d.numPacketsLost > 0 {
|
||||||
d.numPacketsLost--
|
d.numPacketsLost--
|
||||||
|
|||||||
@@ -1427,6 +1427,7 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
|||||||
p.pendingTracksLock.Unlock()
|
p.pendingTracksLock.Unlock()
|
||||||
|
|
||||||
p.UpTrackManager.Close(isExpectedToResume)
|
p.UpTrackManager.Close(isExpectedToResume)
|
||||||
|
p.UpDataTrackManager.Close()
|
||||||
|
|
||||||
p.rpcLock.Lock()
|
p.rpcLock.Lock()
|
||||||
clear(p.rpcPendingAcks)
|
clear(p.rpcPendingAcks)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type UpDataTrackManager struct {
|
|||||||
|
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
dataTracks map[uint16]types.DataTrack
|
dataTracks map[uint16]types.DataTrack
|
||||||
|
closed bool
|
||||||
|
|
||||||
onDataTrackPublished func(types.Participant, types.DataTrack)
|
onDataTrackPublished func(types.Participant, types.DataTrack)
|
||||||
onDataTrackUnpublished 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) {
|
func (u *UpDataTrackManager) AddPublishedDataTrack(dt types.DataTrack) {
|
||||||
u.lock.Lock()
|
u.lock.Lock()
|
||||||
u.dataTracks[dt.PubHandle()] = dt
|
u.dataTracks[dt.PubHandle()] = dt
|
||||||
|
|||||||
Reference in New Issue
Block a user