diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 479fa9769..a696d1c39 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -18,6 +18,7 @@ import android.widget.Toast; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; +import org.webrtc.RendererCommon; import org.webrtc.SurfaceViewRenderer; import org.webrtc.VideoTrack; @@ -241,6 +242,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe @Override public void onStop() { + binding.remoteVideo.release(); + binding.localVideo.release(); releaseProximityWakeLock(); //TODO maybe we want to finish if call had ended super.onStop(); 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 a6fe340ee..4b207dcc5 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -139,6 +139,7 @@ public class WebRTCWrapper { private AppRTCAudioManager appRTCAudioManager = null; private Context context = null; private EglBase eglBase = null; + private Optional optionalCapturer; public WebRTCWrapper(final EventCallback eventCallback) { this.eventCallback = eventCallback; @@ -167,10 +168,10 @@ public class WebRTCWrapper { final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); - final Optional optionalCapturer = getVideoCapturer(); + this.optionalCapturer = getVideoCapturer(); - if (optionalCapturer.isPresent()) { - final CameraVideoCapturer capturer = optionalCapturer.get(); + if (this.optionalCapturer.isPresent()) { + final CameraVideoCapturer capturer = this.optionalCapturer.get(); final VideoSource videoSource = peerConnectionFactory.createVideoSource(false); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext()); capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver()); @@ -207,6 +208,16 @@ public class WebRTCWrapper { if (audioManager != null) { mainHandler.post(audioManager::stop); } + this.localVideoTrack = null; + this.remoteVideoTrack = null; + if (this.optionalCapturer.isPresent()) { + try { + this.optionalCapturer.get().stopCapture(); + } catch (InterruptedException e) { + Log.e(Config.LOGTAG,"unable to stop capturing"); + } + } + eglBase.release(); } public boolean isMicrophoneEnabled() { @@ -326,7 +337,7 @@ public class WebRTCWrapper { private Optional getVideoCapturer() { final CameraEnumerator enumerator = getCameraEnumerator(); final String[] deviceNames = enumerator.getDeviceNames(); - for (String deviceName : deviceNames) { + for (final String deviceName : deviceNames) { if (enumerator.isFrontFacing(deviceName)) { return Optional.fromNullable(enumerator.createCapturer(deviceName, null)); } diff --git a/src/main/res/layout/activity_rtp_session.xml b/src/main/res/layout/activity_rtp_session.xml index 5f7fdec69..3b1390db6 100644 --- a/src/main/res/layout/activity_rtp_session.xml +++ b/src/main/res/layout/activity_rtp_session.xml @@ -35,24 +35,28 @@ - - - + android:layout_alignParentBottom="true" + android:visibility="visible" /> + + +