コード例 #1
0
  /** Handle a dial request */
  public void handleDialRequest(String phoneNumber) {
    try {

      System.err.println(
          "Audio Static:"
              + PhoneManager.isUseStaticLocator()
              + " Using:"
              + PhoneManager.isUsingMediaLocator());

      // cancel call request if no Media Locator
      if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) {
        return;
      }

      PhoneManager.setUsingMediaLocator(true);

      SessionDescription sdpData = mediaManager.generateSdpDescription();

      Call call = sipManager.establishCall(phoneNumber, sdpData.toString());

      if (call == null) return;

      call.setLocalSdpDescription(sdpData);

      call.addStateChangeListener(this);
      Interlocutor interlocutor = new Interlocutor();
      interlocutor.setCall(call);

      guiManager.addInterlocutor(interlocutor);
    } catch (Exception e) {
      Log.error("handleDialRequest", e);
    }
  }
コード例 #2
0
  /** Handle a answer request */
  public boolean handleAnswerRequest(Interlocutor interlocutor) {

    // cancel call request if no Media Locator
    if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) {
      return false;
    }

    PhoneManager.setUsingMediaLocator(true);

    SessionDescription sdpData = null;
    try {
      sdpData = mediaManager.generateSdpDescription();
      interlocutor.getCall().setLocalSdpDescription(sdpData);
    } catch (MediaException ex) {
      try {
        sipManager.sendServerInternalError(interlocutor.getID());
      } catch (CommunicationsException ex1) {
        Log.error("handleAnswerRequest", ex1);
      }
      return false;
    }
    try {
      sipManager.answerCall(interlocutor.getID(), sdpData.toString());
    } catch (CommunicationsException exc) {
      Log.error("handleAnswerRequest", exc);
      return false;
    }
    return true;
  }