diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 3cbf0e51c..8b0cbd6f1 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -62,6 +62,7 @@ android:networkSecurityConfig="@xml/network_security_configuration" android:theme="@style/ConversationsTheme" tools:replace="android:label" + android:hardwareAccelerated="true" tools:targetApi="o"> <meta-data diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 72db2d88e..2d335ec75 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -201,7 +201,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe resetIntent(intent.getExtras()); } } else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(intent.getAction())) { - proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO)); + proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO, Media.VIDEO)); binding.with.setText(account.getRoster().getContact(with).getDisplayName()); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE); @@ -296,27 +296,33 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe private void updateVideoViews() { final Optional<VideoTrack> localVideoTrack = requireRtpConnection().geLocalVideoTrack(); if (localVideoTrack.isPresent()) { - try { - binding.localVideo.init(requireRtpConnection().getEglBaseContext(), null); - } catch (IllegalStateException e) { - Log.d(Config.LOGTAG,"ignoring already init for now",e); - } - binding.localVideo.setEnableHardwareScaler(true); + ensureSurfaceViewRendererIsSetup(binding.localVideo); + //paint local view over remote view + binding.localVideo.setZOrderMediaOverlay(true); binding.localVideo.setMirror(true); localVideoTrack.get().addSink(binding.localVideo); + } else { + binding.localVideo.setVisibility(View.GONE); } final Optional<VideoTrack> remoteVideoTrack = requireRtpConnection().getRemoteVideoTrack(); if (remoteVideoTrack.isPresent()) { - try { - binding.remoteVideo.init(requireRtpConnection().getEglBaseContext(), null); - } catch (IllegalStateException e) { - Log.d(Config.LOGTAG,"ignoring already init for now",e); - } - binding.remoteVideo.setEnableHardwareScaler(true); + ensureSurfaceViewRendererIsSetup(binding.remoteVideo); remoteVideoTrack.get().addSink(binding.remoteVideo); + } else { + binding.remoteVideo.setVisibility(View.GONE); } } + private void ensureSurfaceViewRendererIsSetup(final SurfaceViewRenderer surfaceViewRenderer) { + surfaceViewRenderer.setVisibility(View.VISIBLE); + try { + surfaceViewRenderer.init(requireRtpConnection().getEglBaseContext(), null); + } catch (IllegalStateException e) { + Log.d(Config.LOGTAG, "SurfaceViewRenderer was already initialized"); + } + surfaceViewRenderer.setEnableHardwareScaler(true); + } + private void updateStateDisplay(final RtpEndUserState state) { switch (state) { case INCOMING_CALL: @@ -484,7 +490,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe final Account account = extractAccount(intent); final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); this.rtpConnectionReference = null; - proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO)); + proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO, Media.VIDEO)); } private void exit(View view) { diff --git a/src/main/res/layout/activity_rtp_session.xml b/src/main/res/layout/activity_rtp_session.xml index 3b1390db6..a9b279334 100644 --- a/src/main/res/layout/activity_rtp_session.xml +++ b/src/main/res/layout/activity_rtp_session.xml @@ -35,16 +35,6 @@ </android.support.design.widget.AppBarLayout> - <org.webrtc.SurfaceViewRenderer - android:id="@+id/remote_video" - android:layout_width="match_parent" - android:layout_height="100dp" - android:layout_below="@+id/app_bar_layout" - android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" - android:layout_alignParentBottom="true" - android:visibility="visible" /> - <org.webrtc.SurfaceViewRenderer android:id="@+id/local_video" android:layout_width="80dp" @@ -55,7 +45,17 @@ android:layout_marginTop="24dp" android:layout_marginEnd="24dp" android:layout_marginRight="24dp" - android:visibility="visible" /> + android:visibility="gone" /> + + <org.webrtc.SurfaceViewRenderer + android:id="@+id/remote_video" + android:layout_width="match_parent" + android:layout_height="100dp" + android:layout_below="@+id/app_bar_layout" + android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" + android:layout_alignParentBottom="true" + android:visibility="gone" /> <RelativeLayout