catch ISE cause by race when displaying video track. fixes #3752

This commit is contained in:
Daniel Gultsch 2020-05-27 15:53:05 +02:00
parent 5e3aab3abe
commit 63ba21a512

View file

@ -764,14 +764,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
//paint local view over remote view
binding.localVideo.setZOrderMediaOverlay(true);
binding.localVideo.setMirror(requireRtpConnection().isFrontCamera());
localVideoTrack.get().addSink(binding.localVideo);
addSink(localVideoTrack.get(), binding.localVideo);
} else {
binding.localVideo.setVisibility(View.GONE);
}
final Optional<VideoTrack> remoteVideoTrack = getRemoteVideoTrack();
if (remoteVideoTrack.isPresent()) {
ensureSurfaceViewRendererIsSetup(binding.remoteVideo);
remoteVideoTrack.get().addSink(binding.remoteVideo);
addSink(remoteVideoTrack.get(), binding.remoteVideo);
if (state == RtpEndUserState.CONNECTED) {
binding.appBarLayout.setVisibility(View.GONE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@ -791,6 +791,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
}
}
private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) {
try {
videoTrack.addSink(surfaceViewRenderer);
} catch (final IllegalStateException e) {
Log.e(Config.LOGTAG,"possible race condition on trying to display video track. ignoring",e);
}
}
private Optional<VideoTrack> getLocalVideoTrack() {
final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null;
if (connection == null) {