Search in sources :

Example 1 with IceUpdateMessage

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

the class PushDecryptJob method handleCallIceUpdateMessage.

private void handleCallIceUpdateMessage(@NonNull SignalServiceEnvelope envelope, @NonNull List<IceUpdateMessage> messages) {
    Log.w(TAG, "handleCallIceUpdateMessage... " + messages.size());
    for (IceUpdateMessage message : messages) {
        Intent intent = new Intent(context, WebRtcCallService.class);
        intent.setAction(WebRtcCallService.ACTION_ICE_MESSAGE);
        intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
        intent.putExtra(WebRtcCallService.EXTRA_REMOTE_NUMBER, envelope.getSource());
        intent.putExtra(WebRtcCallService.EXTRA_ICE_SDP, message.getSdp());
        intent.putExtra(WebRtcCallService.EXTRA_ICE_SDP_MID, message.getSdpMid());
        intent.putExtra(WebRtcCallService.EXTRA_ICE_SDP_LINE_INDEX, message.getSdpMLineIndex());
        context.startService(intent);
    }
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) Intent(android.content.Intent)

Example 2 with IceUpdateMessage

use of org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage 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)

Example 3 with IceUpdateMessage

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

the class MessageContentProcessor method handleCallIceUpdateMessage.

private void handleCallIceUpdateMessage(@NonNull SignalServiceContent content, @NonNull List<IceUpdateMessage> messages, @NonNull Recipient senderRecipient) {
    log(String.valueOf(content), "handleCallIceUpdateMessage... " + messages.size());
    List<byte[]> iceCandidates = new ArrayList<>(messages.size());
    long callId = -1;
    for (IceUpdateMessage iceMessage : messages) {
        iceCandidates.add(iceMessage.getOpaque());
        callId = iceMessage.getId();
    }
    RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(callId));
    ApplicationDependencies.getSignalCallManager().receivedIceCandidates(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()), iceCandidates);
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) CallId(org.signal.ringrtc.CallId) ArrayList(java.util.ArrayList) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) WebRtcData(org.thoughtcrime.securesms.service.webrtc.WebRtcData)

Example 4 with IceUpdateMessage

use of org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage 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 5 with IceUpdateMessage

use of org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage in project Signal-Android by signalapp.

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)

Aggregations

IceUpdateMessage (org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage)13 AnswerMessage (org.whispersystems.signalservice.api.messages.calls.AnswerMessage)7 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)7 SignalServiceCallMessage (org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage)7 CallId (org.signal.ringrtc.CallId)4 BusyMessage (org.whispersystems.signalservice.api.messages.calls.BusyMessage)4 HangupMessage (org.whispersystems.signalservice.api.messages.calls.HangupMessage)4 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)3 OpaqueMessage (org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)3 Context (android.content.Context)2 Intent (android.content.Intent)2 ResultReceiver (android.os.ResultReceiver)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 Stream (com.annimon.stream.Stream)2 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2