Search in sources :

Example 11 with WebRtcServiceState

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

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 12 with WebRtcServiceState

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

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