mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Fix missing local participant state changes in group calls bug.
This commit is contained in:
@@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.events
|
||||
|
||||
import com.annimon.stream.OptionalLong
|
||||
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink
|
||||
import org.thoughtcrime.securesms.events.CallParticipant.Companion.HAND_LOWERED
|
||||
import org.thoughtcrime.securesms.events.CallParticipant.Companion.createLocal
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
@@ -113,11 +112,11 @@ class WebRtcViewModel(state: WebRtcServiceState) {
|
||||
val availableDevices: Set<SignalAudioManager.AudioDevice> = state.localDeviceState.availableDevices
|
||||
val bluetoothPermissionDenied: Boolean = state.localDeviceState.bluetoothPermissionDenied
|
||||
|
||||
val localParticipant: CallParticipant = state.callInfoState.localParticipant ?: createLocal(
|
||||
val localParticipant: CallParticipant = createLocal(
|
||||
state.localDeviceState.cameraState,
|
||||
(if (state.videoState.localSink != null) state.videoState.localSink else BroadcastVideoSink())!!,
|
||||
state.localDeviceState.isMicrophoneEnabled,
|
||||
HAND_LOWERED
|
||||
state.localDeviceState.handRaisedTimestamp
|
||||
)
|
||||
|
||||
val isCellularConnection: Boolean = when (state.localDeviceState.networkConnectionType) {
|
||||
|
||||
@@ -260,10 +260,10 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
protected @NonNull WebRtcServiceState handleGroupCallRaisedHand(@NonNull WebRtcServiceState currentState, List<Long> raisedHands) {
|
||||
Log.i(TAG, "handleGroupCallRaisedHand():");
|
||||
|
||||
boolean playSound = !raisedHands.isEmpty();
|
||||
long now = System.currentTimeMillis();
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState();
|
||||
Long localDemuxId = currentState.getCallInfoState().requireGroupCall().getLocalDeviceState().getDemuxId();
|
||||
boolean playSound = !raisedHands.isEmpty();
|
||||
long now = System.currentTimeMillis();
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder callInfoBuilder = currentState.builder().changeCallInfoState();
|
||||
Long localDemuxId = currentState.getCallInfoState().requireGroupCall().getLocalDeviceState().getDemuxId();
|
||||
|
||||
List<CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipants();
|
||||
|
||||
@@ -276,31 +276,25 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
}
|
||||
|
||||
if (raisedHandIndex >= 0 && !wasHandAlreadyRaised) {
|
||||
builder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(now + raisedHandIndex));
|
||||
callInfoBuilder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(now + raisedHandIndex));
|
||||
} else if (raisedHandIndex < 0 && wasHandAlreadyRaised) {
|
||||
builder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(CallParticipant.HAND_LOWERED));
|
||||
callInfoBuilder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(CallParticipant.HAND_LOWERED));
|
||||
}
|
||||
}
|
||||
|
||||
currentState = callInfoBuilder.build();
|
||||
|
||||
if (localDemuxId != null) {
|
||||
if (raisedHands.contains(localDemuxId)) {
|
||||
builder.setLocalParticipant(CallParticipant.createLocal(currentState.getLocalDeviceState().getCameraState(),
|
||||
currentState.getVideoState().requireLocalSink(),
|
||||
currentState.getLocalDeviceState().isMicrophoneEnabled(),
|
||||
now,
|
||||
new CallParticipantId(localDemuxId, Recipient.self().getId())));
|
||||
} else {
|
||||
builder.setLocalParticipant(CallParticipant.createLocal(currentState.getLocalDeviceState().getCameraState(),
|
||||
currentState.getVideoState().requireLocalSink(),
|
||||
currentState.getLocalDeviceState().isMicrophoneEnabled(),
|
||||
CallParticipant.HAND_LOWERED,
|
||||
new CallParticipantId(localDemuxId, Recipient.self().getId())));
|
||||
}
|
||||
currentState = currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.setHandRaisedTimestamp(raisedHands.contains(localDemuxId) ? now : CallParticipant.HAND_LOWERED)
|
||||
.build();
|
||||
}
|
||||
|
||||
if (playSound) {
|
||||
webRtcInteractor.playStateChangeUp();
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
return currentState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ data class CallInfoState(
|
||||
var callRecipient: Recipient = Recipient.UNKNOWN,
|
||||
var callConnectedTime: Long = -1,
|
||||
@get:JvmName("getRemoteCallParticipantsMap") var remoteParticipants: MutableMap<CallParticipantId, CallParticipant> = mutableMapOf(),
|
||||
var localParticipant: CallParticipant? = null,
|
||||
var peerMap: MutableMap<Int, RemotePeer> = mutableMapOf(),
|
||||
var activePeer: RemotePeer? = null,
|
||||
var groupCall: GroupCall? = null,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.service.webrtc.state
|
||||
|
||||
import org.thoughtcrime.securesms.components.sensors.Orientation
|
||||
import org.thoughtcrime.securesms.events.CallParticipant
|
||||
import org.thoughtcrime.securesms.ringrtc.CameraState
|
||||
import org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager
|
||||
import org.webrtc.PeerConnection
|
||||
@@ -8,7 +9,7 @@ import org.webrtc.PeerConnection
|
||||
/**
|
||||
* Local device specific state.
|
||||
*/
|
||||
data class LocalDeviceState constructor(
|
||||
data class LocalDeviceState(
|
||||
var cameraState: CameraState = CameraState.UNKNOWN,
|
||||
var isMicrophoneEnabled: Boolean = true,
|
||||
var orientation: Orientation = Orientation.PORTRAIT_BOTTOM_EDGE,
|
||||
@@ -17,7 +18,8 @@ data class LocalDeviceState constructor(
|
||||
var activeDevice: SignalAudioManager.AudioDevice = SignalAudioManager.AudioDevice.NONE,
|
||||
var availableDevices: Set<SignalAudioManager.AudioDevice> = emptySet(),
|
||||
var bluetoothPermissionDenied: Boolean = false,
|
||||
var networkConnectionType: PeerConnection.AdapterType = PeerConnection.AdapterType.UNKNOWN
|
||||
var networkConnectionType: PeerConnection.AdapterType = PeerConnection.AdapterType.UNKNOWN,
|
||||
var handRaisedTimestamp: Long = CallParticipant.HAND_LOWERED
|
||||
) {
|
||||
|
||||
fun duplicate(): LocalDeviceState {
|
||||
|
||||
@@ -137,6 +137,11 @@ public class WebRtcServiceStateBuilder {
|
||||
toBuild.setNetworkConnectionType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull LocalDeviceStateBuilder setHandRaisedTimestamp(long handRaisedTimestamp) {
|
||||
toBuild.setHandRaisedTimestamp(handRaisedTimestamp);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class CallSetupStateBuilder {
|
||||
@@ -364,10 +369,5 @@ public class WebRtcServiceStateBuilder {
|
||||
toBuild.setCallLinkDisconnectReason(callLinkDisconnectReason);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull CallInfoStateBuilder setLocalParticipant(@NonNull CallParticipant callParticipant) {
|
||||
toBuild.setLocalParticipant(callParticipant);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user