Esempio n. 1
0
  /** Mute or unmute member in a whisperGroup */
  public static void setMuteWhisperGroup(String callId, boolean isMuted) {
    if (callId == null) {
      return;
    }

    synchronized (activeCalls) {
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (match(cp, callId)) {
          if (Logger.logLevel >= Logger.LOG_DETAIL) {
            String s = "";

            if (isMuted == false) {
              s = "un";
            }
            Logger.println(cp.getCallId() + ":  " + s + "muted");
          }

          MemberReceiver memberReceiver = call.getMemberReceiver();

          if (memberReceiver != null) {
            memberReceiver.setMuteWhisperGroup(isMuted);
          }
        }
      }
    }
  }
Esempio n. 2
0
  /*
   * Mostly for debugging
   */
  public String getCallState() {
    String s = "\n" + cp.toString();

    if (member != null) {
      s += "  ConferenceId: " + member.getConferenceManager().getId() + "\n";

      s += "\tStarted " + member.getTimeStarted() + "\n";
    } else {
      s += "\n";
    }

    if (csa != null) {
      s += "\tState = " + csa.getCallState() + "\n";
    } else {
      s += "\tNo Call Setup Agent" + "\n";
    }

    s += "\tIsDistributedBridge " + cp.isDistributedBridge() + "\n";

    if (cp.getCallTimeout() == 0) {
      s += "\tNo timeout\n";
    } else {
      s += "\tCall timeout in " + (cp.getCallTimeout() / 1000) + " seconds\n";
    }

    if (member != null) {
      s += " " + member.getMemberState();
    }

    return s;
  }
Esempio n. 3
0
  /** Mute or unmute the main conference from a particular call. */
  public static void setConferenceSilenced(String callId, boolean isSilenced) {
    synchronized (activeCalls) {
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (match(cp, callId)) {
          if (Logger.logLevel >= Logger.LOG_DETAIL) {
            String s = "";

            if (isSilenced == false) {
              s = "un";
            }

            Logger.println(cp.getCallId() + ":  silenceMainonference " + s + "muted");
          }

          ConferenceMember member = call.getMember();

          if (member != null) {
            member.setConferenceSilenced(isSilenced);
          }
        }
      }
    }
  }
Esempio n. 4
0
  /** Send indication when a dtmf key is pressed */
  public void dtmfKeys(String dtmfKeys) {
    // if (Logger.logLevel >= Logger.LOG_MOREINFO) {
    Logger.println(cp + " got dtmf keys " + dtmfKeys + " " + cp.dtmfDetection());
    // }

    if (isCallEstablished()) {
      if (cp.dtmfDetection()) {
        member.stopTreatment(null);

        CallEvent callEvent = new CallEvent(CallEvent.DTMF_KEY);
        callEvent.setDtmfKey(dtmfKeys);
        sendCallEventNotification(callEvent);
      }

      if (otherCall != null) {
        Logger.println("Call " + cp + " forwarding dtmf key " + dtmfKeys + " to " + otherCall);
        otherCall.getMemberSender().setDtmfKeyToSend(dtmfKeys);
      } else {
        getMemberSender().setDtmfKeyToSend(dtmfKeys);
      }
    } else {
      if (Logger.logLevel >= Logger.LOG_MOREINFO) {
        Logger.println(cp + " Call not established, ignoring dtmf");
      }
      stopCallAnsweredTreatment();
    }
  }
Esempio n. 5
0
  /**
   * Find a call by callId.
   *
   * <p>Calls are kept in the activeCalls list and uniquely identified by
   * <callId>::<name>@<phoneNumber> for a phone call and
   *
   * <p>This method searches for a call with the callId.
   */
  public static CallHandler findCall(String callId) {
    if (Logger.logLevel >= Logger.LOG_DETAIL) {
      Logger.println(
          "findCall:  looking for " + callId + ", " + activeCalls.size() + " active calls");
    }

    synchronized (activeCalls) {
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (Logger.logLevel >= Logger.LOG_DETAIL) {
          Logger.println("findCall:  looking for " + callId + " got " + cp.getCallId());
        }

        if (match(cp, callId)) {
          if (Logger.logLevel >= Logger.LOG_DETAIL) {
            Logger.println("findCall:  found " + callId);
          }

          return call;
        }
      }
    }
    return null;
  }
