Package com.sun.mpk20.voicelib.app

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


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


                logger.fine("Got AudioTreatmentRequestMessage, startTreatment="
        + msg.restartTreatment());

              String treatmentId = CallID.getCallID(cellID);

          Treatment treatment = null;

    treatment = AppContext.getManager(VoiceManager.class).getTreatment(treatmentId);

    if (treatment == null) {
        logger.warning("Can't find treatment " + treatmentId);
        return;
    }

    logger.fine("restart " + msg.restartTreatment() + " pause " + msg.isPaused());

    if (msg.restartTreatment()) {
        treatment.restart(msg.isPaused());
    } else {
        treatment.pause(msg.isPaused());
    }
                return;
            }

      if (message instanceof AudioVolumeMessage) {
View Full Code Here

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

          if (playWhen.equals(PlayWhen.FIRST_IN_RANGE)) {
              addProximityListener(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) {
View Full Code Here

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

      sender.send(response);
      return;
        }

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

        CallListing listing = msg.getCallListing();
             
  String externalCallID = getExternalCallID(listing);

  Call externalCall = vm.getCall(externalCallID);

  Player externalPlayer = null;

  if (externalCall != null) {
      externalPlayer = externalCall.getPlayer();
  }

  String softphoneCallID = listing.getSoftphoneCallID();

  Call softphoneCall = null;

  Player softphonePlayer = null;

  AudioGroup audioGroup = null;

  String audioGroupId = null;

  VoiceManagerParameters parameters = vm.getVoiceManagerParameters();

  if (softphoneCallID != null) {
      softphoneCall = vm.getCall(softphoneCallID);

      if (softphoneCall != null) {
          softphonePlayer = softphoneCall.getPlayer();
      }
       
      audioGroupId = softphoneCallID + "_" + externalCallID;

      audioGroup = vm.getAudioGroup(audioGroupId);
  }

  logger.fine("EXTERNAL CALLID IS " + externalCallID + " " + msg
      + " softphone callID " + softphoneCallID + " softphone call "
      + softphoneCall + " softphone player " + softphonePlayer);

  if (message instanceof PlayTreatmentMessage) {
      PlayTreatmentMessage m = (PlayTreatmentMessage) message;

      logger.fine("play treatment " + m.getTreatment()
    + " to " + listing.getExternalCallID() + " echo " + m.echo());

            if (listing.simulateCalls() == true) {
    return;
      }

      try {
    externalCall.playTreatment(m.getTreatment());
      } catch (IOException e) {
    logger.warning("Unable to play treatment to " + externalCall + ":  "
        + e.getMessage());
      }

      if (m.echo() == false) {
    return;
      }

      logger.fine("echoing treatment to " + softphoneCallID);

      try {
    softphoneCall.playTreatment(m.getTreatment());
      } catch (IOException e) {
    logger.warning("Unable to play treatment to " + softphoneCall + ":  "
        + e.getMessage());
    sender.send(clientID, new CallEndedResponseMessage(
                    phoneCellMO.getCellID(), listing, true, "Softphone is not connected!"));
                return;
      }

      return;
  }

  if (msg instanceof PlaceCallMessage) {
            //Our phone cell is asking us to begin a new call.

      if (listing.simulateCalls() == false) {
    relock(sender);
      }

      logger.fine("Got place call message " + externalCallID);

      PlayerSetup playerSetup = new PlayerSetup();
      //playerSetup.x =  translation.x;
      //playerSetup.y =  translation.y;
      //playerSetup.z =  translation.z;
      playerSetup.isOutworlder = true;
      playerSetup.isLivePlayer = true;

            if (listing.simulateCalls() == false) {
          PhoneStatusListener phoneStatusListener =
        new PhoneStatusListener(phoneCellMO, listing, clientID);

          if (softphoneCall == null || softphonePlayer == null) {
        logger.warning("Softphone player is not connected!");
                  sender.send(clientID, new CallEndedResponseMessage(
      phoneCellMO.getCellID(), listing, false,
      "Softphone is not connected!"));
        return;
          }

    CallSetup setup = new CallSetup();
 
    CallParticipant cp = new CallParticipant();

    setup.cp = cp;

    setup.externalOutgoingCall = true;

    try {
        setup.bridgeInfo = vm.getVoiceBridge();
     } catch (IOException e) {
        logger.warning("Unable to get voice bridge for call " + cp + ":  "
      + e.getMessage());
        return;
    }

    cp.setPhoneNumber(listing.getContactNumber());
    cp.setName(listing.getContactName());
    cp.setCallId(externalCallID);
    cp.setConferenceId(parameters.conferenceId);
    cp.setVoiceDetection(true);
    cp.setDtmfDetection(true);
    cp.setVoiceDetectionWhileMuted(true);
    cp.setHandleSessionProgress(true);

    try {
                    externalCall = vm.createCall(externalCallID, setup);
     } catch (IOException e) {
        logger.warning("Unable to create call " + cp + ":  "
      + e.getMessage());
        return;
    }

        externalPlayer = vm.createPlayer(externalCallID, playerSetup);

    externalCall.setPlayer(externalPlayer);

    externalPlayer.setCall(externalCall);

                if (listing.isPrivate()) {
        /*
         * Allow caller and callee to hear each other
         */
        AudioGroupSetup audioGroupSetup = new AudioGroupSetup();
        audioGroupSetup.spatializer = new FullVolumeSpatializer();

        audioGroup = vm.createAudioGroup(audioGroupId, audioGroupSetup);
        audioGroup.addPlayer(externalPlayer,
            new AudioGroupPlayerInfo(true,
            AudioGroupPlayerInfo.ChatType.EXCLUSIVE));
        audioGroup.addPlayer(softphonePlayer,
            new AudioGroupPlayerInfo(true,
            AudioGroupPlayerInfo.ChatType.EXCLUSIVE));
    } else {
        AudioGroup defaultLivePlayerAudioGroup =
            parameters.livePlayerAudioGroup;

        defaultLivePlayerAudioGroup.addPlayer(externalPlayer,
            new AudioGroupPlayerInfo(true,
            AudioGroupPlayerInfo.ChatType.PUBLIC));

        AudioGroup defaultStationaryPlayerAudioGroup =
            parameters.stationaryPlayerAudioGroup;

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

    logger.fine("done with audio groups");
            }
           
      if (externalCall != null) {
          externalCallID = externalCall.getId();
      }

      logger.fine("Setting actual call id to " + externalCallID);

      listing.setExternalCallID(externalCallID)// set actual call Id

            //Check implicit privacy settings
            if (listing.isPrivate()) {
                /** HARRISNOTE: We need our client name later in order to
                 * setup private spatializers. But because we didn't know
                 * our proper client name in the PhoneCell, we update the
                 * callListing now that we do.
                 **/
    listing.setPrivateClientName(externalCallID);

                /*
     * Set the call audio to whisper mode until the caller
     * chooses to join the call.
     */
                if (listing.simulateCalls() == false) {
                    //Mute the two participants to the outside world
                    logger.fine("attenuate other groups");
        softphonePlayer.attenuateOtherGroups(audioGroup, 0, 0);
                    logger.fine("back from attenuate other groups");
                }
            } else {
    Vector3f center = new Vector3f();

    phoneCellMO.getWorldBounds().getCenter(center);

          center.setY((float).5);

                new Orb(listing.getContactName(), listing.getContactName(),
        externalCallID, center, .1, listing.simulateCalls());
      }

            if (listing.simulateCalls() == false) {
                //Place the calls audio at the phones position
             Vector3f location = new Vector3f();

                location = phoneCellMO.getWorldTransform(null).getTranslation(location);

                externalPlayer.moved(location.x, location.y, location.z, 0);
            }
         
            /*
       * Send PLACE_CALL_RESPONSE message back to all the clients
       * to signal success.
       */
            sender.send(clientID, new PlaceCallResponseMessage(
    phoneCellMO.getCellID(), listing, true));

      logger.fine("back from notifying user");
      return;
  }

  if (msg instanceof JoinCallMessage) {
            //Our phone cell wants us to join the call into the world.
           
            if (listing.simulateCalls() == false) {
                //Stop any current ringing.
          try {
                    softphoneCall.stopTreatment("ring_tone.au");
          } catch (IOException e) {
        logger.fine("Unable to stop treatment to " + softphoneCall + ":  "
            + e.getMessage());
          }

    AudioGroup defaultLivePlayerAudioGroup = parameters.livePlayerAudioGroup;

    defaultLivePlayerAudioGroup.addPlayer(externalPlayer,
        new AudioGroupPlayerInfo(true,
        AudioGroupPlayerInfo.ChatType.PUBLIC));

    AudioGroup defaultStationaryPlayerAudioGroup = parameters.stationaryPlayerAudioGroup;

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

          softphonePlayer.attenuateOtherGroups(audioGroup,
        AudioGroup.DEFAULT_SPEAKING_ATTENUATION,
        AudioGroup.DEFAULT_LISTEN_ATTENUATION);

    audioGroup.removePlayer(externalPlayer);
    audioGroup.removePlayer(softphonePlayer);
          vm.removeAudioGroup(audioGroup);
            }
           
            listing.setPrivateClientName("");
             
            //Inform the PhoneCells that the call has been joined successfully
            sender.send(clientID, new JoinCallResponseMessage(
    phoneCellMO.getCellID(), listing, true));
           
      Vector3f center = new Vector3f();

      phoneCellMO.getWorldBounds().getCenter(center);

            center.setY((float).5);

            new Orb(listing.getContactName(), listing.getContactName(), externalCallID,
    center, .1, false);
      return;
  }

  if (msg instanceof EndCallMessage) {
      logger.fine("simulate is " + listing.simulateCalls()
    + " external call " + externalCall);

            if (listing.simulateCalls() == false) {
    relock(sender);

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

    if (audioGroup != null) {
              vm.removeAudioGroup(audioGroup);

                    if (listing.isPrivate()) {
            softphonePlayer.attenuateOtherGroups(audioGroup,
          AudioGroup.DEFAULT_SPEAKING_ATTENUATION,
              AudioGroup.DEFAULT_LISTEN_ATTENUATION);
View Full Code Here

            // this managed object
            bindingName = PlayerListener.class.getName() + "." + clientID.toString();
            AppContext.getDataManager().setBinding(bindingName, this);

            // add a call status listener for this call
            VoiceManager vm = AppContext.getManager(VoiceManager.class);
            vm.addCallStatusListener(this, callID.toString());
  }
View Full Code Here

            // mark ourself for update
            AppContext.getDataManager().markForUpdate(this);

            // find the player associated with this call
            VoiceManager vm = AppContext.getManager(VoiceManager.class);
      Player player = vm.getPlayer(callID);
      if (player == null) {
                // if the call is not yet established, just return here.
                // when the call is established, the listener will be added
                // below
          return;
View Full Code Here

           
            // mark ourself for update
            AppContext.getDataManager().markForUpdate(this);

            // clean up listeners
            VoiceManager vm = AppContext.getManager(VoiceManager.class);
            vm.removeCallStatusListener(this, callID);

            if (inRangeListener != null) {
                Player player = vm.getPlayer(callID);
                if (player == null) {
                    logger.warning("[PlayerListener] No player for " + callID);
                    return;
                }
           
View Full Code Here

      }
        }

        public void callStatusChanged(CallStatus status) {
            // find the player associated with this call
            VoiceManager vm = AppContext.getManager(VoiceManager.class);
      Player player = vm.getPlayer(callID);
      if (player == null) {
          logger.warning("[PlayerListener] No player for " + callID);
                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.