Search in sources :

Example 1 with HangupMessage

use of org.whispersystems.signalservice.api.messages.calls.HangupMessage in project Signal-Android by WhisperSystems.

the class WebRtcActionProcessor method handleSendHangup.

@NonNull
protected final WebRtcServiceState handleSendHangup(@NonNull WebRtcServiceState currentState, @NonNull CallMetadata callMetadata, @NonNull HangupMetadata hangupMetadata, boolean broadcast) {
    Log.i(tag, "handleSendHangup(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
    HangupMessage hangupMessage = new HangupMessage(callMetadata.getCallId().longValue(), hangupMetadata.getType(), hangupMetadata.getDeviceId(), hangupMetadata.isLegacy());
    Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
    SignalServiceCallMessage callMessage = SignalServiceCallMessage.forHangup(hangupMessage, true, destinationDeviceId);
    webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
    return currentState;
}
Also used : HangupMessage(org.whispersystems.signalservice.api.messages.calls.HangupMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) NonNull(androidx.annotation.NonNull)

Example 2 with HangupMessage

use of org.whispersystems.signalservice.api.messages.calls.HangupMessage in project Signal-Android by WhisperSystems.

the class SignalServiceContent method createCallMessage.

private static SignalServiceCallMessage createCallMessage(SignalServiceProtos.CallMessage content) {
    boolean isMultiRing = content.getMultiRing();
    Integer destinationDeviceId = content.hasDestinationDeviceId() ? content.getDestinationDeviceId() : null;
    if (content.hasOffer()) {
        SignalServiceProtos.CallMessage.Offer offerContent = content.getOffer();
        return SignalServiceCallMessage.forOffer(new OfferMessage(offerContent.getId(), offerContent.hasSdp() ? offerContent.getSdp() : null, OfferMessage.Type.fromProto(offerContent.getType()), offerContent.hasOpaque() ? offerContent.getOpaque().toByteArray() : null), isMultiRing, destinationDeviceId);
    } else if (content.hasAnswer()) {
        SignalServiceProtos.CallMessage.Answer answerContent = content.getAnswer();
        return SignalServiceCallMessage.forAnswer(new AnswerMessage(answerContent.getId(), answerContent.hasSdp() ? answerContent.getSdp() : null, answerContent.hasOpaque() ? answerContent.getOpaque().toByteArray() : null), isMultiRing, destinationDeviceId);
    } else if (content.getIceUpdateCount() > 0) {
        List<IceUpdateMessage> iceUpdates = new LinkedList<>();
        for (SignalServiceProtos.CallMessage.IceUpdate iceUpdate : content.getIceUpdateList()) {
            iceUpdates.add(new IceUpdateMessage(iceUpdate.getId(), iceUpdate.hasOpaque() ? iceUpdate.getOpaque().toByteArray() : null, iceUpdate.hasSdp() ? iceUpdate.getSdp() : null));
        }
        return SignalServiceCallMessage.forIceUpdates(iceUpdates, isMultiRing, destinationDeviceId);
    } else if (content.hasLegacyHangup()) {
        SignalServiceProtos.CallMessage.Hangup hangup = content.getLegacyHangup();
        return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId(), HangupMessage.Type.fromProto(hangup.getType()), hangup.getDeviceId(), content.hasLegacyHangup()), isMultiRing, destinationDeviceId);
    } else if (content.hasHangup()) {
        SignalServiceProtos.CallMessage.Hangup hangup = content.getHangup();
        return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId(), HangupMessage.Type.fromProto(hangup.getType()), hangup.getDeviceId(), content.hasLegacyHangup()), isMultiRing, destinationDeviceId);
    } else if (content.hasBusy()) {
        SignalServiceProtos.CallMessage.Busy busy = content.getBusy();
        return SignalServiceCallMessage.forBusy(new BusyMessage(busy.getId()), isMultiRing, destinationDeviceId);
    } else if (content.hasOpaque()) {
        SignalServiceProtos.CallMessage.Opaque opaque = content.getOpaque();
        return SignalServiceCallMessage.forOpaque(new OpaqueMessage(opaque.getData().toByteArray(), null), isMultiRing, destinationDeviceId);
    }
    return SignalServiceCallMessage.empty();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) LinkedList(java.util.LinkedList) SignalServiceProtos(org.whispersystems.signalservice.internal.push.SignalServiceProtos) HangupMessage(org.whispersystems.signalservice.api.messages.calls.HangupMessage) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) BusyMessage(org.whispersystems.signalservice.api.messages.calls.BusyMessage) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Aggregations

HangupMessage (org.whispersystems.signalservice.api.messages.calls.HangupMessage)2 SignalServiceCallMessage (org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage)2 NonNull (androidx.annotation.NonNull)1 LinkedList (java.util.LinkedList)1 AnswerMessage (org.whispersystems.signalservice.api.messages.calls.AnswerMessage)1 BusyMessage (org.whispersystems.signalservice.api.messages.calls.BusyMessage)1 IceUpdateMessage (org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage)1 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)1 OpaqueMessage (org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)1 SignalServiceProtos (org.whispersystems.signalservice.internal.push.SignalServiceProtos)1