fix race condition accessing rtpSender

This commit is contained in:
Daniel Gultsch 2024-02-17 09:05:40 +01:00
parent e416a6c4eb
commit ca1d8b4d1b
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -65,8 +65,14 @@ class TrackWrapper<T extends MediaStreamTrack> {
public static <T extends MediaStreamTrack> RtpTransceiver getTransceiver(
@Nonnull final PeerConnection peerConnection, final TrackWrapper<T> trackWrapper) {
final RtpSender rtpSender = trackWrapper.rtpSender;
final String rtpSenderId;
try {
rtpSenderId = rtpSender.id();
} catch (final IllegalStateException e) {
return null;
}
for (final RtpTransceiver transceiver : peerConnection.getTransceivers()) {
if (transceiver.getSender().id().equals(rtpSender.id())) {
if (transceiver.getSender().id().equals(rtpSenderId)) {
return transceiver;
}
}