show own video in pip mode for group calls

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-04-29 18:50:35 +02:00
parent 947d064c34
commit e3bbe3503f
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 32 additions and 30 deletions

View File

@ -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() {

View File

@ -331,7 +331,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/pipGroupCallOverlay"
android:id="@+id/pipSelfVideoOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
@ -339,27 +339,13 @@
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/pipCallConversationNameTextView"
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pipSelfVideoRenderer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="-30dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="15dp"
android:ellipsize="end"
android:maxLines="3"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="our group call" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
app:srcCompat="@drawable/ic_circular_group"
tools:ignore="ContentDescription" />
android:layout_height="match_parent"
android:layout_gravity="center"
android:clickable="false"
tools:visibility="visible" />
</LinearLayout>
</RelativeLayout>