コード例 #1
0
    public void onEvent(PlayerEvent event) {

      Player player = event.getSource();
      MediaGroup mg = player.getContainer();
      if (!isBye) {
        if (event.isSuccessful() && (PlayerEvent.PLAY_COMPLETED == event.getEventType())) {

          MediaSession mediaSession = event.getSource().getMediaSession();

          SipSession sipSession = (SipSession) mediaSession.getAttribute("SIP_SESSION");

          sipSession.setAttribute("MEDIA_GROUP", mg);

          SipApplicationSession sipAppSession = sipSession.getApplicationSession();

          try {
            Recorder recoredr = mg.getRecorder();
            logger.info("recording the user at " + RECORDER);
            URI prompt = URI.create(RECORDER);

            recoredr.record(prompt, null, null);

            TimerService timer = (TimerService) getServletContext().getAttribute(TIMER_SERVICE);
            timer.createTimer(sipAppSession, RECORDING_DELAY, false, sipSession.getId());

          } catch (MsControlException e) {
            logger.error("An unexpected error happened ", e);
          }
        } else {
          logger.error("Player didn't complete successfully ");
        }
      }
    }
コード例 #2
0
 @Override
 protected void doBye(SipServletRequest request) throws ServletException, IOException {
   MediaGroup mediaGroup = (MediaGroup) request.getSession().getAttribute("MEDIA_GROUP");
   if (mediaGroup != null) {
     logger.info("Bye received, stopping the recording");
     try {
       mediaGroup.getRecorder().stop();
     } catch (MsControlException e) {
       logger.info("recording couldn't be stopped", e);
     }
   }
   super.doBye(request);
 }
コード例 #3
0
  public void timeout(ServletTimer servletTimer) {

    String sessionId = (String) servletTimer.getInfo();
    logger.info("Timer fired on sip session " + sessionId);
    SipSession sipSession = servletTimer.getApplicationSession().getSipSession(sessionId);

    if (sipSession != null) {
      MediaGroup mediaGroup = (MediaGroup) sipSession.getAttribute("MEDIA_GROUP");
      if (mediaGroup != null) {
        logger.info("Timer fired, stopping the recording");
        try {
          mediaGroup.getRecorder().stop();
        } catch (MsControlException e) {
          logger.info("recording couldn't be stopped", e);
        }
      }
    } else {
      logger.info("the session has not been found, it may have been already invalidated");
    }
  }