terminate RTC sessions properly

This commit is contained in:
David Zhao
2021-01-19 16:18:03 -08:00
parent 71b4673a0a
commit 0b00b26d05
10 changed files with 254 additions and 174 deletions
-4
View File
@@ -133,10 +133,6 @@ func NewParticipant(participantId, name string, pc types.PeerConnection, rs rout
}
})
//pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
// logger.Debugw("PeerConnection state changed", "state", state.String())
//})
pc.OnDataChannel(participant.onDataChannel)
// only set after answered
+3
View File
@@ -80,6 +80,9 @@ func (r *Room) Join(participant types.Participant) error {
}
// start the workers once connectivity is established
p.Start()
} else if p.State() == livekit.ParticipantInfo_DISCONNECTED {
// remove participant from room
go r.RemoveParticipant(p.ID())
}
})
participant.OnTrackUpdated(r.onTrackUpdated)
+1 -1
View File
@@ -24,7 +24,7 @@ type WebsocketClient interface {
type PeerConnection interface {
OnICECandidate(f func(*webrtc.ICECandidate))
OnICEConnectionStateChange(func(webrtc.ICEConnectionState))
OnConnectionStateChange(f func(webrtc.PeerConnectionState))
//OnConnectionStateChange(f func(webrtc.PeerConnectionState))
OnTrack(f func(*webrtc.TrackRemote, *webrtc.RTPReceiver))
OnDataChannel(func(d *webrtc.DataChannel))
OnNegotiationNeeded(f func())
@@ -95,11 +95,6 @@ type FakePeerConnection struct {
result1 webrtc.SessionDescription
result2 error
}
OnConnectionStateChangeStub func(func(webrtc.PeerConnectionState))
onConnectionStateChangeMutex sync.RWMutex
onConnectionStateChangeArgsForCall []struct {
arg1 func(webrtc.PeerConnectionState)
}
OnDataChannelStub func(func(d *webrtc.DataChannel))
onDataChannelMutex sync.RWMutex
onDataChannelArgsForCall []struct {
@@ -608,38 +603,6 @@ func (fake *FakePeerConnection) CreateOfferReturnsOnCall(i int, result1 webrtc.S
}{result1, result2}
}
func (fake *FakePeerConnection) OnConnectionStateChange(arg1 func(webrtc.PeerConnectionState)) {
fake.onConnectionStateChangeMutex.Lock()
fake.onConnectionStateChangeArgsForCall = append(fake.onConnectionStateChangeArgsForCall, struct {
arg1 func(webrtc.PeerConnectionState)
}{arg1})
stub := fake.OnConnectionStateChangeStub
fake.recordInvocation("OnConnectionStateChange", []interface{}{arg1})
fake.onConnectionStateChangeMutex.Unlock()
if stub != nil {
fake.OnConnectionStateChangeStub(arg1)
}
}
func (fake *FakePeerConnection) OnConnectionStateChangeCallCount() int {
fake.onConnectionStateChangeMutex.RLock()
defer fake.onConnectionStateChangeMutex.RUnlock()
return len(fake.onConnectionStateChangeArgsForCall)
}
func (fake *FakePeerConnection) OnConnectionStateChangeCalls(stub func(func(webrtc.PeerConnectionState))) {
fake.onConnectionStateChangeMutex.Lock()
defer fake.onConnectionStateChangeMutex.Unlock()
fake.OnConnectionStateChangeStub = stub
}
func (fake *FakePeerConnection) OnConnectionStateChangeArgsForCall(i int) func(webrtc.PeerConnectionState) {
fake.onConnectionStateChangeMutex.RLock()
defer fake.onConnectionStateChangeMutex.RUnlock()
argsForCall := fake.onConnectionStateChangeArgsForCall[i]
return argsForCall.arg1
}
func (fake *FakePeerConnection) OnDataChannel(arg1 func(d *webrtc.DataChannel)) {
fake.onDataChannelMutex.Lock()
fake.onDataChannelArgsForCall = append(fake.onDataChannelArgsForCall, struct {
@@ -1119,8 +1082,6 @@ func (fake *FakePeerConnection) Invocations() map[string][][]interface{} {
defer fake.createDataChannelMutex.RUnlock()
fake.createOfferMutex.RLock()
defer fake.createOfferMutex.RUnlock()
fake.onConnectionStateChangeMutex.RLock()
defer fake.onConnectionStateChangeMutex.RUnlock()
fake.onDataChannelMutex.RLock()
defer fake.onDataChannelMutex.RUnlock()
fake.onICECandidateMutex.RLock()