handle cid changes between publish intent and onTrack
This commit is contained in:
@@ -589,4 +589,6 @@ func (c *RTCClient) SendNacks(count int) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
|
|
||||||
|
c.PeerConn.WriteRTCP(packets)
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-3
@@ -532,7 +532,7 @@ func (p *ParticipantImpl) updateState(state livekit.ParticipantInfo_State) {
|
|||||||
func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *webrtc.RTPReceiver) {
|
func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *webrtc.RTPReceiver) {
|
||||||
logger.Debugw("mediaTrack added", "participant", p.Identity(), "remoteTrack", track.ID())
|
logger.Debugw("mediaTrack added", "participant", p.Identity(), "remoteTrack", track.ID())
|
||||||
|
|
||||||
ti := p.popPendingTrack(track.ID())
|
ti := p.popPendingTrack(track.ID(), ToProtoTrackKind(track.Kind()))
|
||||||
if ti == nil {
|
if ti == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
|||||||
logger.Debugw("dataChannel added", "participant", p.Identity(), "label", dc.Label())
|
logger.Debugw("dataChannel added", "participant", p.Identity(), "label", dc.Label())
|
||||||
|
|
||||||
// data channels have numeric ids, so we use its label to identify
|
// data channels have numeric ids, so we use its label to identify
|
||||||
ti := p.popPendingTrack(dc.Label())
|
ti := p.popPendingTrack(dc.Label(), livekit.TrackType_DATA)
|
||||||
if ti == nil {
|
if ti == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -563,10 +563,24 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
|||||||
p.handleTrackPublished(dt)
|
p.handleTrackPublished(dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) popPendingTrack(clientId string) *livekit.TrackInfo {
|
func (p *ParticipantImpl) popPendingTrack(clientId string, kind livekit.TrackType) *livekit.TrackInfo {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
ti := p.pendingTracks[clientId]
|
ti := p.pendingTracks[clientId]
|
||||||
|
|
||||||
|
// then find the first one that matches type. with MediaStreamTrack, it's possible for the client id to
|
||||||
|
// change after being added to PeerConnection
|
||||||
|
if ti == nil {
|
||||||
|
for cid, info := range p.pendingTracks {
|
||||||
|
if info.Type == kind {
|
||||||
|
ti = info
|
||||||
|
clientId = cid
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if still not found, we are done
|
||||||
if ti == nil {
|
if ti == nil {
|
||||||
logger.Errorw("track info not published prior to track", "clientId", clientId)
|
logger.Errorw("track info not published prior to track", "clientId", clientId)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user