Mute in lobby if accepting large group call.

This commit is contained in:
Greyson Parrelli
2026-02-13 12:16:48 -05:00
committed by Alex Hart
parent ac59528f5c
commit c7476a2a07
6 changed files with 31 additions and 1 deletions

View File

@@ -197,6 +197,7 @@ data class CallParticipantsState(
companion object {
const val SMALL_GROUP_MAX = 6
const val PRE_JOIN_MUTE_THRESHOLD = 8
@JvmField
val MAX_OUTGOING_GROUP_RING_DURATION = TimeUnit.MINUTES.toMillis(1)

View File

@@ -23,6 +23,7 @@ sealed interface CallEvent {
data class ShowGroupCallSafetyNumberChange(val identityRecords: List<IdentityRecord>) : CallEvent
data object SwitchToSpeaker : CallEvent
data object ShowSwipeToSpeakerHint : CallEvent
data object ShowLargeGroupAutoMuteToast : CallEvent
data class ShowRemoteMuteToast(private val muted: Recipient, private val mutedBy: Recipient) : CallEvent {
fun getDescription(context: Context): String {
return if (muted.isSelf && mutedBy.isSelf) {

View File

@@ -960,6 +960,10 @@ class WebRtcCallActivity : BaseActivity(), SafetyNumberChangeDialog.Callback, Re
is CallEvent.SwitchToSpeaker -> callScreen.switchToSpeakerView()
is CallEvent.ShowSwipeToSpeakerHint -> callScreen.showSpeakerViewHint()
is CallEvent.ShowRemoteMuteToast -> callScreen.showRemoteMuteToast(event.getDescription(this))
is CallEvent.ShowLargeGroupAutoMuteToast -> {
callScreen.onCallStateUpdate(CallControlsChange.MIC_OFF)
callScreen.showRemoteMuteToast(getString(R.string.WebRtcCallView__youve_been_muted_large_group))
}
is CallEvent.ShowVideoTooltip -> {
if (isInPipMode()) return

View File

@@ -101,6 +101,7 @@ class WebRtcCallViewModel : ViewModel() {
private var previousParticipantList = Collections.emptyList<CallParticipant>()
private var switchOnFirstScreenShare = true
private var showScreenShareTip = true
private var hasShownAutoMuteToast = false
var isCallStarting = false
private set
@@ -313,6 +314,7 @@ class WebRtcCallViewModel : ViewModel() {
}
}
val wasMicrophoneEnabled = internalMicrophoneEnabled.value
internalMicrophoneEnabled.value = localParticipant.isMicrophoneEnabled
isAudioDeviceChangePending.value = webRtcViewModel.isAudioDeviceChangePending
@@ -320,6 +322,16 @@ class WebRtcCallViewModel : ViewModel() {
remoteMutedBy.update { null }
}
if (!hasShownAutoMuteToast &&
wasMicrophoneEnabled &&
!localParticipant.isMicrophoneEnabled &&
webRtcViewModel.state == WebRtcViewModel.State.CALL_PRE_JOIN &&
webRtcViewModel.remoteDevicesCount.orElse(0L) >= CallParticipantsState.PRE_JOIN_MUTE_THRESHOLD
) {
hasShownAutoMuteToast = true
emitEvent(CallEvent.ShowLargeGroupAutoMuteToast)
}
val state: CallParticipantsState = participantsState.value!!
val wasScreenSharing: Boolean = state.focusedParticipant.isScreenSharing
val newState: CallParticipantsState = CallParticipantsState.update(state, webRtcViewModel, enableVideo)

View File

@@ -9,6 +9,7 @@ import org.signal.ringrtc.CallException;
import org.signal.ringrtc.GroupCall;
import org.signal.ringrtc.PeekInfo;
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
import org.thoughtcrime.securesms.components.webrtc.CallParticipantsState;
import org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper;
import org.thoughtcrime.securesms.events.CallParticipant;
import org.thoughtcrime.securesms.events.CallParticipantId;
@@ -149,7 +150,16 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
CallParticipant.DeviceOrdinal.PRIMARY));
}
return builder.build();
WebRtcServiceStateBuilder stateBuilder = builder.commit();
if (peekInfo.getDeviceCountExcludingPendingDevices() >= CallParticipantsState.PRE_JOIN_MUTE_THRESHOLD && currentState.getLocalDeviceState().isMicrophoneEnabled()) {
Log.i(tag, "Large call detected (" + peekInfo.getDeviceCountExcludingPendingDevices() + " participants), auto-muting microphone");
return stateBuilder.changeLocalDeviceState()
.isMicrophoneEnabled(false)
.build();
}
return stateBuilder.build();
}
@Override