public void modify(final ConnectionDescriptor remoteDescriptor, final ConnectionMode connectionMode) throws MgcpConnectionException { final List<State> possibleStates = new ArrayList<State>(); possibleStates.add(HALF_OPEN); possibleStates.add(OPEN); assertState(possibleStates); // Make sure there is something to modify. if(remoteDescriptor == null && connectionMode == null) { return; } try { final CallIdentifier callId = new CallIdentifier(Integer.toString(session.getId())); final ModifyConnection mdcx = new ModifyConnection(this, callId, endpoint.getId(), connectionId); // Modify the remote session description. if(remoteDescriptor != null) { mdcx.setRemoteConnectionDescriptor(remoteDescriptor); } // Modify the connection mode. if(connectionMode != null) { mdcx.setMode(connectionMode); } server.sendCommand(mdcx, this); } catch(final MgcpServerException exception) { throw new MgcpConnectionException(exception); } }
command.setBearerInformation(utils.decodeBearerInformation(value)); } else if (name.equalsIgnoreCase("c")) { command.setCallIdentifier(new CallIdentifier(value)); } else if (name.equalsIgnoreCase("I")) { command.setConnectionIdentifier(new ConnectionIdentifier(value)); } else if (name.equalsIgnoreCase("m")) { command.setMode(utils.decodeConnectionMode(value)); } else if (name.equalsIgnoreCase("L")) { command.setLocalConnectionOptions(utils.decodeLocalOptionValueList(value)); } else if (name.equalsIgnoreCase("N")) { command.setNotifiedEntity(utils.decodeNotifiedEntity(value, true)); } else if (name.equalsIgnoreCase("X")) { command.setNotificationRequestParms(new NotificationRequestParms(new RequestIdentifier(value))); } else if (name.equalsIgnoreCase("R")) { command.getNotificationRequestParms().setRequestedEvents(utils.decodeRequestedEventList(value)); } else if (name.equalsIgnoreCase("S")) { command.getNotificationRequestParms().setSignalRequests(utils.decodeEventNames(value)); } else if (name.equalsIgnoreCase("T")) { command.getNotificationRequestParms().setDetectEvents(utils.decodeEventNames(value));
public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new ModifyConnection(source != null ? source : stack, new CallIdentifier("00"), endpoint,new ConnectionIdentifier("00")); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (IOException e) { logger.error("Decoding of MDCX command failed", e); } NotifiedEntity notifiedEntity = command.getNotifiedEntity(); if (command.getNotifiedEntity() != null) this.stack.provider.setNotifiedEntity(notifiedEntity); return command; }
ModifyConnection evt = (ModifyConnection) event; StringBuffer s = new StringBuffer(); s.append("MDCX ").append(evt.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( evt.getEndpointIdentifier()).append(SINGLE_CHAR_SPACE).append(MGCP_VERSION).append(NEW_LINE); s.append("C:").append(evt.getCallIdentifier()).append(NEW_LINE); s.append("I:").append(evt.getConnectionIdentifier()).append(NEW_LINE); if (evt.getBearerInformation() != null) { s.append("B:e:").append(evt.getBearerInformation()).append(NEW_LINE); if (evt.getLocalConnectionOptions() != null) { s.append("L:").append(utils.encodeLocalOptionValueList(evt.getLocalConnectionOptions())); if (evt.getMode() != null) { s.append("M:").append(evt.getMode()).append(NEW_LINE); if (evt.getNotificationRequestParms() != null) { s.append(utils.encodeNotificationRequestParms(evt.getNotificationRequestParms())); if (evt.getNotifiedEntity() != null) { s.append("N:").append(evt.getNotifiedEntity()).append(NEW_LINE); if (evt.getRemoteConnectionDescriptor() != null) { s.append(NEW_LINE).append(evt.getRemoteConnectionDescriptor());
/** * Receive notification of the header of a message. Parser will call * this method to report about header reading. * * @param header * the header from the message. */ public void header(String header) throws ParseException { command = new ModifyConnection(source != null ? source : stack, new CallIdentifier("00"), endpoint, new ConnectionIdentifier("00")); command.setTransactionHandle(remoteTID); }
public void process(State state) { //prepear callID and endpointID parameters for request CallIdentifier callId = connection.getMediaSession().getCallID(); EndpointIdentifier endpointID = connection.getEndpoint().getIdentifier(); ConnectionIdentifier connectionID = connection.getConnectionID(); //ask for new unique transaction handler int txHandle = connection.getMediaSession().getUniqueHandler(); ModifyConnection req = new ModifyConnection(this, callId, endpointID, connectionID); req.setMode(ConnectionMode.Confrnce); req.setTransactionHandle(txHandle); try { req.setRemoteConnectionDescriptor(new ConnectionDescriptor(connection.sdpPortManager.remoteSdp.toString())); } catch (Exception e) { } //send request connection.getMediaSession().getDriver().attach(txHandle, new ModifyConnectionResponseHandler(connection)); connection.getMediaSession().getDriver().send(req); }
ModifyConnection mdcx = new ModifyConnection(this, containers[0].session.getCallID(), containers[0].endpoint.getIdentifier(), connections[0]); mdcx.setMode(mode0); mdcx.setTransactionHandle(txID); mdcx.setLocalConnectionOptions(new LocalOptionValue[]{currExtention}); ConnectionMode mode1 = getMode1(containers[1]); mdcx = new ModifyConnection(this, containers[1].session.getCallID(), containers[1].endpoint.getIdentifier(), connections[1]); mdcx.setMode(mode1); mdcx.setTransactionHandle(txID); mdcx.setLocalConnectionOptions(new LocalOptionValue[]{currExtention});
private void modifyConnection (final Object message, final ActorRef sender) { final ActorRef self = self(); final ModifyConnection mdcx = (ModifyConnection) message; System.out.println("MDCX: \n" + mdcx.toString()); if (logger.isInfoEnabled()) { String msg = String.format("Got MDCX for endpoint %s connId %s, mdcx: \n%s", mdcx.getEndpointIdentifier().getLocalEndpointName(), mdcx.getConnectionIdentifier(), mdcx); logger.info(msg); SessionDescription sessionDescription = null; boolean isNonValidSdp = false; if (mdcx.getRemoteConnectionDescriptor() != null) { try { sessionDescription = SdpFactory.getInstance().createSessionDescription(mdcx.getRemoteConnectionDescriptor().toString()); isNonValidSdp = sessionDescription.getSessionName().getValue().contains("NonValidSDP"); } catch (SdpParseException e) { code = ReturnCode.Protocol_Error; final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); final ConnectionDescriptor descriptor = new ConnectionDescriptor(sdp); response.setLocalConnectionDescriptor(descriptor); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString());
@Override public void execute(final Object message) throws Exception { final UpdateLink request = (UpdateLink) message; final String sessionId = Integer.toString(session.id()); final CallIdentifier callId = new CallIdentifier(sessionId); ModifyConnection mdcx = null; switch (request.type()) { case PRIMARY: { mdcx = new ModifyConnection(source, callId, primaryEndpointId, primaryConnId); } case SECONDARY: { mdcx = new ModifyConnection(source, callId, secondaryEndpointId, secondaryConnId); } } final ConnectionMode mode = request.mode(); if (mode != null) { mdcx.setMode(mode); } gateway.tell(mdcx, source); // Make sure we don't wait for a response indefinitely. getContext().setReceiveTimeout(Duration.create(timeout, TimeUnit.MILLISECONDS)); } }
/** * Receive notification of the session description. Parser will call * this method to report about session descriptor reading. * * @param sd * the session description from message. */ public void sessionDescription(String sd) throws ParseException { command.setRemoteConnectionDescriptor(new ConnectionDescriptor(sd)); } }
return; case SuccessResponse: if (this.endpointId.equals(mcRequest.getEndpointIdentifier().toString())) { if (mcRequest.getNotificationRequestParms() != null) { processRequestedEvents(mcRequest.getNotifiedEntity(), mcRequest.getNotificationRequestParms() .getRequestedEvents());
private void modifyConnection(final Object message, final ActorRef sender) { final ActorRef self = self(); final ModifyConnection mdcx = (ModifyConnection) message; System.out.println(mdcx.toString()); ReturnCode code; SessionDescription sessionDescription = null; boolean isNonValidSdp = false; if (mdcx.getRemoteConnectionDescriptor()!=null) { try { sessionDescription = SdpFactory.getInstance().createSessionDescription(mdcx.getRemoteConnectionDescriptor().toString()); isNonValidSdp = sessionDescription.getSessionName().getValue().contains("NonValidSDP"); } catch (SdpParseException e) { code = ReturnCode.Protocol_Error; final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); final ConnectionDescriptor descriptor = new ConnectionDescriptor(sdp); response.setLocalConnectionDescriptor(descriptor); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString());
totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length); byte[] callBytes=evt.getCallIdentifier().toString().getBytes(); System.arraycopy(callBytes, 0, array,totalLength, callBytes.length); totalLength+=callBytes.length; byte[] connectionIdentifierBytes=evt.getConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionIdentifierBytes, 0, array,totalLength, connectionIdentifierBytes.length); totalLength+=connectionIdentifierBytes.length; if (evt.getBearerInformation() != null) totalLength+=BearerInformationHandler.encode(array,totalLength,evt.getBearerInformation()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getLocalConnectionOptions() != null) totalLength+=LocalOptionValueHandler.encodeList(array,totalLength,evt.getLocalConnectionOptions()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getMode() != null) totalLength+=ConnectionModeHandler.encode(array,totalLength,evt.getMode()); array[totalLength++]=StringFunctions.NEWLINE_BYTE;
public void process(State state) { //prepear callID and endpointID parameters for request CallIdentifier callId = connection.getMediaSession().getCallID(); EndpointIdentifier endpointID = connection.getEndpoint().getIdentifier(); ConnectionIdentifier connectionID = connection.getConnectionID(); //ask for new unique transaction handler int txHandle = connection.getMediaSession().getUniqueHandler(); ModifyConnection req = new ModifyConnection(this, callId, endpointID, connectionID); req.setMode(ConnectionMode.Confrnce); req.setTransactionHandle(txHandle); try { req.setRemoteConnectionDescriptor(new ConnectionDescriptor(connection.sdpPortManager.remoteSdp.toString())); } catch (Exception e) { } //send request connection.getMediaSession().getDriver().attach(txHandle, new ModifyConnectionResponseHandler(connection)); connection.getMediaSession().getDriver().send(req); }
ModifyConnection mdcx = new ModifyConnection(this, containers[0].session.getCallID(), containers[0].endpoint.getIdentifier(), connections[0]); mdcx.setMode(mode0); mdcx.setTransactionHandle(txID); mdcx.setLocalConnectionOptions(new LocalOptionValue[]{currExtention}); ConnectionMode mode1 = getMode1(containers[1]); mdcx = new ModifyConnection(this, containers[1].session.getCallID(), containers[1].endpoint.getIdentifier(), connections[1]); mdcx.setMode(mode1); mdcx.setTransactionHandle(txID); mdcx.setLocalConnectionOptions(new LocalOptionValue[]{currExtention});
/** * Receive notification of the session description. Parser will call * this method to report about session descriptor reading. * * @param sd * the session description from message. */ public void sessionDescription(String sd) throws ParseException { command.setRemoteConnectionDescriptor(new ConnectionDescriptor(sd)); } }
totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length); byte[] callBytes=evt.getCallIdentifier().toString().getBytes(); System.arraycopy(callBytes, 0, array,totalLength, callBytes.length); totalLength+=callBytes.length; byte[] connectionIdentifierBytes=evt.getConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionIdentifierBytes, 0, array,totalLength, connectionIdentifierBytes.length); totalLength+=connectionIdentifierBytes.length; if (evt.getBearerInformation() != null) totalLength+=BearerInformationHandler.encode(array,totalLength,evt.getBearerInformation()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getLocalConnectionOptions() != null) totalLength+=LocalOptionValueHandler.encodeList(array,totalLength,evt.getLocalConnectionOptions()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getMode() != null) totalLength+=ConnectionModeHandler.encode(array,totalLength,evt.getMode()); array[totalLength++]=StringFunctions.NEWLINE_BYTE;
command.setBearerInformation(BearerInformationHandler.decode(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_C_BYTE: case StringFunctions.HIGH_C_BYTE: command.setCallIdentifier(new CallIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_I_BYTE: case StringFunctions.HIGH_I_BYTE: command.setConnectionIdentifier(new ConnectionIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_M_BYTE: case StringFunctions.HIGH_M_BYTE: command.setMode(ConnectionModeHandler.decode(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_L_BYTE: case StringFunctions.HIGH_L_BYTE: command.setLocalConnectionOptions(LocalOptionValueHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_N_BYTE: case StringFunctions.HIGH_N_BYTE: command.setNotifiedEntity(NotifiedEntityHandler.decode(data,value.getOffset(),value.getLength(), true)); break; case StringFunctions.LOW_X_BYTE: case StringFunctions.HIGH_X_BYTE: command.setNotificationRequestParms(new NotificationRequestParms(new RequestIdentifier(new String(data,value.getOffset(),value.getLength())))); break; case StringFunctions.LOW_R_BYTE: case StringFunctions.HIGH_R_BYTE: command.getNotificationRequestParms().setRequestedEvents(RequestedEventHandler.decodeList(data,value.getOffset(),value.getLength()));
@Override public void execute(final Object message) throws Exception { final UpdateConnection request = (UpdateConnection) message; final String sessionId = Integer.toString(session.id()); final CallIdentifier callId = new CallIdentifier(sessionId); requestedConnId = request.connectionIdentifier(); requestedConnId = requestedConnId==null ? connId:requestedConnId; final ModifyConnection mdcx = new ModifyConnection(source, callId, endpointId, requestedConnId); final ConnectionMode mode = request.mode(); if (mode != null) { mdcx.setMode(mode); } final ConnectionDescriptor descriptor = request.descriptor(); if (descriptor != null) { mdcx.setRemoteConnectionDescriptor(descriptor); remoteDesc = descriptor; } gateway.tell(mdcx, source); // Make sure we don't wait for a response indefinitely. getContext().setReceiveTimeout(Duration.create(timeout, TimeUnit.MILLISECONDS)); } }
public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new ModifyConnection(source != null ? source : stack, new CallIdentifier("00"), endpoint,new ConnectionIdentifier("00")); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (IOException e) { logger.error("Decoding of MDCX command failed", e); } NotifiedEntity notifiedEntity = command.getNotifiedEntity(); if (command.getNotifiedEntity() != null) this.stack.provider.setNotifiedEntity(notifiedEntity); return command; }