Beispiel #1
0
  public void handleAck(SipRequest ack, Dialog dialog) {
    // TODO determine if ACK is ACK of an initial INVITE or a re-INVITE
    // in first case, captureRtpSender and incomingRtpReader must be
    // created, in the second case, they must be updated.

    logger.debug("handleAck");

    if (mediaDestination == null) {
      SipHeaders reqHeaders = ack.getSipHeaders();
      SipHeaderFieldValue contentType =
          reqHeaders.get(new SipHeaderFieldName(RFC3261.HDR_CONTENT_TYPE));
      byte[] offerBytes = ack.getBody();

      if (offerBytes != null
          && contentType != null
          && RFC3261.CONTENT_TYPE_SDP.equals(contentType.getValue())) {
        // create response in 200
        try {
          SessionDescription answer = sdpManager.parse(offerBytes);
          mediaDestination = sdpManager.getMediaDestination(answer);
        } catch (NoCodecException e) {
          logger.error(e.getMessage(), e);
          return;
        }
      }
    }
    String destAddress = mediaDestination.getDestination();
    int destPort = mediaDestination.getPort();
    Codec codec = mediaDestination.getCodec();

    MediaManager mediaManager = userAgent.getMediaManager();
    if (initialIncomingInvite) {
      mediaManager.handleAck(destAddress, destPort, codec);
    } else {
      mediaManager.updateRemote(destAddress, destPort, codec);
    }
  }
Beispiel #2
0
 public void terminate(SipRequest sipRequest) {
   String callId = Utils.getMessageCallId(sipRequest);
   if (!guiClosedCallIds.contains(callId)) {
     guiClosedCallIds.add(callId);
   }
   Dialog dialog = dialogManager.getDialog(callId);
   SipRequest inviteWithAuth = getInviteWithAuth(callId);
   if (dialog != null) {
     SipRequest originatingRequest;
     if (inviteWithAuth != null) {
       originatingRequest = inviteWithAuth;
     } else {
       originatingRequest = sipRequest;
     }
     ClientTransaction clientTransaction =
         transactionManager.getClientTransaction(originatingRequest);
     if (clientTransaction != null) {
       synchronized (clientTransaction) {
         DialogState dialogState = dialog.getState();
         if (dialog.EARLY.equals(dialogState)) {
           initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri);
         } else if (dialog.CONFIRMED.equals(dialogState)) {
           // clientTransaction not yet removed
           midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null);
           guiClosedCallIds.remove(callId);
         }
       }
     } else {
       // clientTransaction Terminated and removed
       logger.debug("clientTransaction null");
       midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null);
       guiClosedCallIds.remove(callId);
     }
   } else {
     InviteClientTransaction inviteClientTransaction =
         (InviteClientTransaction) transactionManager.getClientTransaction(inviteWithAuth);
     if (inviteClientTransaction == null) {
       logger.error("cannot find invite client transaction" + " for call " + callId);
     } else {
       SipResponse sipResponse = inviteClientTransaction.getLastResponse();
       if (sipResponse != null) {
         int statusCode = sipResponse.getStatusCode();
         if (statusCode < RFC3261.CODE_200_OK) {
           initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri);
         }
       }
     }
   }
   switch (userAgent.getMediaMode()) {
     case captureAndPlayback:
       userAgent.getMediaManager().stopSession();
       SoundManager soundManager = userAgent.getSoundManager();
       if (soundManager != null) {
         soundManager.closeLines();
       }
       break;
     case echo:
       Echo echo = userAgent.getEcho();
       if (echo != null) {
         echo.stop();
         userAgent.setEcho(null);
       }
       break;
     case file:
       MediaManager mediaManager = userAgent.getMediaManager();
       mediaManager.stopSession();
       break;
     default:
       break;
   }
 }