Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cant see my video from other client [#WPB-12179] #3773

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,8 @@ class CallsModule {
@Provides
fun provideObserveConferenceCallingEnabledUseCase(callsScope: CallsScope) =
callsScope.observeConferenceCallingEnabled

@ViewModelScoped
@Provides
fun provideCurrentClientIdUseCase(callsScope: CallsScope) = callsScope.getCurrentClientIdUseCase
}
4 changes: 3 additions & 1 deletion app/src/main/kotlin/com/wire/android/ui/calling/CallState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package com.wire.android.ui.calling
import androidx.compose.runtime.Stable
import com.wire.android.model.ImageAsset.UserAvatarAsset
import com.wire.android.ui.home.conversationslist.model.Membership
import com.wire.android.util.EMPTY
import com.wire.kalium.logic.data.call.CallStatus
import com.wire.kalium.logic.data.call.ConversationTypeForCall
import com.wire.kalium.logic.data.conversation.Conversation
Expand All @@ -43,5 +44,6 @@ data class CallState(
val membership: Membership = Membership.None,
val protocolInfo: Conversation.ProtocolInfo? = null,
val mlsVerificationStatus: Conversation.VerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
val proteusVerificationStatus: Conversation.VerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
val proteusVerificationStatus: Conversation.VerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
val currentClientId: String = String.EMPTY
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.wire.android.mapper.UserTypeMapper
import com.wire.android.media.CallRinger
import com.wire.android.model.ImageAsset
import com.wire.android.ui.calling.model.UICallParticipant
import com.wire.android.util.EMPTY
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.kalium.logic.data.call.Call
import com.wire.kalium.logic.data.call.ConversationTypeForCall
Expand All @@ -40,6 +41,7 @@ import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.feature.call.usecase.EndCallUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToBackCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToFrontCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.GetCurrentClientIdUseCase
import com.wire.kalium.logic.feature.call.usecase.MuteCallUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallWithSortedParticipantsUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveSpeakerUseCase
Expand All @@ -49,6 +51,7 @@ import com.wire.kalium.logic.feature.call.usecase.TurnLoudSpeakerOnUseCase
import com.wire.kalium.logic.feature.call.usecase.UnMuteCallUseCase
import com.wire.kalium.logic.feature.call.usecase.video.UpdateVideoStateUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.functional.fold
import com.wire.kalium.logic.util.PlatformView
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
Expand Down Expand Up @@ -86,9 +89,9 @@ class SharedCallingViewModel @AssistedInject constructor(
private val callRinger: CallRinger,
private val uiCallParticipantMapper: UICallParticipantMapper,
private val userTypeMapper: UserTypeMapper,
private val dispatchers: DispatcherProvider
private val dispatchers: DispatcherProvider,
private val getCurrentClientIdUseCase: GetCurrentClientIdUseCase
) : ViewModel() {

var callState by mutableStateOf(CallState(conversationId))

var participantsState by mutableStateOf(persistentListOf<UICallParticipant>())
Expand All @@ -110,6 +113,18 @@ class SharedCallingViewModel @AssistedInject constructor(
launch {
observeOnSpeaker(this)
}
launch {
getCurrentClientId()
}
}
}

private fun getCurrentClientId() {
viewModelScope.launch {
callState = callState.copy(
currentClientId = getCurrentClientIdUseCase()
.fold({ String.EMPTY }, { it.value })
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fun OngoingCallScreen(
onCameraPermissionPermanentlyDenied = onCameraPermissionPermanentlyDenied,
participants = sharedCallingViewModel.participantsState,
inPictureInPictureMode = inPictureInPictureMode,
currentUserId = ongoingCallViewModel.currentUserId,
currentUserId = ongoingCallViewModel.currentUserId
)

BackHandler {
Expand Down Expand Up @@ -417,6 +417,7 @@ private fun OngoingCallContent(
onSelfClearVideoPreview = clearVideoPreview,
requestVideoStreams = requestVideoStreams,
currentUserId = currentUserId,
currentClientId = callState.currentClientId,
onDoubleTap = { selectedParticipant ->
onSelectedParticipant(selectedParticipant)
shouldOpenFullScreen = !shouldOpenFullScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fun VerticalCallingPager(
isInPictureInPictureMode: Boolean,
contentHeight: Dp,
currentUserId: UserId,
currentClientId: String,
onSelfVideoPreviewCreated: (view: View) -> Unit,
onSelfClearVideoPreview: () -> Unit,
requestVideoStreams: (participants: List<UICallParticipant>) -> Unit,
Expand Down Expand Up @@ -107,6 +108,7 @@ fun VerticalCallingPager(
onSelfClearVideoPreview = onSelfClearVideoPreview,
onDoubleTap = onDoubleTap,
currentUserId = currentUserId,
currentClientId = currentClientId
)
} else {
GroupCallGrid(
Expand All @@ -119,6 +121,7 @@ fun VerticalCallingPager(
onSelfClearVideoPreview = onSelfClearVideoPreview,
onDoubleTap = onDoubleTap,
currentUserId = currentUserId,
currentClientId = currentClientId,
isInPictureInPictureMode = isInPictureInPictureMode,
)
}
Expand Down Expand Up @@ -179,6 +182,7 @@ private fun PreviewVerticalCallingPager(participants: List<UICallParticipant>) {
onDoubleTap = { },
isInPictureInPictureMode = false,
currentUserId = participants[0].id,
currentClientId = "clientId"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.times
import com.wire.android.BuildConfig
import com.wire.android.ui.calling.model.UICallParticipant
import com.wire.android.ui.calling.ongoing.buildPreviewParticipantsList
import com.wire.android.ui.calling.ongoing.fullscreen.SelectedParticipant
Expand All @@ -51,6 +52,7 @@ fun GroupCallGrid(
isSelfUserCameraOn: Boolean,
contentHeight: Dp,
currentUserId: UserId,
currentClientId: String,
onSelfVideoPreviewCreated: (view: View) -> Unit,
onSelfClearVideoPreview: () -> Unit,
onDoubleTap: (selectedParticipant: SelectedParticipant) -> Unit,
Expand Down Expand Up @@ -82,7 +84,11 @@ fun GroupCallGrid(
contentType = { getContentType(it.isCameraOn, it.isSharingScreen) }
) { participant ->
// API returns only id.value, without domain, till this get changed compare only id.value
val isSelfUser = participant.id.equalsIgnoringBlankDomain(currentUserId)
// We also check the client ID because if we are using two devices and one is screen sharing,
// the second device cannot be marked as the owner. Otherwise, the shared screen preview will not be visible.
val isCurrentUserOwner = participant.id.equalsIgnoringBlankDomain(currentUserId)
&& participant.clientId == currentClientId
&& !BuildConfig.PICTURE_IN_PICTURE_ENABLED

ParticipantTile(
modifier = Modifier
Expand All @@ -93,7 +99,7 @@ fun GroupCallGrid(
SelectedParticipant(
userId = participant.id,
clientId = participant.clientId,
isSelfUser = isSelfUser
isSelfUser = isCurrentUserOwner
)
)
}
Expand All @@ -103,7 +109,7 @@ fun GroupCallGrid(
.animateItem(),
participantTitleState = participant,
isOnPiPMode = isInPictureInPictureMode,
isSelfUser = isSelfUser,
isSelfUser = isCurrentUserOwner,
isSelfUserMuted = isSelfUserMuted,
isSelfUserCameraOn = isSelfUserCameraOn,
onSelfUserVideoPreviewCreated = onSelfVideoPreviewCreated,
Expand Down Expand Up @@ -140,6 +146,7 @@ private fun PreviewGroupCallGrid(participants: List<UICallParticipant>, modifier
onSelfClearVideoPreview = {},
onDoubleTap = { },
currentUserId = UserId("id", "domain"),
currentClientId = "clientId",
isInPictureInPictureMode = false,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.times
import com.wire.android.BuildConfig
import com.wire.android.ui.calling.model.UICallParticipant
import com.wire.android.ui.calling.ongoing.buildPreviewParticipantsList
import com.wire.android.ui.calling.ongoing.fullscreen.SelectedParticipant
Expand All @@ -50,6 +51,7 @@ fun CallingHorizontalView(
isSelfUserCameraOn: Boolean,
contentHeight: Dp,
currentUserId: UserId,
currentClientId: String,
onSelfVideoPreviewCreated: (view: View) -> Unit,
onSelfClearVideoPreview: () -> Unit,
onDoubleTap: (selectedParticipant: SelectedParticipant) -> Unit,
Expand All @@ -70,7 +72,12 @@ fun CallingHorizontalView(
) {
items(items = participants, key = { it.id.toString() + it.clientId }) { participant ->
// API returns only id.value, without domain, till this get changed compare only id.value
val isSelfUser = participant.id.equalsIgnoringBlankDomain(currentUserId)
// We also check the client ID because if we are using two devices and one is screen sharing,
// the second device cannot be marked as the owner. Otherwise, the shared screen preview will not be visible.
val isCurrentUserOwner = participant.id.equalsIgnoringBlankDomain(currentUserId)
&& participant.clientId == currentClientId
&& !BuildConfig.PICTURE_IN_PICTURE_ENABLED

ParticipantTile(
modifier = Modifier
.pointerInput(Unit) {
Expand All @@ -80,7 +87,7 @@ fun CallingHorizontalView(
SelectedParticipant(
userId = participant.id,
clientId = participant.clientId,
isSelfUser = isSelfUser
isSelfUser = isCurrentUserOwner
)
)
}
Expand All @@ -90,7 +97,7 @@ fun CallingHorizontalView(
.height(tileHeight)
.animateItem(),
participantTitleState = participant,
isSelfUser = isSelfUser,
isSelfUser = isCurrentUserOwner,
isSelfUserMuted = isSelfUserMuted,
isSelfUserCameraOn = isSelfUserCameraOn,
onSelfUserVideoPreviewCreated = onSelfVideoPreviewCreated,
Expand All @@ -112,6 +119,7 @@ fun PreviewCallingHorizontalView(
isSelfUserCameraOn = false,
contentHeight = 800.dp,
currentUserId = UserId("id", "domain"),
currentClientId = "clientId",
onSelfVideoPreviewCreated = {},
onSelfClearVideoPreview = {},
onDoubleTap = { },
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 46 files
+27 −0 data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/InCallReactionMessage.kt
+5 −0 data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/Message.kt
+5 −0 data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt
+1 −0 data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContentLogging.kt
+1 −1 gradle/libs.versions.toml
+48 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/InCallReactionsRepository.kt
+7 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationRepository.kt
+24 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageRepository.kt
+3 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/PersistMessageUseCase.kt
+32 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/ProtoContentMapper.kt
+6 −6 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserRepository.kt
+11 −3 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+16 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/CallsScope.kt
+38 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/GetCurrentClientIdUseCase.kt
+39 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveInCallReactionsUseCase.kt
+51 −0 ...c/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/ClearConversationAssetsLocallyUseCase.kt
+16 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/ConversationScope.kt
+48 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/DeleteConversationLocallyUseCase.kt
+70 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/incallreaction/SendInCallReactionUseCase.kt
+53 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/GetNextAudioMessageInConversationUseCase.kt
+57 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/GetSenderNameByMessageIdUseCase.kt
+16 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MessageScope.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MessageSendFailureHandler.kt
+1 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/PersistMigratedMessagesUseCase.kt
+9 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/user/ObserveUserInfoUseCase.kt
+8 −7 ...src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/ApplicationMessageHandler.kt
+43 −0 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/InCallReactionsRepositoryTest.kt
+19 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/ProtoContentMapperTest.kt
+1 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/prekey/MessageSendFailureHandlerTest.kt
+111 −0 ...c/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/ClearConversationAssetsLocallyUseCaseTest.kt
+137 −0 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/DeleteConversationLocallyUseCaseTest.kt
+3 −3 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneResolverTest.kt
+119 −0 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/incallreaction/SendInCallReactionUseCaseTest.kt
+109 −0 ...src/commonTest/kotlin/com/wire/kalium/logic/feature/message/GetNextAudioMessageInConversationUseCaseTest.kt
+108 −0 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/GetSenderNameByMessageIdUseCaseTest.kt
+36 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/user/ObserveUserInfoUseCaseTest.kt
+40 −0 ...commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/ApplicationMessageHandlerTest.kt
+2 −2 logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/UserRepositoryArrangement.kt
+8 −0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/MessageAssetView.sq
+8 −0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Messages.sq
+4 −0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Users.sq
+3 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAO.kt
+22 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOImpl.kt
+1 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/UserDatabaseBuilder.kt
+160 −0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOTest.kt
+20 −7 protobuf-codegen/src/main/proto/messages.proto
Loading