Search in sources :

Example 31 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method onCallEvent.

@Override
public void onCallEvent(@Nullable Remote remote, @NonNull CallManager.CallEvent event) {
    if (callManager == null) {
        Log.w(TAG, "Unable to process call event, call manager is not initialized");
        return;
    }
    if (!(remote instanceof RemotePeer)) {
        return;
    }
    process((s, p) -> {
        RemotePeer remotePeer = (RemotePeer) remote;
        if (s.getCallInfoState().getPeer(remotePeer.hashCode()) == null) {
            Log.w(TAG, "remotePeer not found in map with key: " + remotePeer.hashCode() + "! Dropping.");
            try {
                callManager.drop(remotePeer.getCallId());
            } catch (CallException e) {
                return p.callFailure(s, "callManager.drop() failed: ", e);
            }
            return s;
        }
        Log.i(TAG, "onCallEvent(): call_id: " + remotePeer.getCallId() + ", state: " + remotePeer.getState() + ", event: " + event);
        switch(event) {
            case LOCAL_RINGING:
                return p.handleLocalRinging(s, remotePeer);
            case REMOTE_RINGING:
                return p.handleRemoteRinging(s, remotePeer);
            case RECONNECTING:
                Log.i(TAG, "Reconnecting: NOT IMPLEMENTED");
                break;
            case RECONNECTED:
                Log.i(TAG, "Reconnected: NOT IMPLEMENTED");
                break;
            case LOCAL_CONNECTED:
            case REMOTE_CONNECTED:
                return p.handleCallConnected(s, remotePeer);
            case REMOTE_VIDEO_ENABLE:
                return p.handleRemoteVideoEnable(s, true);
            case REMOTE_VIDEO_DISABLE:
                return p.handleRemoteVideoEnable(s, false);
            case REMOTE_SHARING_SCREEN_ENABLE:
                return p.handleScreenSharingEnable(s, true);
            case REMOTE_SHARING_SCREEN_DISABLE:
                return p.handleScreenSharingEnable(s, false);
            case ENDED_REMOTE_HANGUP:
            case ENDED_REMOTE_HANGUP_NEED_PERMISSION:
            case ENDED_REMOTE_HANGUP_ACCEPTED:
            case ENDED_REMOTE_HANGUP_BUSY:
            case ENDED_REMOTE_HANGUP_DECLINED:
            case ENDED_REMOTE_BUSY:
            case ENDED_REMOTE_GLARE:
                return p.handleEndedRemote(s, event, remotePeer);
            case ENDED_TIMEOUT:
            case ENDED_INTERNAL_FAILURE:
            case ENDED_SIGNALING_FAILURE:
            case ENDED_CONNECTION_FAILURE:
                return p.handleEnded(s, event, remotePeer);
            case RECEIVED_OFFER_EXPIRED:
                return p.handleReceivedOfferExpired(s, remotePeer);
            case RECEIVED_OFFER_WHILE_ACTIVE:
            case RECEIVED_OFFER_WITH_GLARE:
                return p.handleReceivedOfferWhileActive(s, remotePeer);
            case ENDED_LOCAL_HANGUP:
            case ENDED_APP_DROPPED_CALL:
                Log.i(TAG, "Ignoring event: " + event);
                break;
            default:
                throw new AssertionError("Unexpected event: " + event.toString());
        }
        return s;
    });
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 32 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method onSendOffer.

@Override
public void onSendOffer(@NonNull CallId callId, @Nullable Remote remote, @NonNull Integer remoteDevice, @NonNull Boolean broadcast, @NonNull byte[] opaque, @NonNull CallManager.CallMediaType callMediaType) {
    if (!(remote instanceof RemotePeer)) {
        return;
    }
    RemotePeer remotePeer = (RemotePeer) remote;
    Log.i(TAG, "onSendOffer: id: " + remotePeer.getCallId().format(remoteDevice) + " type: " + callMediaType.name());
    OfferMessage.Type offerType = WebRtcUtil.getOfferTypeFromCallMediaType(callMediaType);
    WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
    WebRtcData.OfferMetadata offerMetadata = new WebRtcData.OfferMetadata(opaque, null, offerType);
    process((s, p) -> p.handleSendOffer(s, callMetadata, offerMetadata, broadcast));
}
Also used : OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 33 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method onSendIceCandidates.

@Override
public void onSendIceCandidates(@NonNull CallId callId, @Nullable Remote remote, @NonNull Integer remoteDevice, @NonNull Boolean broadcast, @NonNull List<byte[]> iceCandidates) {
    if (!(remote instanceof RemotePeer)) {
        return;
    }
    RemotePeer remotePeer = (RemotePeer) remote;
    Log.i(TAG, "onSendIceCandidates: id: " + remotePeer.getCallId().format(remoteDevice));
    WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
    process((s, p) -> p.handleSendIceCandidates(s, callMetadata, broadcast, iceCandidates));
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 34 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method onSendAnswer.

@Override
public void onSendAnswer(@NonNull CallId callId, @Nullable Remote remote, @NonNull Integer remoteDevice, @NonNull Boolean broadcast, @NonNull byte[] opaque) {
    if (!(remote instanceof RemotePeer)) {
        return;
    }
    RemotePeer remotePeer = (RemotePeer) remote;
    Log.i(TAG, "onSendAnswer: id: " + remotePeer.getCallId().format(remoteDevice));
    WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
    WebRtcData.AnswerMetadata answerMetadata = new WebRtcData.AnswerMetadata(opaque, null);
    process((s, p) -> p.handleSendAnswer(s, callMetadata, answerMetadata, broadcast));
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 35 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method onSendBusy.

@Override
public void onSendBusy(@NonNull CallId callId, @Nullable Remote remote, @NonNull Integer remoteDevice, @NonNull Boolean broadcast) {
    if (!(remote instanceof RemotePeer)) {
        return;
    }
    RemotePeer remotePeer = (RemotePeer) remote;
    Log.i(TAG, "onSendBusy: id: " + remotePeer.getCallId().format(remoteDevice));
    WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
    process((s, p) -> p.handleSendBusy(s, callMetadata, broadcast));
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Aggregations

RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)70 NonNull (androidx.annotation.NonNull)44 CallException (org.signal.ringrtc.CallException)32 CallId (org.signal.ringrtc.CallId)14 Recipient (org.thoughtcrime.securesms.recipients.Recipient)14 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)10 GroupId (org.thoughtcrime.securesms.groups.GroupId)10 WebRtcData (org.thoughtcrime.securesms.service.webrtc.WebRtcData)10 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)10 Context (android.content.Context)8 Build (android.os.Build)8 Nullable (androidx.annotation.Nullable)8 Stream (com.annimon.stream.Stream)8 IOException (java.io.IOException)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8 LinkedList (java.util.LinkedList)8 List (java.util.List)8 UUID (java.util.UUID)8 Log (org.signal.core.util.logging.Log)8