Package com.sun.mpk20.voicelib.app

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


      return;
  }

  int code = status.getCode();

  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
View Full Code Here


            break;
        }
    }

    private boolean playerIsChatting(Player player) {
  VoiceManager vm = AppContext.getManager(VoiceManager.class);

  VoiceManagerParameters parameters = vm.getVoiceManagerParameters();

  AudioGroup[] audioGroups = player.getAudioGroups();

  for (int i = 0; i < audioGroups.length; i++) {
      if (audioGroups[i].equals(parameters.livePlayerAudioGroup) == false &&
View Full Code Here

        case CallStatus.STARTEDSPEAKING:           
      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) {
View Full Code Here

      return;
  }

  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;
      }
View Full Code Here

    public void messageReceived(WonderlandClientSender sender,
      WonderlandClientID clientID, CellMessage message) {

  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;
          }
      }

      sender.send(message);
      return;
  }

  if (message instanceof OrbChangeNameMessage) {
      username = ((OrbChangeNameMessage) message).getName();
      sender.send(message);
      return;
  }

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

      if (player == null) {
    return;
      }

      Vector3f position = msg.getPosition();

      player.moved(position.getX(), position.getY(), position.getZ(),
    player.getOrientation());
      return;
  }

  if (message instanceof OrbSetVolumeMessage) {
      if (player == null) {
    logger.warning("no player for " + callID);
    return;
      }

      OrbSetVolumeMessage msg = (OrbSetVolumeMessage) message;

      String softphoneCallID = msg.getSoftphoneCallID();

      Player softphonePlayer = vm.getPlayer(softphoneCallID);

      if (softphonePlayer == null) {
    logger.warning("Can't find Player for softphone " + softphoneCallID);
    return;
      }

      DefaultSpatializer spatializer = (DefaultSpatializer)
    vm.getVoiceManagerParameters().livePlayerSpatializer.clone();

      double volume = msg.getVolume();

      spatializer.setAttenuator(volume);
View Full Code Here

  logger.finer("got status " + status);

        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);
        }
    }
            }
               
            sender.send(clientID, new CallEndedResponseMessage(cellID,
View Full Code Here

    public static IncomingCallHandler getInstance() {
  if (incomingCallHandler != null) {
      return incomingCallHandler;
  }

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

  incomingCallHandler = new IncomingCallHandler();

  vm.addCallStatusListener(incomingCallHandler);

  vm.addCallBeginEndListener(incomingCallHandler);

  return incomingCallHandler;
    }
View Full Code Here

  return incomingCallHandler;
    }

    public void done() {
  VoiceManager vm = AppContext.getManager(VoiceManager.class);
  vm.removeCallStatusListener(incomingCallHandler);
  vm.removeCallBeginEndListener(incomingCallHandler);
    }
View Full Code Here

  }

  /*
   * 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());
      return;
  }

View Full Code Here

    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);
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.