Package com.sun.mpk20.voicelib.app

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


         * Set a private spatializer for the given fullVolume radius
         * for all the other avatars in the cell.
         * For each cell already in the cell, set a private spatializer
         * for this cell.
         */
        VoiceManager vm = AppContext.getManager(VoiceManager.class);

        Player player = vm.getPlayer(callId);

        logger.warning(callId + " entered cone " + name + " player " + player);

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

        AudioGroup audioGroup = vm.getAudioGroup(name);

        if (audioGroup == null) {
      AudioGroupSetup setup = new AudioGroupSetup();

      setup.audioGroupListener = this;

      setup.spatializer = new FullVolumeSpatializer();

            setup.spatializer.setAttenuator(Spatializer.DEFAULT_MAXIMUM_VOLUME);

      //System.out.println("Creating audio group for " + name);

      audioGroup = vm.createAudioGroup(name, setup);
        }

  //System.out.println("CONE PROX Player:  " + player);

  boolean isSpeaking = (inPrivateChat(audioGroup, player) == false);
View Full Code Here


    }

    private void cellExited(String callId) {
        logger.warning(callId + " exited cone " + name + " avatar cell ID " + callId);

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

        AudioGroup audioGroup = vm.getAudioGroup(name);

        if (audioGroup == null) {
            logger.warning("No audio group " + name);
            return;
        }

        Player player = vm.getPlayer(callId);

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

      sender.send(new ConeOfSilenceEnterExitMessage(name, player.getId(), false));
  }
    }

    public void remove() {
        VoiceManager vm = AppContext.getManager(VoiceManager.class);

        AudioGroup audioGroup = vm.getAudioGroup(name);

  logger.warning("Remove " + audioGroup + " name " + name);

  if (audioGroup == null) {
      return;
  }

  vm.removeAudioGroup(audioGroup);
    }
View Full Code Here

                                                     1000);

            return;
        }

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

        TreatmentGroup group = null;

  if (groupId != null && groupId.length() > 0) {
      group = vm.createTreatmentGroup(groupId);
  }
 
        for (int i = 0; i < treatments.length; i++) {
            TreatmentSetup setup = new TreatmentSetup();

      setup.treatmentCreatedListener = new TreatmentCreatedListenerImpl(cellID);

      setup.spatializer = getSpatializer(false);

            String treatment = treatments[i];

            String treatmentId = CallID.getCallID(cellID);

      String pattern = "wlcontent://";

            if (treatment.startsWith(pattern)) {
                /*
                 * We need to create a URL
                 */
                String path = treatment.substring(pattern.length());

                URL url;

                try {
                    path = path.replaceAll(" ", "%20");

                    url = new URL(new URL(serverURL), "webdav/content/" + path);

                    treatment = url.toString();
                } catch (MalformedURLException e) {
                    logger.warning("bad url:  " + e.getMessage());
                    return;
    }
      } else {
          pattern = "wls://";

          if (treatment.startsWith(pattern)) {
                    /*
                     * We need to create a URL from wls:<module>/path
                     */
                    treatment = treatment.substring(pattern.length())// skip past wls://

                    int ix = treatment.indexOf("/");

                    if (ix < 0) {
                        logger.warning("Bad treatment:  " + treatments[i]);
                        continue;
                    }

                    String moduleName = treatment.substring(0, ix);

                    String path = treatment.substring(ix + 1);

                    logger.fine("Module:  " + moduleName + " treatment " + treatment);

                    URL url;

                    try {
      path = path.replaceAll(" ", "%20");

                        url = new URL(new URL(serverURL),
                            "webdav/content/modules/installed/" + moduleName + "/audio/" + path);

                        treatment = url.toString();
                        logger.fine("Treatment: " + treatment);
                    } catch (MalformedURLException e) {
                        logger.warning("bad url:  " + e.getMessage());
                        continue;
                    }
                }
      }

            setup.treatment = treatment;

      vm.addCallStatusListener(this, treatmentId);

            if (setup.treatment == null || setup.treatment.length() == 0) {
                logger.warning("Invalid treatment '" + setup.treatment + "'");
                continue;
            }

            // OWL issue #60: make sure to use world location, not local
            // location
            Vector3f location = cellRef.get().getWorldTransform(null).getTranslation(null);

            setup.x = location.getX();
            setup.y = location.getY();
            setup.z = location.getZ();

            // do we need to start paused?
            if (playWhen.equals(PlayWhen.ALWAYS) == false) {
                setup.startPaused = true;
            }
           
            logger.info("Starting treatment " + setup.treatment + " at (" + setup.x
    + ":" + setup.y + ":" + setup.z + ")");

            System.out.println("Starting treatment " + setup.treatment + " at (" + setup.x
    + ":" + setup.y + ":" + setup.z + ")");
 
            try {
    Treatment t = vm.createTreatment(treatmentId, setup);

    if (group != null) {
                    group.addTreatment(t);
    }

View Full Code Here

      }

      parent = parent.getParent();
  }

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

        TreatmentGroup group = null;

  if (groupId != null) {
      group = vm.getTreatmentGroup(groupId);
  }

  if (group == null) {
      Treatment treatment = vm.getTreatment(CallID.getCallID(cellID));

      if (treatment == null) {
      //System.out.println("No treatment for " + CallID.getCallID(cellID));
    return;
      }

      endTreatment(treatment);
      return;
  }

  Treatment[] treatments = group.getTreatments().values().toArray(new Treatment[0]);

  for (int i = 0; i < treatments.length; i++) {
      //System.out.println("Ending treatment:  " + treatments[i]);
      endTreatment(treatments[i]);
      group.removeTreatment(treatments[i]);
  }

  try {
      vm.removeTreatmentGroup(group);
  } catch (IOException e) {
      logger.warning("Unable to remove treatment group " + group);
  }

  vm.dump("all");
    }
