Prevent race of new track and new receiver. (#2345)

* Prevent race of new track and new receiver.

Two different concepts
1. Creation of a new media track
2. Creation of a new receiver inside the media track
collided and caused track published to not be fired.

Unify to mark creation of new receiver as the source of truth.
With simulcast codecs, creation of a new receiver should be treated as a
new published track.

* Fire onTrackPublished only on new track
This commit is contained in:
Raja Subramanian
2023-12-25 23:05:59 +05:30
committed by GitHub
parent 5429edd476
commit bdfc684cd7

View File

@@ -1861,10 +1861,17 @@ func (p *ParticipantImpl) mediaTrackReceived(track *webrtc.TrackRemote, rtpRecei
if mt.AddReceiver(rtpReceiver, track, p.twcc, mid) {
p.removeMutedTrackNotFired(mt)
if newTrack {
p.pubLogger.Debugw("track published", "trackID", mt.ID(), "track", logger.Proto(mt.ToProto()))
go p.handleTrackPublished(mt)
}
}
if newTrack {
go func() {
p.pubLogger.Debugw(
"track published",
"trackID", mt.ID(),
"track", logger.Proto(mt.ToProto()),
)
p.handleTrackPublished(mt)
}()
}
return mt, newTrack