use of org.whispersystems.signalservice.api.messages.calls.OfferMessage in project Signal-Android by WhisperSystems.
the class MessageContentProcessor method handleCallOfferMessage.
private void handleCallOfferMessage(@NonNull SignalServiceContent content, @NonNull OfferMessage message, @NonNull Optional<Long> smsMessageId, @NonNull Recipient senderRecipient) {
log(String.valueOf(content.getTimestamp()), "handleCallOfferMessage...");
if (smsMessageId.isPresent()) {
MessageDatabase database = SignalDatabase.sms();
database.markAsMissedCall(smsMessageId.get(), message.getType() == OfferMessage.Type.VIDEO_CALL);
} else {
RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(message.getId()));
byte[] remoteIdentityKey = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(senderRecipient.getId()).transform(record -> record.getIdentityKey().serialize()).orNull();
ApplicationDependencies.getSignalCallManager().receivedOffer(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()), new WebRtcData.OfferMetadata(message.getOpaque(), message.getSdp(), message.getType()), new WebRtcData.ReceivedOfferMetadata(remoteIdentityKey, content.getServerReceivedTimestamp(), content.getServerDeliveredTimestamp(), content.getCallMessage().get().isMultiRing()));
}
}
use of org.whispersystems.signalservice.api.messages.calls.OfferMessage 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();
}
use of org.whispersystems.signalservice.api.messages.calls.OfferMessage 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();
}
use of org.whispersystems.signalservice.api.messages.calls.OfferMessage in project Signal-Android by signalapp.
the class MessageContentProcessor method handleCallOfferMessage.
private void handleCallOfferMessage(@NonNull SignalServiceContent content, @NonNull OfferMessage message, @NonNull Optional<Long> smsMessageId, @NonNull Recipient senderRecipient) {
log(String.valueOf(content.getTimestamp()), "handleCallOfferMessage...");
if (smsMessageId.isPresent()) {
MessageDatabase database = SignalDatabase.sms();
database.markAsMissedCall(smsMessageId.get(), message.getType() == OfferMessage.Type.VIDEO_CALL);
} else {
RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(message.getId()));
byte[] remoteIdentityKey = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(senderRecipient.getId()).transform(record -> record.getIdentityKey().serialize()).orNull();
ApplicationDependencies.getSignalCallManager().receivedOffer(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()), new WebRtcData.OfferMetadata(message.getOpaque(), message.getSdp(), message.getType()), new WebRtcData.ReceivedOfferMetadata(remoteIdentityKey, content.getServerReceivedTimestamp(), content.getServerDeliveredTimestamp(), content.getCallMessage().get().isMultiRing()));
}
}
use of org.whispersystems.signalservice.api.messages.calls.OfferMessage in project Signal-Android by signalapp.
the class WebRtcActionProcessor method handleSendOffer.
@NonNull
protected final WebRtcServiceState handleSendOffer(@NonNull WebRtcServiceState currentState, @NonNull CallMetadata callMetadata, @NonNull OfferMetadata offerMetadata, boolean broadcast) {
Log.i(tag, "handleSendOffer(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
OfferMessage offerMessage = new OfferMessage(callMetadata.getCallId().longValue(), offerMetadata.getSdp(), offerMetadata.getOfferType(), offerMetadata.getOpaque());
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOffer(offerMessage, true, destinationDeviceId);
Recipient callRecipient = currentState.getCallInfoState().getCallRecipient();
RecipientUtil.shareProfileIfFirstSecureMessage(context, callRecipient);
webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
return currentState;
}
Aggregations