From e3bbe3503f908e1d00146c78c1cb4d31837b7b6e Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 29 Apr 2025 18:50:35 +0200 Subject: [PATCH] show own video in pip mode for group calls Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/activities/CallActivity.kt | 34 ++++++++++++++----- app/src/main/res/layout/call_activity.xml | 28 ++++----------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index 8b7460725..d62a24060 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -901,7 +901,7 @@ class CallActivity : CallBaseActivity() { if (cameraEnumerator!!.deviceNames.size < 2) { binding!!.switchSelfVideoButton.visibility = View.GONE } - initSelfVideoView() + initSelfVideoViewForNormalMode() } binding!!.gridview.setOnTouchListener { _, me -> val action = me.actionMasked @@ -924,7 +924,7 @@ class CallActivity : CallBaseActivity() { } @SuppressLint("ClickableViewAccessibility") - private fun initSelfVideoView() { + private fun initSelfVideoViewForNormalMode() { try { binding!!.selfVideoRenderer.init(rootEglBase!!.eglBaseContext, null) } catch (e: IllegalStateException) { @@ -937,6 +937,20 @@ class CallActivity : CallBaseActivity() { binding!!.selfVideoRenderer.setOnTouchListener(SelfVideoTouchListener()) } + private fun initSelfVideoViewForPipMode() { + try { + binding!!.pipSelfVideoRenderer.init(rootEglBase!!.eglBaseContext, null) + } catch (e: IllegalStateException) { + Log.d(TAG, "pipGroupVideoRenderer already initialized", e) + } + binding!!.pipSelfVideoRenderer.setZOrderMediaOverlay(true) + // disabled because it causes some devices to crash + binding!!.pipSelfVideoRenderer.setEnableHardwareScaler(false) + binding!!.pipSelfVideoRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) + + localVideoTrack!!.addSink(binding!!.pipSelfVideoRenderer) + } + private fun initGridAdapter() { Log.d(TAG, "initGridAdapter") val columns: Int @@ -3211,17 +3225,20 @@ class CallActivity : CallBaseActivity() { binding!!.callInfosLinearLayout.visibility = View.GONE binding!!.selfVideoViewWrapper.visibility = View.GONE binding!!.callStates.callStateRelativeLayout.visibility = View.GONE - if (participantDisplayItems!!.size > 1) { - binding!!.pipCallConversationNameTextView.text = conversationName - binding!!.pipGroupCallOverlay.visibility = View.VISIBLE - } else { - binding!!.pipGroupCallOverlay.visibility = View.GONE - } + binding!!.selfVideoRenderer.release() + if (participantDisplayItems!!.size > 1) { + binding!!.pipSelfVideoOverlay.visibility = View.VISIBLE + initSelfVideoViewForPipMode() + } else { + binding!!.pipSelfVideoOverlay.visibility = View.GONE + } } override fun updateUiForNormalMode() { Log.d(TAG, "updateUiForNormalMode") + binding!!.pipSelfVideoOverlay.visibility = View.GONE + if (isVoiceOnlyCall) { binding!!.callControls.visibility = View.VISIBLE } else { @@ -3231,7 +3248,6 @@ class CallActivity : CallBaseActivity() { initViews() binding!!.callInfosLinearLayout.visibility = View.VISIBLE binding!!.selfVideoViewWrapper.visibility = View.VISIBLE - binding!!.pipGroupCallOverlay.visibility = View.GONE } override fun suppressFitsSystemWindows() { diff --git a/app/src/main/res/layout/call_activity.xml b/app/src/main/res/layout/call_activity.xml index 4c256eb09..3b8f54726 100644 --- a/app/src/main/res/layout/call_activity.xml +++ b/app/src/main/res/layout/call_activity.xml @@ -331,7 +331,7 @@ - - - - + android:layout_height="match_parent" + android:layout_gravity="center" + android:clickable="false" + tools:visibility="visible" />