From 644e5aa856559173086fe27aaa1e707be6a4b25d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 17 Apr 2020 14:33:56 +0200 Subject: [PATCH] remove video sinks when calling onStop. otherwise going in and out foreground will give us endless sinks --- .../conversations/ui/RtpSessionActivity.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 4b71a86fc..a27808f3e 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -270,11 +270,26 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe public void onStop() { binding.remoteVideo.release(); binding.localVideo.release(); + final WeakReference weakReference = this.rtpConnectionReference; + final JingleRtpConnection jingleRtpConnection = weakReference == null ? null : weakReference.get(); + if (jingleRtpConnection != null) { + releaseVideoTracks(jingleRtpConnection); + } releaseProximityWakeLock(); - //TODO maybe we want to finish if call had ended super.onStop(); } + private void releaseVideoTracks(final JingleRtpConnection jingleRtpConnection) { + final Optional remoteVideo = jingleRtpConnection.getRemoteVideoTrack(); + if (remoteVideo.isPresent()) { + remoteVideo.get().removeSink(binding.remoteVideo); + } + final Optional localVideo = jingleRtpConnection.geLocalVideoTrack(); + if (localVideo.isPresent()) { + localVideo.get().removeSink(binding.localVideo); + } + } + @Override public void onBackPressed() { endCall();