Search in sources :

Example 1 with CallMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage in project libsignal-service-java by signalapp.

the class SignalServiceMessageSender method createCallContent.

private byte[] createCallContent(SignalServiceCallMessage callMessage) {
    Content.Builder container = Content.newBuilder();
    CallMessage.Builder builder = CallMessage.newBuilder();
    if (callMessage.getOfferMessage().isPresent()) {
        OfferMessage offer = callMessage.getOfferMessage().get();
        builder.setOffer(CallMessage.Offer.newBuilder().setId(offer.getId()).setDescription(offer.getDescription()));
    } else if (callMessage.getAnswerMessage().isPresent()) {
        AnswerMessage answer = callMessage.getAnswerMessage().get();
        builder.setAnswer(CallMessage.Answer.newBuilder().setId(answer.getId()).setDescription(answer.getDescription()));
    } else if (callMessage.getIceUpdateMessages().isPresent()) {
        List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
        for (IceUpdateMessage update : updates) {
            builder.addIceUpdate(CallMessage.IceUpdate.newBuilder().setId(update.getId()).setSdp(update.getSdp()).setSdpMid(update.getSdpMid()).setSdpMLineIndex(update.getSdpMLineIndex()));
        }
    } else if (callMessage.getHangupMessage().isPresent()) {
        builder.setHangup(CallMessage.Hangup.newBuilder().setId(callMessage.getHangupMessage().get().getId()));
    } else if (callMessage.getBusyMessage().isPresent()) {
        builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId()));
    }
    container.setCallMessage(builder);
    return container.build().toByteArray();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) CallMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage)

Example 2 with CallMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method createCallContent.

private Content createCallContent(SignalServiceCallMessage callMessage) {
    Content.Builder container = Content.newBuilder();
    CallMessage.Builder builder = CallMessage.newBuilder();
    if (callMessage.getOfferMessage().isPresent()) {
        OfferMessage offer = callMessage.getOfferMessage().get();
        CallMessage.Offer.Builder offerBuilder = CallMessage.Offer.newBuilder().setId(offer.getId()).setType(offer.getType().getProtoType());
        if (offer.getOpaque() != null) {
            offerBuilder.setOpaque(ByteString.copyFrom(offer.getOpaque()));
        }
        if (offer.getSdp() != null) {
            offerBuilder.setSdp(offer.getSdp());
        }
        builder.setOffer(offerBuilder);
    } else if (callMessage.getAnswerMessage().isPresent()) {
        AnswerMessage answer = callMessage.getAnswerMessage().get();
        CallMessage.Answer.Builder answerBuilder = CallMessage.Answer.newBuilder().setId(answer.getId());
        if (answer.getOpaque() != null) {
            answerBuilder.setOpaque(ByteString.copyFrom(answer.getOpaque()));
        }
        if (answer.getSdp() != null) {
            answerBuilder.setSdp(answer.getSdp());
        }
        builder.setAnswer(answerBuilder);
    } else if (callMessage.getIceUpdateMessages().isPresent()) {
        List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
        for (IceUpdateMessage update : updates) {
            CallMessage.IceUpdate.Builder iceBuilder = CallMessage.IceUpdate.newBuilder().setId(update.getId()).setMid("audio").setLine(0);
            if (update.getOpaque() != null) {
                iceBuilder.setOpaque(ByteString.copyFrom(update.getOpaque()));
            }
            if (update.getSdp() != null) {
                iceBuilder.setSdp(update.getSdp());
            }
            builder.addIceUpdate(iceBuilder);
        }
    } else if (callMessage.getHangupMessage().isPresent()) {
        CallMessage.Hangup.Type protoType = callMessage.getHangupMessage().get().getType().getProtoType();
        CallMessage.Hangup.Builder builderForHangup = CallMessage.Hangup.newBuilder().setType(protoType).setId(callMessage.getHangupMessage().get().getId());
        if (protoType != CallMessage.Hangup.Type.HANGUP_NORMAL) {
            builderForHangup.setDeviceId(callMessage.getHangupMessage().get().getDeviceId());
        }
        if (callMessage.getHangupMessage().get().isLegacy()) {
            builder.setLegacyHangup(builderForHangup);
        } else {
            builder.setHangup(builderForHangup);
        }
    } else if (callMessage.getBusyMessage().isPresent()) {
        builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId()));
    } else if (callMessage.getOpaqueMessage().isPresent()) {
        OpaqueMessage opaqueMessage = callMessage.getOpaqueMessage().get();
        ByteString data = ByteString.copyFrom(opaqueMessage.getOpaque());
        CallMessage.Opaque.Urgency urgency = opaqueMessage.getUrgency().toProto();
        builder.setOpaque(CallMessage.Opaque.newBuilder().setData(data).setUrgency(urgency));
    }
    builder.setMultiRing(callMessage.isMultiRing());
    if (callMessage.getDestinationDeviceId().isPresent()) {
        builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get());
    }
    container.setCallMessage(builder);
    return container.build();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) CallMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage) ByteString(com.google.protobuf.ByteString) SignalGroupSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder) GroupSessionBuilder(org.whispersystems.libsignal.groups.GroupSessionBuilder) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Example 3 with CallMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage in project Signal-Android by signalapp.