View Full Code Here

            double volume = msg.getVolume();

            logger.fine("GOT Volume message:  call " + softphoneCallID
          + " volume " + volume + " other callID " + otherCallID);

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

            Player softphonePlayer = vm.getPlayer(softphoneCallID);

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

            Player player = vm.getPlayer(otherCallID);

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

      if (msg.isSetVolume() == false) {
                AudioTreatmentComponentMO audioTreatmentComponentMO =
        cellMO.getComponent(AudioTreatmentComponentMO.class);

    msg.setVolume(audioTreatmentComponentMO.getVolume());
                sender.send(clientID, msg);
                logger.fine("Sending vol message " + msg.getVolume());
                return;
            }

      if (volume == 1.0) {
          softphonePlayer.removePrivateSpatializer(player);
          return;
      }

      VoiceManagerParameters parameters = vm.getVoiceManagerParameters();

            Spatializer spatializer;

      spatializer = player.getPublicSpatializer();
View Full Code Here

    }

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

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

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

      Player player = vm.getPlayer(msg.getPlayerID());

      if (player == null) {
    logger.warning("No player for " + msg.getPlayerID());
    return;

      }

      Player[] playersInRange = player.getPlayersInRange();

      String[] playerIDList = new String[playersInRange.length];

      for (int i = 0; i < playersInRange.length; i++) {
    playerIDList[i] = playersInRange[i].getId();   
      }
 
      sender.send(clientID, new GetPlayersInRangeResponseMessage(msg.getPlayerID(),
    playerIDList));

      return;
  }

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

      try {
          vm.testUDPPort(msg.getHost(), msg.getPort(), msg.getDuration());
      } catch (IOException e) {
    logger.warning("Unable to test udp port " + msg.getPort()
        + ": " + e.getMessage());
      }

      return;
  }

        if (message instanceof GetVoiceBridgeRequestMessage) {
            logger.fine("Got GetVoiceBridgeMessage");

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

        if (callID == null) {
            logger.fine("Can't place call to " + msg.getSipURL() + ".  No cell for " + callID);
            return;
        }

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

  Call call = vm.getCall(callID);

  if (call != null) {
      call.getSetup().ended = true// make it look like it ended already
  }
 
  ScalableHashMap<String, ManagedReference<AudioCallStatusListener>> callIDListenerMap = callIDListenerMapRef.get();

  ManagedReference<AudioCallStatusListener> audioCallStatusListenerRef = callIDListenerMap.remove(callID);

  if (audioCallStatusListenerRef != null) {
      audioCallStatusListenerRef.get().done();
  }

        AudioCallStatusListener audioCallStatusListener = new AudioCallStatusListener(clientID, callID);

  audioCallStatusListenerRef = AppContext.getDataManager().createReference(audioCallStatusListener);

  callIDListenerMap.put(callID, audioCallStatusListenerRef);

        cp.setCallId(callID);
        cp.setName(info.getUserID().getUsername());
        cp.setPhoneNumber(msg.getSipURL());

        setJoinConfirmation(cp);

  cp.setCallEstablishedTreatment(JOIN_SOUND);
        cp.setConferenceId(vm.getVoiceManagerParameters().conferenceId);
        cp.setVoiceDetection(true);
        cp.setDtmfDetection(true);
        cp.setVoiceDetectionWhileMuted(true);
        cp.setHandleSessionProgress(true);
View Full Code Here

    }

    public static void setupCall(String callID, CallSetup setup, double x,
            double y, double z, double direction) throws IOException {

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

        Player p = vm.getPlayer(callID);

        Call call;

        call = vm.createCall(callID, setup);

        callID = call.getId();

        PlayerSetup ps = new PlayerSetup();

        if (p == null) {
            ps.x = x;
            ps.y = y;
            ps.z = z;
        } else {
            ps.x = p.getSetup().x;
            ps.y = p.getSetup().y;
            ps.z = p.getSetup().z;
        }

        ps.orientation = direction;
        ps.isLivePlayer = true;

        Player player = null;
        if(p==null) {
            player = vm.createPlayer(callID, ps);
        } else {
            player = p;
        }

        call.setPlayer(player);
        player.setCall(call);

        vm.getVoiceManagerParameters().livePlayerAudioGroup.addPlayer(player,
                new AudioGroupPlayerInfo(true, AudioGroupPlayerInfo.ChatType.PUBLIC));

        AudioGroupPlayerInfo info =
                new AudioGroupPlayerInfo(false, AudioGroupPlayerInfo.ChatType.PUBLIC);

        info.defaultSpeakingAttenuation = 0;

        vm.getVoiceManagerParameters().stationaryPlayerAudioGroup.addPlayer(player, info);
    }
View Full Code Here

      + " volume " + volume + " other callID " + otherCallID);

        logger.fine("GOT Volume message:  call " + softphoneCallID
      + " volume " + volume + " other callID " + otherCallID);

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

        Player softphonePlayer = vm.getPlayer(softphoneCallID);

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

        if (softphoneCallID.equals(otherCallID)) {
      if (msg.isSetVolume() == false) {
    msg.setVolume(softphonePlayer.getMasterVolume());
    sender.send(clientID, msg);
    return;
      }

            softphonePlayer.setMasterVolume(volume);
            return;
        }

        Player player = vm.getPlayer(otherCallID);

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

  if (msg.isSetVolume() == false) {
      Spatializer spatializer = softphonePlayer.getPrivateSpatializer(player);
      msg.setVolume(spatializer.getAttenuator());
      sender.send(clientID, msg);
      logger.fine("Sending vol message " + msg.getVolume());
      return;
  }

  if (volume == 1.0) {
      softphonePlayer.removePrivateSpatializer(player);
      return;
  }

  VoiceManagerParameters parameters = vm.getVoiceManagerParameters();

        Spatializer spatializer;

  spatializer = player.getPublicSpatializer();
View Full Code Here

TOP

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

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.