From c0b0ef66ff59bc699adf0dbeb7f963a086ac556a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 15 Apr 2024 12:20:11 +0200 Subject: [PATCH] Trying to fix lost remote video upon rotation --- .../ui/call/fragment/ActiveCallFragment.kt | 22 +++++++++---------- .../ui/call/viewmodel/CurrentCallViewModel.kt | 7 ++++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt index c50fc4263..52bbd913b 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt @@ -336,18 +336,14 @@ class ActiveCallFragment : GenericCallFragment() { } callViewModel.isSendingVideo.observe(viewLifecycleOwner) { sending -> - coreContext.core.nativePreviewWindowId = if (sending) { - binding.localPreviewVideoSurface - } else { - null - } - } - - callViewModel.isReceivingVideo.observe(viewLifecycleOwner) { receiving -> - coreContext.core.nativeVideoWindowId = if (receiving) { - binding.remoteVideoSurface - } else { - null + coreContext.postOnCoreThread { core -> + core.nativePreviewWindowId = if (sending) { + Log.i("$TAG We are sending video, setting capture preview surface") + binding.localPreviewVideoSurface + } else { + Log.i("$TAG We are not sending video, clearing capture preview surface") + null + } } } @@ -384,6 +380,8 @@ class ActiveCallFragment : GenericCallFragment() { super.onResume() coreContext.postOnCoreThread { core -> + core.nativeVideoWindowId = binding.remoteVideoSurface + binding.localPreviewVideoSurface.setOnTouchListener(previewTouchListener) // Need to be done manually diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt index 361ab2afe..c994db03b 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt @@ -1070,12 +1070,15 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { @WorkerThread private fun updateVideoDirection(direction: MediaDirection) { + val isSending = direction == MediaDirection.SendRecv || direction == MediaDirection.SendOnly + val isReceived = direction == MediaDirection.SendRecv || direction == MediaDirection.RecvOnly isSendingVideo.postValue( - direction == MediaDirection.SendRecv || direction == MediaDirection.SendOnly + isSending ) isReceivingVideo.postValue( - direction == MediaDirection.SendRecv || direction == MediaDirection.RecvOnly + isReceived ) + Log.i("$TAG Is video being sent? [$isSending] Is video being received? [$isReceived]") } @AnyThread