Package com.sun.mpk20.voicelib.app

Examples of com.sun.mpk20.voicelib.app.CallSetup


  VoiceManager vm = AppContext.getManager(VoiceManager.class);

  AudioGroup audioGroup;

  Call call = vm.getCall(callId);

  Player player = vm.getPlayer(callId);

  AudioGroup secretAudioGroup;

  WonderlandClientSender sender = WonderlandContext.getCommsManager().getSender(AudioManagerConnectionType.CONNECTION_TYPE);

  switch (code) {
  case CallStatus.ESTABLISHED:
      if (player == null) {
    logger.warning("Couldn't find player for " + status);
    return;
      }

      //vm.dump("all");
      player.setPrivateMixes(true);

      sender.send(new CallEstablishedMessage(callID));
      break;

  case CallStatus.MUTED:
      sender.send(new CallMutedMessage(callID, true));
      break;

  case CallStatus.UNMUTED:
      sender.send(new CallMutedMessage(callID, false));
      break;

        case CallStatus.STARTEDSPEAKING:
      if (player == null) {
    logger.warning("Couldn't find player for " + status);
    return;
      }

      secretAudioGroup = getSecretAudioGroup(player);

      if (playerIsChatting(player)) {
    VoiceChatHandler.getInstance().setSpeaking(player, callID, true, secretAudioGroup);
      }

      if (secretAudioGroup != null) {
    return;
      }

      sender.send(new CallSpeakingMessage(callID, true));
            break;

        case CallStatus.STOPPEDSPEAKING:
      if (player == null) {
    logger.warning("Couldn't find player for " + status);
    return;
      }

      secretAudioGroup = getSecretAudioGroup(player);

      if (playerIsChatting(player)) {
    VoiceChatHandler.getInstance().setSpeaking(player, callID, false, secretAudioGroup);
      }

      if (secretAudioGroup != null) {
    return;
      }

      sender.send(new CallSpeakingMessage(callID, false));
            break;

  case CallStatus.MIGRATED:
      if (isExternalCall) {
    return;
      }

      sender = WonderlandContext.getCommsManager().getSender(CellChannelConnectionType.CLIENT_TYPE);
      sender.send(clientID, new CallMigrateMessage(callID, true));
      break;

  case CallStatus.MIGRATE_FAILED:
      if (isExternalCall) {
    return;
      }

      sender.send(clientID, new CallMigrateMessage(callID, false));
      break;

  case CallStatus.ENDED:
      if (done) {
    return;
      }

if (false) {
      if (player != null) {
          AudioGroup[] audioGroups = player.getAudioGroups();

          for (int i = 0; i < audioGroups.length; i++) {
        audioGroups[i].removePlayer(player);
          }

    if (player.getSetup().isOutworlder) {
              vm.removePlayer(player);
    }
      } else {
    logger.warning("Couldn't find player for " + status);
      }
}

      done();
      sender.send(new CallEndedMessage(callID, status.getOption("Reason")));
            break;
   
  case CallStatus.BRIDGE_OFFLINE:
            logger.info("Bridge offline: " + status);
    // XXX need a way to tell the voice manager to reset all of the private mixes.
      Call c = vm.getCall(callId);

      if (callId == null || callId.length() == 0) {
                /*
                 * After the last BRIDGE_OFFLINE notification
                 * we have to tell the voice manager to restore
                 * all the pm's for live players.
                 */
                logger.fine("Restoring private mixes...");
      } else {
    if (c == null) {
        logger.warning("No call for " + callId);
        break;
    }

    Player p = c.getPlayer();

    if (p == null) {
        logger.warning("No player for " + callId);
        break;
    }

    try {
        c.end(true);
    } catch (IOException e) {
        logger.warning("Unable to end call " + callId);
    }

    try {
        AudioManagerConnectionHandler.setupCall(
       callId, c.getSetup(), -p.getX(), p.getY(), p.getZ(), p.getOrientation());
    } catch (IOException e) {
        logger.warning("Unable to setupCall " + c + " "
      + e.getMessage());
    }
      }
View Full Code Here


      if (isMuted && muteMessageSpoken == false) {
    muteMessageSpoken = true;

    VoiceManager vm = AppContext.getManager(VoiceManager.class);

    Call call = vm.getCall(callID);

     try {
                    call.playTreatment("tts:You are muted.");
                    call.playTreatment("tts:Press star, three to unmute");
    } catch (IOException e) {
        logger.warning("unable to play you are muted treatment to " + call
      + ":  " + e.getMessage());
    }
      }
View Full Code Here

  starPressed = false;

  VoiceManager vm = AppContext.getManager(VoiceManager.class);

  Call call = vm.getCall(callID);

  if (call == null) {
      logger.warning("No Call for " + callID);
      return;
  }

  if (dtmfKey.equals("4")) {
      if (playingHelp) {
    return;
      }

      playingHelp = true;

      //listenAttenuator = voiceHandler.getListenAttenuator(callID);
      //voiceHandler.setListenAttenuator(callID, listenAttenuator / 3);

      try {
          call.playTreatment(help);
      } catch (IOException e) {
    logger.warning("unable to play help treatment to " + call
        + ":  " + e.getMessage());
      }
      return;
  }
   
  if (dtmfKey.equals("6")) {
      try {
          call.playTreatment("tts:Mary had a little lamb, little lamb, little lamb.");
          call.playTreatment("tts:Mary had a little lamb, its fleece was white as snow.");
      } catch (IOException e) {
    logger.warning("unable to play treatment to " + call
        + ":  " + e.getMessage());
      }

      return;
  }

  if (dtmfKey.equals("7")) {
      try {
          call.playTreatment("tts:And everywhere that Mary went, the lamb was sure to go.");
      } catch (IOException e) {
    logger.warning("unable to play treatment to " + call
        + ":  " + e.getMessage());
      }
      return;
  }

  if (dtmfKey.equals("#")) {
      Player p = vm.getPlayer(callID);

      if (p == null) {
    logger.warning("No Player for " + callID);
    return;
      }

      int n = p.getPlayersInRange().length;

      try {
                if (n == 0) {
                    call.playTreatment("tts:There is no one in range.");
                } else if (n == 1) {
                    call.playTreatment("tts:There is one person in range.");
                } else {
                    call.playTreatment("tts:There are " + n + " people in range.");
          }
      } catch (IOException e) {
    logger.warning("unable to play treatment with players in rang to " + call
        + ":  " + e.getMessage());
      }

      return;
  }

  if (dtmfKey.equals("2")) {
      try {
          call.mute(true);
      } catch (IOException e) {
    logger.warning("Unable to mute call " + call
        + ":  " + e.getMessage());
      }

      isMuted = true;

      OrbMuteCallMessage orbMuteCallMessage = new OrbMuteCallMessage(orbCellID, true);

            // send to everybody cellChannel.send(cellChannel.getSessions(), orbMessage.getBytes());           
      try {
          call.playTreatment("tts:muted");
      } catch (IOException e) {
    logger.warning("unable to play muted treatment to " + call
        + ":  " + e.getMessage());
      }
      return;
  }

  if (dtmfKey.equals("3")) {
      try {
          call.mute(false);
      } catch (IOException e) {
    logger.warning("Unable to unmute call " + call
        + ":  " + e.getMessage());
      }

      isMuted = false;

      try {
          call.playTreatment("tts:un muted");
      } catch (IOException e) {
    logger.warning("unable to play unmuted treatment to " + call
        + ":  " + e.getMessage());
      }
      OrbMuteCallMessage orbUnmuteCallMessage = new OrbMuteCallMessage(orbCellID, false);
View Full Code Here

  logger.finest("got message " + message);

  VoiceManager vm = AppContext.getManager(VoiceManager.class);

  Call call = null;

  Player player = null;

  if (simulateCalls == false) {
      call = vm.getCall(callID);

      if (call == null) {
          logger.warning("Can't find call for " + callID + " " + message);
          return;
      }

      player = vm.getPlayer(callID);
  }

  if (message instanceof OrbEndCallMessage) {
      if (call != null) {
          try {
              vm.endCall(call, true);
          } catch (IOException e) {
        logger.warning("Unable to end call " + call + ": "
            + e.getMessage());
          }
       } else {
    orbStatusListenerRef.get().endCall(callID);
      }

      sender.send(message);
      return;
  }

  if (message instanceof OrbMuteCallMessage) {
      if (call != null) {
          try {
              call.mute(((OrbMuteCallMessage)message).isMuted());
          } catch (IOException e) {
        logger.warning("Unable to mute call " + call + ": "
            + e.getMessage());
        return;
          }
View Full Code Here

        WonderlandClientSender sender = WonderlandContext.getCommsManager().getSender(
      CellChannelConnectionType.CLIENT_TYPE);

  VoiceManager vm = AppContext.getManager(VoiceManager.class);

  Call externalCall = null;

  if (listing.getExternalCallID() != null) {
      externalCall = vm.getCall(listing.getExternalCallID());
  }

  Call softphoneCall = vm.getCall(listing.getSoftphoneCallID());

  logger.fine("external call:  " + externalCall);
  logger.fine("softphone call:  " + softphoneCall);

        switch(status.getCode()) {
        case CallStatus.INVITED:
            //The call has been placed, the phone should be ringing
            /** HARRISDEBUG: It should be tested whether or not we'll catch
             * callStatus changes for calls which we've just set up.
             * If not, this code will have to be moved back to the
             * "messageReceived->PlaceCall" function.
             **/
            if (listing.isPrivate()) {
                //Start playing the phone ringing sound                   
    try {
                    softphoneCall.playTreatment("ring_tone.au");
          } catch (IOException e) {
        logger.warning("Unable to play treatment " + softphoneCall + ":  "
            + e.getMessage());
          }
            }
           
            sender.send(clientID, new CallInvitedResponseMessage(cellID, listing, true));
            break;

        //Something's picked up, the call has been connected
        case CallStatus.ESTABLISHED:
            if (listing.isPrivate()) {
                //Stop playing the phone ringing sound
    try {
                    softphoneCall.stopTreatment("ring_tone.au");
          } catch (IOException e) {
        logger.warning("Unable to stop treatment " + softphoneCall + ":  "
            + e.getMessage());
          }
            }

            sender.send(clientID, new CallEstablishedResponseMessage(cellID, listing, true));
            break;

        case CallStatus.ENDED:
      if (ended) {
    return;
      }

      ended = true;
 
      vm.removeCallStatusListener(this);

            //Stop the ringing
      if (softphoneCall != null) {
          try {
                    softphoneCall.stopTreatment("ring_tone.au");
          } catch (IOException e) {
        logger.warning(
      "Unable to stop treatment " + softphoneCall + ":  "
          + e.getMessage());
          }
      }
               
            String softphoneCallID = listing.getSoftphoneCallID();
               
            //This may appear redundant, but it's necessary for the VoiceManager
      // to remove its internal data structures.

            if (listing.simulateCalls() == false) {
    if (externalCall != null) {
        try {
                        vm.endCall(externalCall, true);
              } catch (IOException e) {
            logger.warning(
          "Unable to end call " + externalCall + ":  "
                + e.getMessage());
              }
    }

                if (listing.isPrivate()) {
        String audioGroupId = softphoneCallID + "_"
            + listing.getPrivateClientName();

        AudioGroup audioGroup = vm.getAudioGroup(audioGroupId);

        if (audioGroup != null) {
            if (softphoneCall.getPlayer() != null) {
                softphoneCall.getPlayer().attenuateOtherGroups(audioGroup,
              AudioGroup.DEFAULT_SPEAKING_ATTENUATION,
                  AudioGroup.DEFAULT_LISTEN_ATTENUATION);
            }

                  vm.removeAudioGroup(audioGroup);
View Full Code Here

          }

          callHandler.removeCallStatusListener(this);

    try {
            Call call = callHandler.getCall();

        if (call == null) {
      logger.info("Can't find call for " + callId);
      return;
        }

        call.end(false);
    } catch (IOException e) {
        logger.warning("Unable to end call for " + callId + ": " + e.getMessage());
    }
      }
      return;
  }

  if (code != CallStatus.ESTABLISHED) {
      return;
  }

  String incomingCall = status.getOption("IncomingCall");

  if (incomingCall == null || incomingCall.equals("false")) {
      return;    // it's not an incoming call
  }

  /*
   * New incoming call
   */
  VoiceManager vm = AppContext.getManager(VoiceManager.class);
 
  CallSetup setup = new CallSetup();
  setup.incomingCall = true;

  setup.cp = new CallParticipant()
  setup.cp.setCallId(callId);
  setup.cp.setConferenceId(vm.getVoiceManagerParameters().conferenceId);

  String callInfo = status.getCallInfo();

  /*
   * When a call is internal from our PBX caller ID is
   *
   * <last name>,<first name>@<10 digit phone number>@<gateway IP address>
   *
   * When we get a call from an outside line, the caller ID is
   *
   * sip:<10 digit phone number>@<gateway IP address>@<10 digit phone number>@<gateway IP address>
   */
  String name;
  String phoneNumber;

  if (callInfo.startsWith("sip:")) {
      callInfo = callInfo.substring(4);
      String[] tokens = callInfo.split("@");

      name = tokens[0];
      phoneNumber = callInfo;
  } else {
      int ix = callInfo.indexOf("@");

      if (ix > 0) {
          name = callInfo.substring(0, ix);

          String[] tokens = name.split(",");

          if (tokens.length == 2) {
        name = tokens[1] + " " + tokens[0];
          } else {
        name = callInfo;
          }

          phoneNumber = callInfo.substring(ix + 1);
      } else {
    name = callInfo;
    phoneNumber = callInfo;
      }
  }

  setup.cp.setPhoneNumber(phoneNumber);
  setup.cp.setName(name);

  Call call;

  try {
      call = vm.createCall(callId, setup);
  } catch (IOException e) {
      logger.warning("Unable to create call " + callId + ": " + e.getMessage());
View Full Code Here

    }
      }
  }

        private void cancelCall() {
      Call call = getCall();

      if (call == null) {
    logger.info("Can't find call for " + callId);
    return;
      }

      try {
          call.end(true);
      } catch (IOException e) {
    logger.warning("Unable to end call " + call + ": " + e.getMessage());
      }
  }
View Full Code Here

  private void playInitialTreatment(Call call, String treatment) {
  }

  private void playTreatment(String treatment) {
      Call call = getCall();

      if (call == null) {
    logger.info("Can't find call for " + callId);
    return;
      }
View Full Code Here

  private Phone getPhone(String phoneNumber) {
      return phoneMap.get(phoneNumber);
  }

  private boolean transferCall() {
      Call call = getCall();

      if (call == null) {
    logger.info("Can't find call for " + callId);
    return false;
      }

      try {
    PhoneInfo phoneInfo = phone.phoneInfo;

                logger.info("Transferring call " + call
        + " to phone " + phoneInfo.phoneNumber);

    Vector3f location = getLocation(phone.phoneCellRef);

    PlayerSetup setup = new PlayerSetup();
    setup.x = location.getX();
    setup.y = location.getY();
    setup.z = location.getZ();
    setup.isOutworlder = true;
    setup.isLivePlayer = true;

    VoiceManager vm = AppContext.getManager(VoiceManager.class);

    Player externalPlayer = vm.createPlayer(call.getId(), setup);

    call.setPlayer(externalPlayer);
    externalPlayer.setCall(call);

    VoiceManagerParameters parameters = vm.getVoiceManagerParameters();

                AudioGroup defaultLivePlayerAudioGroup = parameters.livePlayerAudioGroup;

                AudioGroupPlayerInfo groupInfo = new AudioGroupPlayerInfo(true,
                    AudioGroupPlayerInfo.ChatType.PUBLIC);

    groupInfo.defaultListenAttenuation = 1.0;

                defaultLivePlayerAudioGroup.addPlayer(externalPlayer, groupInfo);

    AudioGroup defaultStationaryPlayerAudioGroup = parameters.stationaryPlayerAudioGroup;

                defaultStationaryPlayerAudioGroup.addPlayer(externalPlayer,
                    new AudioGroupPlayerInfo(false,
                    AudioGroupPlayerInfo.ChatType.PUBLIC));

                call.mute(false);

    call.transferToConference(parameters.conferenceId);
   
    String s;

    if (phoneInfo.phoneNumber.equals("1")) {
        s = "xfer_phone1.au";
    } else if (phoneInfo.phoneNumber.equals("2")) {
        s = "xfer_phone2.au";
    } else if (phoneInfo.phoneNumber.equals("3")) {
        s = "xfer_phone3.au";
    } else if (phoneInfo.phoneNumber.equals("4")) {
        s = "xfer_phone4.au";
    } else if (phoneInfo.phoneNumber.equals("5")) {
        s = "xfer_phone5.au";
    } else {
        s = "tts:transferring call to Phone number "
            + phoneInfo.phoneNumber;
    }

    playTreatment(s);

    String info = establishedStatus.getCallInfo();

    String phoneNumber = call.getId();

    if (info != null) {
        String[] tokens = info.split("@");

        if (info.startsWith("sip:")) {
            phoneNumber = tokens[2];
        } else {
            phoneNumber = tokens[1];
        }
    }

    playTreatment("help.au");
    playTreatment(JOIN_CLICK);
       
     Vector3f center = new Vector3f();

    phone.phoneCellRef.get().getWorldBounds().getCenter(center);

          center.setY((float).5);

    String username = call.getSetup().cp.getName();

    if (username == null) {
        username = call.getId();
    }

    new Orb(username, username, call.getId(), center, .1, false);

    state = ESTABLISHED;
            } catch (IOException e) {
                logger.warning(e.getMessage());
                return false;
View Full Code Here

      String callID = ((GetVoiceBridgeRequestMessage) message).getCallID();

      if (callID != null) {
    logger.info("Ending existing call " + callID);

    Call call = vm.getCall(callID);

    if (call != null) {
        try {
            call.end(false);
        } catch (IOException e) {
      logger.info("Unable to end call " + call
         + " " + e.getMessage());
        }
    } else {
        logger.info("Can't find call for " + callID);
    }
      }

            BridgeInfo bridgeInfo;

            try {
                bridgeInfo = vm.getVoiceBridge();

                logger.info("Sending voice bridge info '" + bridgeInfo + "'");
            } catch (IOException e) {
                logger.warning("unable to get voice bridge:  " + e.getMessage());
                return;
            }

            sender.send(clientID, new GetVoiceBridgeResponseMessage(bridgeInfo.toString()));
            return;
        }

        if (message instanceof PlaceCallRequestMessage) {
            logger.fine("Got PlaceCallMessage from " + clientID);

            placeCall(clientID, (PlaceCallRequestMessage) message);
            return;
        }

  if (message instanceof EndCallMessage) {
      EndCallMessage msg = (EndCallMessage) message;

            String callID = msg.getCallID();

            Call call = vm.getCall(callID);

            if (call == null) {
                logger.fine("Unable to end call " + callID);
                return;
            }

      try {
    vm.endCall(call, true);
            } catch (IOException e) {
                logger.warning(
                    "Unable to end call " + call + ":  " + e.getMessage());
            }

      sender.send(new CallEndedMessage(msg.getCallID(), msg.getReason()));
      return;
  }

        if (message instanceof MuteCallRequestMessage) {
            MuteCallRequestMessage msg = (MuteCallRequestMessage) message;

            String callID = msg.getCallID();

            Call call = vm.getCall(callID);

            if (call == null) {
                logger.info("Unable to mute/unmute call " + callID);
                return;
            }

            try {
                call.mute(msg.isMuted());
            } catch (IOException e) {
                logger.warning("Unable to mute/unmute call " + callID + ": " + e.getMessage());
                return;
            }

            return;
        }

        if (message instanceof TransferCallRequestMessage) {
            TransferCallRequestMessage msg = (TransferCallRequestMessage) message;

            String callID = msg.getPresenceInfo().getCallID();

            Call call = vm.getCall(callID);

            if (call == null) {
                if (msg.getCancel() == true) {
                    return;
                }

                double x = 0;
                double y = 0;
                double z = 0;
                double orientation = 0;

                Player player = vm.getPlayer(callID);

                if (player != null) {
                    x = -player.getX();
                    y = player.getY();
                    z = player.getZ();
                    orientation = player.getOrientation();
                }

                placeCall(clientID, new PlaceCallRequestMessage(msg.getPresenceInfo(),
        msg.getPhoneNumber(), x, y, z, orientation, true));
                return;
            }

            CallParticipant cp = call.getSetup().cp;

            if (msg.getCancel() == true) {
                try {
                    call.transfer(cp, true);
                } catch (IOException e) {
                    logger.warning("Unable to cancel call transfer:  " + e.getMessage());
                }
                return;
            }

            if (msg.getPhoneNumber().equals(cp.getPhoneNumber())) {
    sender.send(clientID, new CallMigrateMessage(msg.getPresenceInfo().getCallID(), true));
                return;
            }

            cp.setPhoneNumber(msg.getPhoneNumber());

            setJoinConfirmation(cp);

            try {
                call.transfer(cp, false);
            } catch (IOException e) {
                logger.warning("Unable to transfer call:  " + e.getMessage());
            }
            return;
        }

  if (message instanceof AudioVolumeMessage) {
      handleAudioVolume(sender, clientID, (AudioVolumeMessage) message);
      return;
  }

  if (message instanceof ChangeUsernameAliasMessage) {
      sender.send(message);
      return;
  }

        if (message instanceof VoiceChatMessage) {
            VoiceChatHandler.getInstance().processVoiceChatMessage(sender, clientID,
                    (VoiceChatMessage) message);
            return;
        }

        if (message instanceof PlayTreatmentRequestMessage) {
            PlayTreatmentRequestMessage msg = (PlayTreatmentRequestMessage) message;

            Call call = vm.getCall(msg.getCallID());

            if (call == null) {
                logger.warning("No call for " + msg.getCallID());
                return;
            }

            try {
                call.playTreatment(msg.getTreatment());
            } catch (IOException e) {
                logger.warning("Unable to play treatment " + msg.getTreatment()
        + " to call " + call + ": " + e.getMessage());
            }
            return;
View Full Code Here

TOP

Related Classes of com.sun.mpk20.voicelib.app.CallSetup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.