org.whispersystems.signalservice.api.messages.calls.AnswerMessage Java Examples

The following examples show how to use org.whispersystems.signalservice.api.messages.calls.AnswerMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PushProcessMessageJob.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void handleCallAnswerMessage(@NonNull SignalServiceContent content,
                                     @NonNull AnswerMessage message)
{
  Log.i(TAG, "handleCallAnswerMessage...");
  Intent     intent     = new Intent(context, WebRtcCallService.class);
  RemotePeer remotePeer = new RemotePeer(Recipient.externalPush(context, content.getSender()).getId());

  intent.setAction(WebRtcCallService.ACTION_RECEIVE_ANSWER)
        .putExtra(WebRtcCallService.EXTRA_CALL_ID,            message.getId())
        .putExtra(WebRtcCallService.EXTRA_REMOTE_PEER,        remotePeer)
        .putExtra(WebRtcCallService.EXTRA_REMOTE_DEVICE,      content.getSenderDevice())
        .putExtra(WebRtcCallService.EXTRA_ANSWER_DESCRIPTION, message.getDescription())
        .putExtra(WebRtcCallService.EXTRA_MULTI_RING,         content.getCallMessage().get().isMultiRing());

  context.startService(intent);
}
 
Example #2
Source File: SignalServiceCipher.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
private SignalServiceCallMessage createCallMessage(CallMessage content) {
  if (content.hasOffer()) {
    CallMessage.Offer offerContent = content.getOffer();
    return SignalServiceCallMessage.forOffer(new OfferMessage(offerContent.getId(), offerContent.getDescription()));
  } else if (content.hasAnswer()) {
    CallMessage.Answer answerContent = content.getAnswer();
    return SignalServiceCallMessage.forAnswer(new AnswerMessage(answerContent.getId(), answerContent.getDescription()));
  } else if (content.getIceUpdateCount() > 0) {
    List<IceUpdateMessage> iceUpdates = new LinkedList<>();

    for (CallMessage.IceUpdate iceUpdate : content.getIceUpdateList()) {
      iceUpdates.add(new IceUpdateMessage(iceUpdate.getId(), iceUpdate.getSdpMid(), iceUpdate.getSdpMLineIndex(), iceUpdate.getSdp()));
    }

    return SignalServiceCallMessage.forIceUpdates(iceUpdates);
  } else if (content.hasHangup()) {
    CallMessage.Hangup hangup = content.getHangup();
    return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId()));
  } else if (content.hasBusy()) {
    CallMessage.Busy busy = content.getBusy();
    return SignalServiceCallMessage.forBusy(new BusyMessage(busy.getId()));
  }

  return SignalServiceCallMessage.empty();
}
 
Example #3
Source File: WebRtcCallService.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void handleSendAnswer(Intent intent) {
  RemotePeer remotePeer   = getRemotePeer(intent);
  CallId     callId       = getCallId(intent);
  Integer    remoteDevice = intent.getIntExtra(EXTRA_REMOTE_DEVICE, -1);
  boolean    broadcast    = intent.getBooleanExtra(EXTRA_BROADCAST, false);
  String     answer       = intent.getStringExtra(EXTRA_ANSWER_DESCRIPTION);

  Log.i(TAG, "handleSendAnswer: id: " + callId.format(remoteDevice));

  AnswerMessage            answerMessage       = new AnswerMessage(callId.longValue(), answer);
  Integer                  destinationDeviceId = broadcast ? null : remoteDevice;
  SignalServiceCallMessage callMessage         = SignalServiceCallMessage.forAnswer(answerMessage, true, destinationDeviceId);

  sendCallMessage(remotePeer, callMessage);
}
 
Example #4
Source File: SignalServiceCipher.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private SignalServiceCallMessage createCallMessage(CallMessage content) {
  if (content.hasOffer()) {
    CallMessage.Offer offerContent = content.getOffer();
    CallMessage.Offer.CallType callType = CallMessage.Offer.CallType.AUDIO;
    if (offerContent.hasType()) {
      callType = offerContent.getType();
    }
    return SignalServiceCallMessage.forOffer(new OfferMessage(offerContent.getId(), offerContent.getDescription(), callType));
  } else if (content.hasAnswer()) {
    CallMessage.Answer answerContent = content.getAnswer();
    return SignalServiceCallMessage.forAnswer(new AnswerMessage(answerContent.getId(), answerContent.getDescription()));
  } else if (content.getIceUpdateCount() > 0) {
    List<IceUpdateMessage> iceUpdates = new LinkedList<>();

    for (CallMessage.IceUpdate iceUpdate : content.getIceUpdateList()) {
      iceUpdates.add(new IceUpdateMessage(iceUpdate.getId(), iceUpdate.getSdpMid(), iceUpdate.getSdpMLineIndex(), iceUpdate.getSdp()));
    }

    return SignalServiceCallMessage.forIceUpdates(iceUpdates);
  } else if (content.hasHangup()) {
    CallMessage.Hangup hangup = content.getHangup();
    return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId()));
  } else if (content.hasBusy()) {
    CallMessage.Busy busy = content.getBusy();
    return SignalServiceCallMessage.forBusy(new BusyMessage(busy.getId()));
  }

  return SignalServiceCallMessage.empty();
}
 
Example #5
Source File: PushDecryptJob.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private void handleCallAnswerMessage(@NonNull SignalServiceProtos.Envelope envelope,
                                     @NonNull AnswerMessage message) {
    ALog.i(TAG, "handleCallAnswerMessage...");
    try {
        Intent intent = new Intent(context, WebRtcCallService.class);
        intent.setAction(WebRtcCallService.ACTION_RESPONSE_MESSAGE);
        intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
        intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, Address.from(accountContext, envelope.getSource()));
        intent.putExtra(WebRtcCallService.EXTRA_REMOTE_DESCRIPTION, message.getDescription());
        intent.putExtra(ARouterConstants.PARAM.PARAM_ACCOUNT_CONTEXT, accountContext);
        AppUtilKotlinKt.startForegroundServiceCompat(context, intent);
    } catch (Exception ex) {
        ALog.e(TAG, "handleCallAnswerMessage error", ex);
    }
}
 
Example #6
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example #7
Source File: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
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())
                                      .setType(offer.getType().getProtoType()));
  } 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()) {
    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()));
  }

  builder.setMultiRing(callMessage.isMultiRing());

  if (callMessage.getDestinationDeviceId().isPresent()) {
    builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get());
  }

  container.setCallMessage(builder);
  return container.build().toByteArray();
}