예제 #1
0
 /**
  * {@inheritDoc}
  *
  * <p>This implementation uses {@link SynthesizedOutput#getUriForNextSynthesisizedOutput()} to
  * obtain a URI that is being used to stream to the terminal.
  *
  * <p>Although this terminal is the source where to stream the audio this implementation makes no
  * assumptions about the URI. In most cases this will be related to the {@link SpokenInput}
  * implementation. In the simplest case this implementation <emph>invents</emph> a unique URI.
  */
 public void play(final SynthesizedOutput output, final CallControlProperties props)
     throws NoresourceError, IOException {
   try {
     if (terminal == null) {
       throw new NoresourceError("No active telephony connection!");
     }
     URI uri = null;
     try {
       LOGGER.debug("status of the terminal " + terminal);
       // checking termnal status before play
       if ((terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY
               || terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY_COLLECT
               || terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY_RECORD)
           && terminal.getIVREndPointState() != MgcpIvrEndpoint.STOP) {
         LOGGER.debug("canceling current playing....  ");
         //                    terminal.stopMedia();
       }
       uri = output.getUriForNextSynthesisizedOutput();
     } catch (URISyntaxException e) {
       throw new IOException(e.getMessage(), e);
     }
     LOGGER.debug("playing URI '" + uri + "'" + " CallControlProperties: " + props);
     terminal.play(uri, 1);
     terminal.addObserver((MobicentsSynthesizedOutput) output);
     //            terminal.play(new
     // URI("http://192.168.146.146:8080/VNXIVR/audio/dtmf_welcome.wav"), 1);
     //            Thread.sleep(10000);
   } catch (Exception ex) {
     ExLog.exception(LOGGER, ex);
   }
 }
예제 #2
0
 /** @param call @Override */
 public void onStatusChanged(Call call) {
   try {
     MgcpCallTerminal term = (MgcpCallTerminal) call;
     LOGGER.debug(" for CallControlProperties:" + props + " " + call.toString());
     if ((Call.Status.COMPLETED == call.getStatus() || Call.Status.IN_PROGRESS == call.getStatus())
         && term.getIVREndPointState() == MgcpIvrEndpoint.IDLE
         && (term.getIVREndPointOldState() == MgcpIvrEndpoint.PLAY
             || term.getIVREndPointOldState() == MgcpIvrEndpoint.PLAY_COLLECT
             || term.getIVREndPointOldState() == MgcpIvrEndpoint.PLAY_RECORD)) {
       JVoiceXmlRecordResult result = new JVoiceXmlRecordResult();
       long duration = (long) props.getGenProperties(JVoiceXmlRecordResult.DURATION);
       result.setDuration(duration);
       if (duration >= JVoiceXmlRecordResult.DEFAULT_RECORDING_MAXTIME) result.setMAXTIME("true");
       else result.setMAXTIME("false");
       result.setTermchar((String) props.getGenProperties(JVoiceXmlRecordResult.TERMCHAR));
       result.setSize(-1);
       final JVoiceXMLEvent event = new RecordingEvent(null);
       ((RecordingEvent) event).setInputResult(result);
       EventHandler handler = (EventHandler) props.getGenProperties("EventHandler");
       handler.notifyEvent(event);
     }
   } catch (Exception ex) {
     ExLog.exception(LOGGER, ex);
   }
 }