Esempio n. 6
0
  private static boolean match(CallParticipant cp, String callId) {
    if (cp.getCallId().equals(callId)) {
      return true;
    }

    if (ConferenceManager.allowShortNames() == false) {
      return false;
    }

    String name = cp.getName();

    if (name != null) {
      if (name.equals(callId)) {
        return true;
      }

      name = name.replaceAll(" ", "_");

      if (name.equals(callId)) {
        return true;
      }
    }

    String number = cp.getPhoneNumber();

    if (number == null) {
      return false;
    }

    if (number.equals(callId)) {
      return true;
    }

    if (number.indexOf("sip:") == 0) {
      int ix = number.indexOf("@");

      if (ix >= 0) {
        number = number.substring(4, ix);

        if (number.equals(callId)) {
          return true;
        }
      }
    }

    return false;
  }
Esempio n. 7
0
  /** Find the new call of a call migration. */
  public static CallHandler findMigratingCall(String callId) {
    synchronized (activeCalls) {
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (match(cp, callId) && cp.migrateCall()) {
          if (Logger.logLevel >= Logger.LOG_DETAIL) {
            Logger.println("findMigratingCall:  found " + callId);
          }

          return call;
        }
      }
    }
    return null;
  }
Esempio n. 8
0
  /** For debugging... */
  public static boolean tooManyDuplicateCalls(String phoneNumber) {
    synchronized (activeCalls) {
      int n = 0;

      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (cp.getPhoneNumber().equals(phoneNumber)) {
          n++;
        }
      }

      if (n > duplicateCallLimit) {
        return true;
      }

      return false;
    }
  }
Esempio n. 9
0
  public static void hangupOwner(String ownerId, String reason) {
    Vector callsToCancel = new Vector();

    synchronized (activeCalls) {
      /*
       * Make a list of all the calls we want to cancel, then cancel them.
       * We have to cancel them while not synchronized or
       * we could deadlock.
       */
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (cp.getCallOwner().equals(ownerId)) {
          callsToCancel.add(call);
        }
      }
    }

    cancel(callsToCancel, reason, false);
  }
Esempio n. 10
0
  /** Set flag to do voice detection while muted */
  public static void setVoiceDetectionWhileMuted(String callId, boolean voiceDetectionWhileMuted) {

    if (callId == null) {
      return;
    }

    synchronized (activeCalls) {
      for (int i = 0; i < activeCalls.size(); i++) {
        CallHandler call = (CallHandler) activeCalls.elementAt(i);

        CallParticipant cp = call.getCallParticipant();

        if (match(cp, callId)) {
          cp.setVoiceDetectionWhileMuted(voiceDetectionWhileMuted);

          if (Logger.logLevel >= Logger.LOG_DETAIL) {
            Logger.println(
                cp.getCallId() + " voice detection while muted is " + voiceDetectionWhileMuted);
          }
        }
      }
    }
  }
Esempio n. 11
0
  public void sendCallEventNotification(CallEvent callEvent) {
    if (cp.getCallId() != null) {
      callEvent.setCallId(cp.getCallId());
    } else {
      callEvent.setCallId("CallIdNotInitialized");
    }

    callEvent.setConferenceId(cp.getConferenceId());

    callEvent.setCallInfo(cp.getCallOwner());

    if (csa != null) {
      callEvent.setCallState(csa.getCallState());
    } else {
      callEvent.setCallState(new CallState(CallState.UNINITIALIZED));
    }

    synchronized (callEventListeners) {
      for (int i = 0; i < callEventListeners.size(); i++) {
        CallEventListener listener = (CallEventListener) callEventListeners.elementAt(i);
        listener.callEventNotification(callEvent);
      }
    }
  }
Esempio n. 12
0
  public TreatmentManager playTreatmentToCall(
      String treatment, TreatmentDoneListener treatmentDoneListener) throws IOException {

    if (Logger.logLevel >= Logger.LOG_MOREINFO) {
      Logger.println("Playing treatment " + treatment + " to " + cp.getCallId());
    }

    TreatmentManager treatmentManager =
        new TreatmentManager(
            treatment,
            0,
            conferenceManager.getMediaInfo().getSampleRate(),
            conferenceManager.getMediaInfo().getChannels());

    if (treatmentDoneListener != null) {
      treatmentManager.addTreatmentDoneListener(treatmentDoneListener);
    }

    addTreatment(treatmentManager);
    return treatmentManager;
  }
Esempio n. 13
0
 /**
  * String representation of this Caller
  *
  * @return the string representation of this Caller
  */
 public String toString() {
   return cp.toString();
 }