Search in sources :

Example 6 with WebRtcServiceState

use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState in project Signal-Android by WhisperSystems.

the class GroupPreJoinActionProcessor method handleCancelPreJoinCall.

@Override
@NonNull
protected WebRtcServiceState handleCancelPreJoinCall(@NonNull WebRtcServiceState currentState) {
    Log.i(TAG, "handleCancelPreJoinCall():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    WebRtcVideoUtil.deinitializeVideo(currentState);
    EglBaseWrapper.releaseEglBase(RemotePeer.GROUP_CALL_ID.longValue());
    return new WebRtcServiceState(new IdleActionProcessor(webRtcInteractor));
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 7 with WebRtcServiceState

use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState in project Signal-Android by WhisperSystems.

the class SignalCallManager method process.

private void process(@NonNull ProcessAction action) {
    Throwable t = new Throwable();
    String caller = t.getStackTrace().length > 1 ? t.getStackTrace()[1].getMethodName() : "unknown";
    if (callManager == null) {
        Log.w(TAG, "Unable to process action, call manager is not initialized");
        return;
    }
    serviceExecutor.execute(() -> {
        if (needsToSetSelfUuid) {
            try {
                callManager.setSelfUuid(Recipient.self().requireServiceId().uuid());
                needsToSetSelfUuid = false;
            } catch (CallException e) {
                Log.w(TAG, "Unable to set self UUID on CallManager", e);
            }
        }
        Log.v(TAG, "Processing action: " + caller + ", handler: " + serviceState.getActionProcessor().getTag());
        WebRtcServiceState previous = serviceState;
        serviceState = action.process(previous, previous.getActionProcessor());
        if (previous != serviceState) {
            if (serviceState.getCallInfoState().getCallState() != WebRtcViewModel.State.IDLE) {
                postStateUpdate(serviceState);
            }
        }
    });
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)

Example 8 with WebRtcServiceState

use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState in project Signal-Android by WhisperSystems.

the class GroupActionProcessor method handleGroupRequestUpdateMembers.

@Override
@NonNull
protected WebRtcServiceState handleGroupRequestUpdateMembers(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupRequestUpdateMembers():");
    Recipient group = currentState.getCallInfoState().getCallRecipient();
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    List<GroupCall.GroupMemberInfo> members = Stream.of(GroupManager.getUuidCipherTexts(context, group.requireGroupId().requireV2())).map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).toList();
    try {
        groupCall.setGroupMembers(new ArrayList<>(members));
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable set group members", e);
    }
    return currentState;
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) CallException(org.signal.ringrtc.CallException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) Map(java.util.Map) Recipient(org.thoughtcrime.securesms.recipients.Recipient) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ACI(org.whispersystems.signalservice.api.push.ACI) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) Collection(java.util.Collection) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) Set(java.util.Set) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) VideoTrack(org.webrtc.VideoTrack) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) LongSparseArray(android.util.LongSparseArray) Collections(java.util.Collections) CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NonNull(androidx.annotation.NonNull)

Example 9 with WebRtcServiceState

use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState in project Signal-Android by WhisperSystems.

the class WebRtcActionProcessor method handleSendIceCandidates.

// endregion Active call
// region Call setup
@NonNull
protected final WebRtcServiceState handleSendIceCandidates(@NonNull WebRtcServiceState currentState, @NonNull CallMetadata callMetadata, boolean broadcast, @NonNull List<byte[]> iceCandidates) {
    Log.i(tag, "handleSendIceCandidates(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
    List<IceUpdateMessage> iceUpdateMessages = Stream.of(iceCandidates).map(c -> new IceUpdateMessage(callMetadata.getCallId().longValue(), c, null)).toList();
    Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
    SignalServiceCallMessage callMessage = SignalServiceCallMessage.forIceUpdates(iceUpdateMessages, true, destinationDeviceId);
    webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
    return currentState;
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) RingUpdate(org.signal.ringrtc.CallManager.RingUpdate) NonNull(androidx.annotation.NonNull) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) CallException(org.signal.ringrtc.CallException) CallManager(org.signal.ringrtc.CallManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) NotificationProfiles(org.thoughtcrime.securesms.notifications.profiles.NotificationProfiles) NetworkUtil(org.thoughtcrime.securesms.util.NetworkUtil) Recipient(org.thoughtcrime.securesms.recipients.Recipient) BusyMessage(org.whispersystems.signalservice.api.messages.calls.BusyMessage) IdentityKeyUtil(org.thoughtcrime.securesms.crypto.IdentityKeyUtil) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) NotificationProfile(org.thoughtcrime.securesms.notifications.profiles.NotificationProfile) IdentityKey(org.whispersystems.libsignal.IdentityKey) GroupCall(org.signal.ringrtc.GroupCall) Objects(java.util.Objects) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) CallState(org.thoughtcrime.securesms.ringrtc.CallState) OfferMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.OfferMetadata) GroupId(org.thoughtcrime.securesms.groups.GroupId) CallId(org.signal.ringrtc.CallId) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) CallMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.CallMetadata) Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) ReceivedOfferMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.ReceivedOfferMetadata) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) EglBaseWrapper(org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper) GroupCallSafetyNumberChangeNotificationUtil(org.thoughtcrime.securesms.components.webrtc.GroupCallSafetyNumberChangeNotificationUtil) LockManager(org.thoughtcrime.securesms.webrtc.locks.LockManager) CameraState(org.thoughtcrime.securesms.ringrtc.CameraState) HangupMessage(org.whispersystems.signalservice.api.messages.calls.HangupMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Camera(org.thoughtcrime.securesms.ringrtc.Camera) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) PeerConnection(org.webrtc.PeerConnection) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) Orientation(org.thoughtcrime.securesms.components.sensors.Orientation) TelephonyUtil(org.thoughtcrime.securesms.util.TelephonyUtil) Optional(org.whispersystems.libsignal.util.guava.Optional) AnswerMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.AnswerMetadata) IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) HangupMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.HangupMetadata) ResultReceiver(android.os.ResultReceiver) ReceivedAnswerMetadata(org.thoughtcrime.securesms.service.webrtc.WebRtcData.ReceivedAnswerMetadata) IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) NonNull(androidx.annotation.NonNull)

Example 10 with WebRtcServiceState

use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState in project Signal-Android by WhisperSystems.

the class GroupConnectedActionProcessor method handleLocalHangup.

@Override
@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
    Log.i(TAG, "handleLocalHangup():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
    webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId);
    List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().uuid()).toList();
    webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, false);
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) UUID(java.util.UUID) CallException(org.signal.ringrtc.CallException) ArrayList(java.util.ArrayList) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) PeekInfo(org.signal.ringrtc.PeekInfo) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ResultReceiver(android.os.ResultReceiver) Camera(org.thoughtcrime.securesms.ringrtc.Camera) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) UUID(java.util.UUID) NonNull(androidx.annotation.NonNull)

Aggregations

CallException (org.signal.ringrtc.CallException)12 WebRtcServiceState (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)12 NonNull (androidx.annotation.NonNull)10 GroupCall (org.signal.ringrtc.GroupCall)10 Stream (com.annimon.stream.Stream)8 List (java.util.List)8 Log (org.signal.core.util.logging.Log)8 WebRtcViewModel (org.thoughtcrime.securesms.events.WebRtcViewModel)8 Recipient (org.thoughtcrime.securesms.recipients.Recipient)8 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)8 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)6 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)6 WebRtcServiceStateBuilder (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder)6 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)6 ResultReceiver (android.os.ResultReceiver)4 Nullable (androidx.annotation.Nullable)4 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 Set (java.util.Set)4 UUID (java.util.UUID)4