diff --git a/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ConferenceWaitingRoomViewModel.kt b/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ConferenceWaitingRoomViewModel.kt index eeed7e054..a76e0a148 100644 --- a/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ConferenceWaitingRoomViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ConferenceWaitingRoomViewModel.kt @@ -96,7 +96,8 @@ class ConferenceWaitingRoomViewModel : ViewModel() { updateMicState() isVideoAvailable.value = core.isVideoCaptureEnabled || core.isVideoPreviewEnabled - callParams.isVideoEnabled = core.videoActivationPolicy.automaticallyInitiate + callParams.isVideoEnabled = isVideoAvailable.value == true + callParams.videoDirection = if (core.videoActivationPolicy.automaticallyInitiate) MediaDirection.SendRecv else MediaDirection.RecvOnly Log.i("[Conference Waiting Room] Video will be ${if (callParams.isVideoEnabled) "enabled" else "disabled"}") updateVideoState() @@ -192,14 +193,14 @@ class ConferenceWaitingRoomViewModel : ViewModel() { askPermissionEvent.value = Event(Manifest.permission.CAMERA) return } - callParams.isVideoEnabled = !callParams.isVideoEnabled + callParams.videoDirection = if (callParams.videoDirection == MediaDirection.SendRecv) MediaDirection.RecvOnly else MediaDirection.SendRecv Log.i("[Conference Waiting Room] Video will be ${if (callParams.isVideoEnabled) "enabled" else "disabled"}") updateVideoState() } fun enableVideo() { Log.i("[Conference Waiting Room] Video will be enabled") - callParams.isVideoEnabled = true + callParams.videoDirection = MediaDirection.SendRecv updateVideoState() } @@ -247,7 +248,7 @@ class ConferenceWaitingRoomViewModel : ViewModel() { } private fun updateVideoState() { - isVideoEnabled.value = callParams.isVideoEnabled + isVideoEnabled.value = callParams.videoDirection == MediaDirection.SendRecv isSwitchCameraAvailable.value = callParams.isVideoEnabled && coreContext.showSwitchCameraButton() coreContext.core.isVideoPreviewEnabled = callParams.isVideoEnabled } diff --git a/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt b/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt index a6a1e8f54..82242394b 100644 --- a/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt +++ b/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt @@ -21,6 +21,7 @@ package org.linphone.activities.voip.data import android.graphics.SurfaceTexture import android.view.TextureView +import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MutableLiveData import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.contact.GenericContactData @@ -35,7 +36,11 @@ class ConferenceParticipantDeviceData( val isMe: Boolean ) : GenericContactData(participantDevice.address) { - val videoEnabled = MutableLiveData() + val videoEnabled: MediatorLiveData = MediatorLiveData() + + val videoAvailable = MutableLiveData() + + val videoSendReceive = MutableLiveData() val activeSpeaker = MutableLiveData() @@ -73,6 +78,7 @@ class ConferenceParticipantDeviceData( ) { if (streamType == StreamType.Video) { Log.i("[Conference Participant Device] Participant [${participantDevice.address.asStringUriOnly()}] video capability changed to $direction") + videoSendReceive.value = direction == MediaDirection.SendRecv } } @@ -83,7 +89,7 @@ class ConferenceParticipantDeviceData( ) { if (streamType == StreamType.Video) { Log.i("[Conference Participant Device] Participant [${participantDevice.address.asStringUriOnly()}] video availability changed to ${if (available) "available" else "unavailable"}") - videoEnabled.value = available + videoAvailable.value = available if (available) { updateWindowId(textureView) } @@ -96,12 +102,21 @@ class ConferenceParticipantDeviceData( participantDevice.addListener(listener) activeSpeaker.value = false - videoEnabled.value = participantDevice.getStreamAvailability(StreamType.Video) + videoAvailable.value = participantDevice.getStreamAvailability(StreamType.Video) + val videoCapability = participantDevice.getStreamCapability(StreamType.Video) + videoSendReceive.value = videoCapability == MediaDirection.SendRecv micMuted.value = false // TODO isInConference.value = participantDevice.isInConference - val videoCapability = participantDevice.getStreamCapability(StreamType.Video) - Log.i("[Conference Participant Device] Participant [${participantDevice.address.asStringUriOnly()}], is in conf? ${isInConference.value}, is video enabled? ${videoEnabled.value} ($videoCapability)") + videoEnabled.value = isVideoAvailableAndSendReceive() + videoEnabled.addSource(videoAvailable) { + videoEnabled.value = isVideoAvailableAndSendReceive() + } + videoEnabled.addSource(videoSendReceive) { + videoEnabled.value = isVideoAvailableAndSendReceive() + } + + Log.i("[Conference Participant Device] Participant [${participantDevice.address.asStringUriOnly()}], is in conf? ${isInConference.value}, is video available? ${videoAvailable.value} ($videoCapability)") } override fun destroy() { @@ -161,4 +176,8 @@ class ConferenceParticipantDeviceData( participantDevice.nativeVideoWindowId = windowId } } + + private fun isVideoAvailableAndSendReceive(): Boolean { + return videoAvailable.value == true && videoSendReceive.value == true + } } diff --git a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt index 6ef84175b..25729b8c0 100644 --- a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt +++ b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt @@ -54,6 +54,8 @@ class ControlsViewModel : ViewModel() { val isVideoEnabled = MutableLiveData() + val isVideoSendReceive = MutableLiveData() + val isVideoUpdateInProgress = MutableLiveData() val isSwitchCameraAvailable = MutableLiveData() @@ -316,7 +318,20 @@ class ControlsViewModel : ViewModel() { isVideoUpdateInProgress.value = true val params = core.createCallParams(currentCall) - params?.isVideoEnabled = !currentCall.currentParams.isVideoEnabled + if (currentCall.conference != null) { + if (params?.isVideoEnabled == false) { + params.isVideoEnabled = true + params.videoDirection = MediaDirection.SendRecv + } else { + if (params?.videoDirection == MediaDirection.SendRecv) { + params.videoDirection = MediaDirection.RecvOnly + } else { + params?.videoDirection = MediaDirection.SendRecv + } + } + } else { + params?.isVideoEnabled = !currentCall.currentParams.isVideoEnabled + } currentCall.update(params) } } @@ -446,8 +461,14 @@ class ControlsViewModel : ViewModel() { } } } + isVideoEnabled.value = enabled isSwitchCameraAvailable.value = enabled && coreContext.showSwitchCameraButton() + if (coreContext.core.currentCall?.conference != null) { + isVideoSendReceive.value = coreContext.core.currentCall?.currentParams?.videoDirection == MediaDirection.SendRecv + } else { + isVideoSendReceive.value = true + } } private fun shouldProximitySensorBeEnabled(): Boolean { diff --git a/app/src/main/res/layout/chat_message_content_cell.xml b/app/src/main/res/layout/chat_message_content_cell.xml index a969f48ba..246fb0cec 100644 --- a/app/src/main/res/layout/chat_message_content_cell.xml +++ b/app/src/main/res/layout/chat_message_content_cell.xml @@ -121,7 +121,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" - android:textColor="?attr/secondaryTextColor" style="@style/file_transfer_progress_font" android:text="@{data.downloadProgressString, default=`50%`}"/> diff --git a/app/src/main/res/layout/voip_buttons.xml b/app/src/main/res/layout/voip_buttons.xml index cfba92728..7a4cd50c2 100644 --- a/app/src/main/res/layout/voip_buttons.xml +++ b/app/src/main/res/layout/voip_buttons.xml @@ -94,7 +94,7 @@ diff --git a/app/src/main/res/layout/voip_call.xml b/app/src/main/res/layout/voip_call.xml index e299c6049..4c94a49f8 100644 --- a/app/src/main/res/layout/voip_call.xml +++ b/app/src/main/res/layout/voip_call.xml @@ -145,7 +145,7 @@