public static int encodeParams(byte[] destination,int offset,EventName eventName) { if(eventName.getEventIdentifier().getParms()==null) return 0; destination[offset]=StringFunctions.OPEN_BRACKET_BYTE; byte[] paramsBytes=eventName.getEventIdentifier().getParms().getBytes(); System.arraycopy(paramsBytes, 0, destination, offset+1, paramsBytes.length); destination[offset+paramsBytes.length+1]=StringFunctions.CLOSE_BRACKET_BYTE; return paramsBytes.length+2; }
public static int encodeParams(byte[] destination,int offset,EventName eventName) { if(eventName.getEventIdentifier().getParms()==null) return 0; destination[offset]=StringFunctions.OPEN_BRACKET_BYTE; byte[] paramsBytes=eventName.getEventIdentifier().getParms().getBytes(); System.arraycopy(paramsBytes, 0, destination, offset+1, paramsBytes.length); destination[offset+paramsBytes.length+1]=StringFunctions.CLOSE_BRACKET_BYTE; return paramsBytes.length+2; }
public String encodeEventName(EventName e) { StringBuffer s = new StringBuffer(""); s.append(e.getPackageName().toString()).append('/').append(e.getEventIdentifier().getName()); if (e.getConnectionIdentifier() != null) { s.append(AMPERSAND).append(e.getConnectionIdentifier().toString()); } if (e.getEventIdentifier().getParms() != null) { s.append('(').append(e.getEventIdentifier().getParms()).append(')'); } return s.toString(); }
private void processNotify(Notify notify) { EventName[] events = notify.getObservedEvents(); for (EventName evt : events) { switch (evt.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION: fireEvent(evt.getEventIdentifier().getParms()); break; case MgcpEvent.REPORT_FAILURE: break; } } }
private int decodeDTMF(EventName observed) String eventName = observed.getEventIdentifier().getName(); if(Pattern.matches("\\d", eventName))
private int decodeDTMF(EventName observed) String eventName = observed.getEventIdentifier().getName(); if(Pattern.matches("\\d", eventName))
private void processNotify(Notify notify) { EventName[] events = notify.getObservedEvents(); for (EventName evt : events) { switch (evt.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION: fireEvent(evt.getEventIdentifier().getParms()); break; case MgcpEvent.REPORT_FAILURE: break; } } }
public static boolean isPartialNotify(EventName lastEvent){ final MgcpEvent event = lastEvent.getEventIdentifier(); final Map<String, String> parameters = MgcpUtil.parseParameters(event.getParms()); return NumberUtils.toInt(parameters.get("rc")) == RETURNCODE_PARTIAL; } }
public String encodeRequestedEvent(RequestedEvent evt) { StringBuffer s = new StringBuffer((evt.getEventName().getPackageName()).toString()).append("/").append( evt.getEventName().getEventIdentifier().getName()); if (evt.getEventName().getConnectionIdentifier() != null) { s.append(AMPERSAND).append(evt.getEventName().getConnectionIdentifier().toString()); } String parms = evt.getEventName().getEventIdentifier().getParms(); RequestedAction[] actions = evt.getRequestedActions(); if (actions != null) { String ac = encodeRequestedActions(actions); s.append(" (").append(ac).append(")"); } if (parms != null) { s.append(" (").append(parms).append(")"); } return s.toString(); }
public static int encode(byte[] destination,int offset,EventName eventName) { int totalLength=PackageNameHandler.encode(destination,offset,eventName.getPackageName()); destination[offset+totalLength]=StringFunctions.SLASH_BYTE; totalLength++; byte[] nameBytes=eventName.getEventIdentifier().getName().getBytes(); System.arraycopy(nameBytes, 0, destination, offset+totalLength, nameBytes.length); totalLength+=nameBytes.length; if(eventName.getConnectionIdentifier()!=null) { destination[offset+totalLength]=StringFunctions.AT_BYTE; totalLength++; byte[] connectionBytes=eventName.getConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionBytes, 0, destination, offset+totalLength, connectionBytes.length); totalLength+=connectionBytes.length; } return totalLength; }
public static int encode(byte[] destination,int offset,EventName eventName) { int totalLength=PackageNameHandler.encode(destination,offset,eventName.getPackageName()); destination[offset+totalLength]=StringFunctions.SLASH_BYTE; totalLength++; byte[] nameBytes=eventName.getEventIdentifier().getName().getBytes(); System.arraycopy(nameBytes, 0, destination, offset+totalLength, nameBytes.length); totalLength+=nameBytes.length; if(eventName.getConnectionIdentifier()!=null) { destination[offset+totalLength]=StringFunctions.AT_BYTE; totalLength++; byte[] connectionBytes=eventName.getConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionBytes, 0, destination, offset+totalLength, connectionBytes.length); totalLength+=connectionBytes.length; } return totalLength; }
private void send (final Object message, final ActorRef sender) { final JainMgcpCommandEvent command = (JainMgcpCommandEvent) message; final int transactionId = (int) transactionIdPool.get(); command.setTransactionHandle(transactionId); respond(message, sender); EventName[] events = null; if (message instanceof NotificationRequest) { final NotificationRequest rqnt = (NotificationRequest) message; events = rqnt.getSignalRequests(); if (events != null && events[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { recordingRqnt = rqnt; recordingRqntSender = sender(); } } if (events != null && !events[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { if (NotificationRequest.class.equals(command.getClass())) { final NotificationRequest request = (NotificationRequest) command; final String id = Long.toString(requestIdPool.get()); request.getRequestIdentifier().setRequestIdentifier(id); notify(request, sender); } } }
/** * Fires event. * * @param evt the event to be fired */ private void fireEvent(EventName eventName) { this.returnCode = eventName.getEventIdentifier().getParms(); switch (eventName.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION : try { fsm.signal(SIGNAL_PLAY_COMPLETED); } catch (UnknownTransitionException e) { e.printStackTrace(); } break; case MgcpEvent.REPORT_FAILURE : try { fsm.signal("FAILURE"); } catch (UnknownTransitionException e) { e.printStackTrace(); } break; } }
/** * Fires event. * * @param evt the event to be fired */ private void fireEvent(EventName eventName) { this.returnCode = eventName.getEventIdentifier().getParms(); switch (eventName.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION : try { fsm.signal(SIGNAL_PLAY_COMPLETED); } catch (UnknownTransitionException e) { e.printStackTrace(); } break; case MgcpEvent.REPORT_FAILURE : try { fsm.signal("FAILURE"); } catch (UnknownTransitionException e) { e.printStackTrace(); } break; } }
@Override protected void notify(Object message, ActorRef sender) { final ActorRef self = self(); final NotificationRequest request = (NotificationRequest) message; MgcpEvent event = null; if (request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("es") || request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { //Looks like this is either an RQNT AU/ES or //recording max length reached and we got the original recording RQNT event = AUMgcpEvent.auoc.withParm("AU/pr ri=file://" + recordingFile.toPath() + " rc=100 dc=1"); } else { event = AUMgcpEvent.auoc.withParm("rc=100 dc=1"); if(!request.getSignalRequests()[0].getEventIdentifier().getParms().contains("ringing.wav")) { try { Thread.sleep(2000); } catch (Exception e){ logger.error(e.toString()); } } } final EventName[] events = {new EventName(AUPackage.AU, event)}; final Notify notify = new Notify(this, request.getEndpointIdentifier(), request.getRequestIdentifier(), events); notify.setTransactionHandle((int) transactionIdPool.get()); System.out.println(notify.toString()); sender.tell(notify, self); } }
protected void notify (final Object message, final ActorRef sender) { final ActorRef self = self(); final NotificationRequest request = (NotificationRequest) message; MgcpEvent event = null; if (request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("es") || request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { //Looks like this is either an RQNT AU/ES or //recording max length reached and we got the original recording RQNT event = AUMgcpEvent.auoc.withParm("AU/pr ri=file://" + recordingFile.toPath() + " rc=100 dc=1"); } else { event = AUMgcpEvent.auoc.withParm("rc=100 dc=1"); } final EventName[] events = {new EventName(AUPackage.AU, event)}; final Notify notify = new Notify(this, request.getEndpointIdentifier(), request.getRequestIdentifier(), events); notify.setTransactionHandle((int) transactionIdPool.get()); System.out.println(notify.toString()); sender.tell(notify, self); }
switch (eventName.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION : Options options = new Options(eventName.getEventIdentifier().getParms()); switch (options.getReturnCode()) { case 100 :
switch (eventName.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION : Options options = new Options(eventName.getEventIdentifier().getParms()); switch (options.getReturnCode()) { case 100 :
public void onNotifyRequest(Notify event, ActivityContextInterface aci) { logger.info("onNotifyRequest"); NotificationRequestResponse response = new NotificationRequestResponse(event.getSource(), ReturnCode.Transaction_Executed_Normally); response.setTransactionHandle(event.getTransactionHandle()); mgcpProvider.sendMgcpEvents(new JainMgcpEvent[] { response }); EventName[] observedEvents = event.getObservedEvents(); for (EventName observedEvent : observedEvents) { switch (observedEvent.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION: logger.info("Announcemnet Completed NTFY received"); break; case MgcpEvent.REPORT_FAILURE: logger.info("Announcemnet Failed received"); // TODO : Send DLCX and Send BYE to UA break; default: //MGCP RI expects D/dtmfX, but correct is D/X ... hence it fails to match on //MgcpEvent.DTMF_X .... Thus event ID is wrong.... if(observedEvent.getPackageName().toString().equals("D")) { int decodedId = decodeDTMF(observedEvent); processDTMF(decodedId); } } } }
switch (observedEvent.getEventIdentifier().intValue()) { case MgcpEvent.REPORT_ON_COMPLETION: logger.info("Announcemnet Completed NTFY received");