mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Implement remote mute receive; Update to RingRTC v2.52.0
Co-authored-by: Alex Hart <alex@signal.org> Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
committed by
Cody Henthorne
parent
ed9a945f05
commit
3d7162cdd3
@@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -121,6 +122,65 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleRemoteMuteRequest(@NonNull WebRtcServiceState currentState, long sourceDemuxId) {
|
||||
Log.i(tag, "handleRemoteMuteRequest():");
|
||||
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
Map<CallParticipantId, CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipantsMap();
|
||||
|
||||
if (!currentState.getLocalDeviceState().isMicrophoneEnabled()) {
|
||||
// Nothing to do.
|
||||
return currentState;
|
||||
}
|
||||
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == sourceDemuxId) {
|
||||
try {
|
||||
groupCall.setOutgoingAudioMutedRemotely(sourceDemuxId);
|
||||
} catch (CallException e) {
|
||||
return groupCallFailure(currentState, "Unable to set attribution of remote mute", e);
|
||||
}
|
||||
return currentState.builder().changeLocalDeviceState().setRemoteMutedBy(entry.getValue()).build();
|
||||
}
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleObservedRemoteMute(@NonNull WebRtcServiceState currentState, long sourceDemuxId, long targetDemuxId) {
|
||||
Log.i(tag, "handleObservedRemoteMute not processed");
|
||||
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
Map<CallParticipantId, CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipantsMap();
|
||||
|
||||
Long selfDemuxId = groupCall.getLocalDeviceState().getDemuxId();
|
||||
Recipient source = null;
|
||||
if (selfDemuxId != null && sourceDemuxId == selfDemuxId) {
|
||||
source = Recipient.self();
|
||||
} else {
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == sourceDemuxId) {
|
||||
source = entry.getValue().getRecipient();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (source == null) {
|
||||
Log.w(tag, "handleObservedRemoteMute: source not found");
|
||||
return currentState;
|
||||
}
|
||||
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == targetDemuxId) {
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState().putParticipant(entry.getKey(), entry.getValue().withRemotelyMutedBy(source));
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcEphemeralState handleGroupAudioLevelsChanged(@NonNull WebRtcServiceState currentState, @NonNull WebRtcEphemeralState ephemeralState) {
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
|
||||
@@ -971,6 +971,17 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
process((s, p) -> p.handleGroupCallEnded(s, groupCall.hashCode(), groupCallEndReason));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteMuteRequest(@NonNull GroupCall groupCall, long sourceDemuxId) {
|
||||
process((s, p) -> p.handleRemoteMuteRequest(s, sourceDemuxId));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onObservedRemoteMute(@NonNull GroupCall groupCall, long sourceDemuxId, long targetDemuxId) {
|
||||
process((s, p) -> p.handleObservedRemoteMute(s, sourceDemuxId, targetDemuxId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakingNotification(@NonNull GroupCall groupCall, @NonNull GroupCall.SpeechEvent speechEvent) {
|
||||
process((s, p) -> p.handleGroupCallSpeechEvent(s, speechEvent));
|
||||
|
||||
@@ -786,6 +786,16 @@ public abstract class WebRtcActionProcessor {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleRemoteMuteRequest(@NonNull WebRtcServiceState currentState, long sourceDemuxId) {
|
||||
Log.i(tag, "handleRemoteMuteRequest not processed");
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleObservedRemoteMute(@NonNull WebRtcServiceState currentState, long sourceDemuxId, long targetDemuxId) {
|
||||
Log.i(tag, "handleObservedRemoteMute not processed");
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleGroupCallSpeechEvent(@NonNull WebRtcServiceState currentState, @NonNull GroupCall.SpeechEvent speechEvent) {
|
||||
Log.i(tag, "handleGroupCallSpeechEvent not processed");
|
||||
return currentState;
|
||||
|
||||
@@ -19,7 +19,8 @@ data class LocalDeviceState(
|
||||
var availableDevices: Set<SignalAudioManager.AudioDevice> = emptySet(),
|
||||
var bluetoothPermissionDenied: Boolean = false,
|
||||
var networkConnectionType: PeerConnection.AdapterType = PeerConnection.AdapterType.UNKNOWN,
|
||||
var handRaisedTimestamp: Long = CallParticipant.HAND_LOWERED
|
||||
var handRaisedTimestamp: Long = CallParticipant.HAND_LOWERED,
|
||||
var remoteMutedBy: CallParticipant? = null
|
||||
) {
|
||||
|
||||
fun duplicate(): LocalDeviceState {
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
import org.signal.ringrtc.CallId;
|
||||
import org.signal.ringrtc.GroupCall;
|
||||
import org.thoughtcrime.securesms.components.sensors.Orientation;
|
||||
@@ -101,6 +102,10 @@ public class WebRtcServiceStateBuilder {
|
||||
|
||||
public @NonNull LocalDeviceStateBuilder isMicrophoneEnabled(boolean enabled) {
|
||||
toBuild.setMicrophoneEnabled(enabled);
|
||||
if (enabled) {
|
||||
// Clear any remote mute attribution.
|
||||
toBuild.setRemoteMutedBy(null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -143,6 +148,12 @@ public class WebRtcServiceStateBuilder {
|
||||
toBuild.setHandRaisedTimestamp(handRaisedTimestamp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull LocalDeviceStateBuilder setRemoteMutedBy(@NonNull CallParticipant participant) {
|
||||
toBuild.setRemoteMutedBy(participant);
|
||||
toBuild.setMicrophoneEnabled(false);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class CallSetupStateBuilder {
|
||||
|
||||
Reference in New Issue
Block a user