the class SignalServiceMessageSender method createCallContent.

private Content createCallContent(SignalServiceCallMessage callMessage) {
    Content.Builder container = Content.newBuilder();
    CallMessage.Builder builder = CallMessage.newBuilder();
    if (callMessage.getOfferMessage().isPresent()) {
        OfferMessage offer = callMessage.getOfferMessage().get();
        CallMessage.Offer.Builder offerBuilder = CallMessage.Offer.newBuilder().setId(offer.getId()).setType(offer.getType().getProtoType());
        if (offer.getOpaque() != null) {
            offerBuilder.setOpaque(ByteString.copyFrom(offer.getOpaque()));
        }
        if (offer.getSdp() != null) {
            offerBuilder.setSdp(offer.getSdp());
        }
        builder.setOffer(offerBuilder);
    } else if (callMessage.getAnswerMessage().isPresent()) {
        AnswerMessage answer = callMessage.getAnswerMessage().get();
        CallMessage.Answer.Builder answerBuilder = CallMessage.Answer.newBuilder().setId(answer.getId());
        if (answer.getOpaque() != null) {
            answerBuilder.setOpaque(ByteString.copyFrom(answer.getOpaque()));
        }
        if (answer.getSdp() != null) {
            answerBuilder.setSdp(answer.getSdp());
        }
        builder.setAnswer(answerBuilder);
    } else if (callMessage.getIceUpdateMessages().isPresent()) {
        List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
        for (IceUpdateMessage update : updates) {
            CallMessage.IceUpdate.Builder iceBuilder = CallMessage.IceUpdate.newBuilder().setId(update.getId()).setMid("audio").setLine(0);
            if (update.getOpaque() != null) {
                iceBuilder.setOpaque(ByteString.copyFrom(update.getOpaque()));
            }
            if (update.getSdp() != null) {
                iceBuilder.setSdp(update.getSdp());
            }
            builder.addIceUpdate(iceBuilder);
        }
    } else if (callMessage.getHangupMessage().isPresent()) {
        CallMessage.Hangup.Type protoType = callMessage.getHangupMessage().get().getType().getProtoType();
        CallMessage.Hangup.Builder builderForHangup = CallMessage.Hangup.newBuilder().setType(protoType).setId(callMessage.getHangupMessage().get().getId());
        if (protoType != CallMessage.Hangup.Type.HANGUP_NORMAL) {
            builderForHangup.setDeviceId(callMessage.getHangupMessage().get().getDeviceId());
        }
        if (callMessage.getHangupMessage().get().isLegacy()) {
            builder.setLegacyHangup(builderForHangup);
        } else {
            builder.setHangup(builderForHangup);
        }
    } else if (callMessage.getBusyMessage().isPresent()) {
        builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId()));
    } else if (callMessage.getOpaqueMessage().isPresent()) {
        OpaqueMessage opaqueMessage = callMessage.getOpaqueMessage().get();
        ByteString data = ByteString.copyFrom(opaqueMessage.getOpaque());
        CallMessage.Opaque.Urgency urgency = opaqueMessage.getUrgency().toProto();
        builder.setOpaque(CallMessage.Opaque.newBuilder().setData(data).setUrgency(urgency));
    }
    builder.setMultiRing(callMessage.isMultiRing());
    if (callMessage.getDestinationDeviceId().isPresent()) {
        builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get());
    }
    container.setCallMessage(builder);
    return container.build();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) CallMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage) ByteString(com.google.protobuf.ByteString) SignalGroupSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder) GroupSessionBuilder(org.whispersystems.libsignal.groups.GroupSessionBuilder) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Aggregations

AnswerMessage (org.whispersystems.signalservice.api.messages.calls.AnswerMessage)3 IceUpdateMessage (org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage)3 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)3 SignalServiceCallMessage (org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage)3 CallMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage)3 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)3 ByteString (com.google.protobuf.ByteString)2 SessionBuilder (org.whispersystems.libsignal.SessionBuilder)2 GroupSessionBuilder (org.whispersystems.libsignal.groups.GroupSessionBuilder)2 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)2 EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)2 SignalGroupSessionBuilder (org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder)2 SignalSessionBuilder (org.whispersystems.signalservice.api.crypto.SignalSessionBuilder)2 OpaqueMessage (org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)2