handle unpublish track

This commit is contained in:
David Zhao
2021-01-12 17:07:01 -08:00
parent 7c3b0c5202
commit bd885b1de9
10 changed files with 221 additions and 361 deletions
+8 -9
View File
@@ -262,15 +262,6 @@ func (p *ParticipantImpl) AddTrack(clientId, name string, trackType livekit.Trac
})
}
func (p *ParticipantImpl) RemoveTrack(sid string) error {
p.lock.Lock()
defer p.lock.Unlock()
// TODO: handle removal properly
return nil
}
func (p *ParticipantImpl) HandleAnswer(sdp webrtc.SessionDescription) error {
if sdp.Type != webrtc.SDPTypeAnswer {
return ErrUnexpectedOffer
@@ -539,6 +530,14 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
track.Start()
track.OnClose(func() {
// cleanup
p.lock.Lock()
delete(p.publishedTracks, track.ID())
p.lock.Unlock()
p.onTrackUpdated(p, track)
})
if p.onTrackPublished != nil {
p.onTrackPublished(p, track)
}