From 7e9980d9973e1d0d1b2c9e2c7e7e594502174169 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 2 Oct 2023 11:48:03 +0200 Subject: [PATCH] catch illegal state exception in TrackWrapper --- .../conversations/xmpp/jingle/TrackWrapper.java | 12 +++++++++--- .../conversations/xmpp/jingle/WebRTCWrapper.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/TrackWrapper.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/TrackWrapper.java index 31c3577ee..e62aa18fd 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/TrackWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/TrackWrapper.java @@ -6,6 +6,8 @@ import com.google.common.base.CaseFormat; import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import eu.siacs.conversations.Config; + import org.webrtc.MediaStreamTrack; import org.webrtc.PeerConnection; import org.webrtc.RtpSender; @@ -16,8 +18,6 @@ import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import eu.siacs.conversations.Config; - class TrackWrapper { public final T track; public final RtpSender rtpSender; @@ -43,7 +43,13 @@ class TrackWrapper { final RtpTransceiver transceiver = peerConnection == null ? null : getTransceiver(peerConnection, trackWrapper); if (transceiver == null) { - Log.w(Config.LOGTAG, "unable to detect transceiver for " + trackWrapper.rtpSender.id()); + final String id; + try { + id = trackWrapper.rtpSender.id(); + } catch (final IllegalStateException e) { + return Optional.absent(); + } + Log.w(Config.LOGTAG, "unable to detect transceiver for " + id); return Optional.of(trackWrapper.track); } final RtpTransceiver.RtpTransceiverDirection direction = transceiver.getDirection(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java index ba7e078f3..c30b1d58f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -520,7 +520,7 @@ public class WebRTCWrapper { return false; } } else { - throw new IllegalStateException("Local audio track does not exist (yet)"); + return false; } }