예제 #1
0
 private SipRequest getInviteWithAuth(String callId) {
   List<ClientTransaction> clientTransactions =
       transactionManager.getClientTransactionsFromCallId(callId, RFC3261.METHOD_INVITE);
   SipRequest sipRequestNoAuth = null;
   for (ClientTransaction clientTransaction : clientTransactions) {
     InviteClientTransaction inviteClientTransaction = (InviteClientTransaction) clientTransaction;
     SipRequest sipRequest = inviteClientTransaction.getRequest();
     SipHeaders sipHeaders = sipRequest.getSipHeaders();
     SipHeaderFieldName authorization = new SipHeaderFieldName(RFC3261.HDR_AUTHORIZATION);
     SipHeaderFieldValue value = sipHeaders.get(authorization);
     if (value == null) {
       SipHeaderFieldName proxyAuthorization =
           new SipHeaderFieldName(RFC3261.HDR_PROXY_AUTHORIZATION);
       value = sipHeaders.get(proxyAuthorization);
     }
     if (value != null) {
       return sipRequest;
     }
     sipRequestNoAuth = sipRequest;
   }
   return sipRequestNoAuth;
 }
예제 #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;
   }
 }