MCPcopy
hub / github.com/livekit/livekit / processRemoteTrack

Method processRemoteTrack

test/client/client.go:1253–1336  ·  view source on GitHub ↗
(track *webrtc.TrackRemote)

Source from the content-addressed store, hash-verified

1251}
1252
1253func (c *RTCClient) processRemoteTrack(track *webrtc.TrackRemote) {
1254 lastUpdate := time.Time{}
1255
1256 // because of FireOnTrackBySdp, it is possible get an empty streamID
1257 // if media comes before SDP, cache and try later
1258 streamID := track.StreamID()
1259 if streamID == "" {
1260 logger.Infow(
1261 "client caching track",
1262 "participant", c.localParticipant.Identity,
1263 "participantID", c.ID(),
1264 "codec", track.Codec(),
1265 "ssrc", track.SSRC(),
1266 )
1267 c.lock.Lock()
1268 c.pendingRemoteTracks = append(c.pendingRemoteTracks, track)
1269 c.lock.Unlock()
1270 return
1271 }
1272
1273 publisherID, trackID := rtc.UnpackStreamID(streamID)
1274 if trackID == "" {
1275 trackID = livekit.TrackID(track.ID())
1276 }
1277 c.lock.Lock()
1278 c.subscribedTracks[publisherID] = append(c.subscribedTracks[publisherID], track)
1279 c.lock.Unlock()
1280
1281 logger.Infow(
1282 "client added track",
1283 "participant", c.localParticipant.Identity,
1284 "participantID", c.ID(),
1285 "publisherID", publisherID,
1286 "trackID", trackID,
1287 "codec", track.Codec(),
1288 "ssrc", track.SSRC(),
1289 )
1290
1291 defer func() {
1292 c.lock.Lock()
1293 c.subscribedTracks[publisherID] = funk.Without(c.subscribedTracks[publisherID], track).([]*webrtc.TrackRemote)
1294 c.lock.Unlock()
1295 }()
1296
1297 numBytes := 0
1298 for {
1299 pkt, _, err := track.ReadRTP()
1300 if c.ctx.Err() != nil {
1301 break
1302 }
1303 if rtc.IsEOF(err) {
1304 logger.Infow(
1305 "client track removed",
1306 "participant", c.localParticipant.Identity,
1307 "participantID", c.ID(),
1308 "publisherID", publisherID,
1309 "trackID", trackID,
1310 "codec", track.Codec(),

Callers 2

createTransportMethod · 0.95

Calls 10

IDMethod · 0.95
UnpackStreamIDFunction · 0.92
IsEOFFunction · 0.92
StreamIDMethod · 0.65
CodecMethod · 0.65
SSRCMethod · 0.65
TrackIDMethod · 0.65
IDMethod · 0.65
ReadRTPMethod · 0.65
MarshalSizeMethod · 0.45

Tested by

no test coverage detected