mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add initial support for Group Calling.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package org.thoughtcrime.securesms.events;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.ringrtc.GroupCall;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Allow system to identify a call participant by their device demux id and their
|
||||
* recipient id.
|
||||
*/
|
||||
public final class CallParticipantId {
|
||||
|
||||
private static final long DEFAULT_ID = -1;
|
||||
|
||||
private final long demuxId;
|
||||
private final RecipientId recipientId;
|
||||
|
||||
public CallParticipantId(@NonNull Recipient recipient) {
|
||||
this(DEFAULT_ID, recipient.getId());
|
||||
}
|
||||
|
||||
public CallParticipantId(long demuxId, @NonNull RecipientId recipientId) {
|
||||
this.demuxId = demuxId;
|
||||
this.recipientId = recipientId;
|
||||
}
|
||||
|
||||
public long getDemuxId() {
|
||||
return demuxId;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getRecipientId() {
|
||||
return recipientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final CallParticipantId that = (CallParticipantId) o;
|
||||
return demuxId == that.demuxId &&
|
||||
recipientId.equals(that.recipientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(demuxId, recipientId);
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,45 @@ public class WebRtcViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
private final @NonNull State state;
|
||||
private final @NonNull Recipient recipient;
|
||||
public enum GroupCallState {
|
||||
IDLE,
|
||||
DISCONNECTED,
|
||||
CONNECTING,
|
||||
RECONNECTING,
|
||||
CONNECTED,
|
||||
CONNECTED_AND_JOINING,
|
||||
CONNECTED_AND_JOINED;
|
||||
|
||||
public boolean isNotIdle() {
|
||||
return this != IDLE;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
switch (this) {
|
||||
case CONNECTED:
|
||||
case CONNECTED_AND_JOINING:
|
||||
case CONNECTED_AND_JOINED:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNotIdleOrConnected() {
|
||||
switch (this) {
|
||||
case DISCONNECTED:
|
||||
case CONNECTING:
|
||||
case RECONNECTING:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final @NonNull State state;
|
||||
private final @NonNull GroupCallState groupState;
|
||||
private final @NonNull Recipient recipient;
|
||||
|
||||
private final boolean isBluetoothAvailable;
|
||||
private final boolean isRemoteVideoOffer;
|
||||
@@ -56,6 +93,7 @@ public class WebRtcViewModel {
|
||||
private final List<CallParticipant> remoteParticipants;
|
||||
|
||||
public WebRtcViewModel(@NonNull State state,
|
||||
@NonNull GroupCallState groupState,
|
||||
@NonNull Recipient recipient,
|
||||
@NonNull CameraState localCameraState,
|
||||
@Nullable BroadcastVideoSink localSink,
|
||||
@@ -66,6 +104,7 @@ public class WebRtcViewModel {
|
||||
@NonNull List<CallParticipant> remoteParticipants)
|
||||
{
|
||||
this.state = state;
|
||||
this.groupState = groupState;
|
||||
this.recipient = recipient;
|
||||
this.isBluetoothAvailable = isBluetoothAvailable;
|
||||
this.isRemoteVideoOffer = isRemoteVideoOffer;
|
||||
@@ -79,12 +118,16 @@ public class WebRtcViewModel {
|
||||
return state;
|
||||
}
|
||||
|
||||
public @NonNull GroupCallState getGroupState() {
|
||||
return groupState;
|
||||
}
|
||||
|
||||
public @NonNull Recipient getRecipient() {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
public boolean isRemoteVideoEnabled() {
|
||||
return Stream.of(remoteParticipants).anyMatch(CallParticipant::isVideoEnabled);
|
||||
return Stream.of(remoteParticipants).anyMatch(CallParticipant::isVideoEnabled) || (groupState.isNotIdle() && remoteParticipants.size() > 1);
|
||||
}
|
||||
|
||||
public boolean isBluetoothAvailable() {
|
||||
|
||||
Reference in New Issue
Block a user