public EndpointName(String fqn) { parse(fqn); }
/** * Creates switch executor for specified mode. * * @param mode the mode value. * @return switch executor * @throws ModeNotSupportedException */ protected Mode convert(ConnectionMode mode) throws ModeNotSupportedException { switch (mode) { case RECV_ONLY: return recvOnly; case SEND_ONLY: return sendOnly; case SEND_RECV: return send_recv; case CONFERENCE: return cnfMode; case NETWORK_LOOPBACK: return network_loop; case INACTIVE: return null; default: throw new ModeNotSupportedException(mode); } }
private Endpoint lookupAny(boolean exclusive) throws ResourceUnavailableException { for (int i = 0; i < queue.size(); i++) { if (queue.get(i).getState() == EndpointState.READY) { Endpoint endpoint = queue.remove(i); queue.add(endpoint); return endpoint; } } throw new ResourceUnavailableException(); } }
/** * (Non Java-doc.) * * @see org.mobicents.media.server.spi.Endpoint#createConnection(org.mobicents.media.server.spi.ConnectionMode); */ public Connection createConnection(ConnectionType type,boolean isLocal) throws TooManyConnectionsException, ResourceUnavailableException { BaseConnection connection = (BaseConnection) connections.createConnection(type); connection.setIsLocal(isLocal); try { connection.bind(); } catch (Exception e) { e.printStackTrace(); throw new ResourceUnavailableException(e.getMessage()); } return connection; }
@Override public void start() throws IllegalStateException { if (this.started) { throw new IllegalStateException("Media Server already started"); } // Validate mandatory dependencies if (clock == null) { log.error("Timing clock is not defined"); return; } // Start Media Server this.started = true; for (ServerManager controller : managers.values()) { log.info("Activating controller " + controller.getControlProtocol().name()); controller.activate(); } if (heartbeatTime > 0) { heartbeat = new HeartBeat(); heartbeat.restart(); } }
public static Endpoint lookup(String name) throws NamingException, ResourceUnavailableException { if (name.endsWith("$")) { return findAny(name); } else { return find(name); } /* if (Pattern.matches(trunkNameRegex, name)) { name = name.substring(0, name.indexOf("/$")); return findAny(name); } else if (Pattern.matches(exactNameRegex, name)) { return find(name); } else { throw new ResourceUnavailableException("Name: " + name + " is neither trunk name nor an endpoint name!!!"); } */ } }
/** * Uninstalls the endpoint. * * @param name the local name of the endpoint to be uninstalled */ public void uninstalls(String name) { //unregister localy Endpoint endpoint = endpoints.remove(name); //send notification to manager for (ServerManager manager : managers) { manager.onStarted(endpoint); } try { //TODO: lookup irrespective of endpoint usage endpoint = namingService.lookup(name, true); if (endpoint != null) { endpoint.stop(); namingService.unregister(endpoint); } } catch (Exception e) { logger.error(e); } }
@Override public String toString() { return "Local Connection [" + getEndpoint().getLocalName() + "]"; }
public ConnectionException(Connection connection, Throwable t) { super(t.getMessage()); this.initCause(t); this.connection = connection; } }
/** * Uninstalls endpoint defined by specified endpoint installer. * * @param installer the endpoints installer. */ public void removeInstaller(EndpointInstaller installer) { installers.remove(installer); installer.uninstall(); }
public void setRelayType(String relayType) { if(relayType == null) { throw new IllegalArgumentException("Relay Type cannot be undefined."); } this.relayType = RelayType.fromName(relayType); }
@Override public void addManager(ServerManager manager) { managers.put(manager.getControlProtocol(), manager); }
/** * Installs endpoints defined by specified installer. * * @param installer the endpoints installer */ public void addInstaller(EndpointInstaller installer) { ((VirtualEndpointInstaller)installer).setServer(this); installers.add(installer); installer.install(); }
@Override public void setOtherParty(Connection other) throws IOException { if (!(other instanceof RtpConnectionImpl)) { throw new IOException("Incompatible connections"); } RtpConnectionImpl otherConnection = (RtpConnectionImpl) other; try { setOtherParty(otherConnection.getEndpoint().describe(MediaType.AUDIO).getBytes()); } catch (Exception e) { throw new IOException(e.getMessage()); } }
private ConnectionMode loadConnectionMode(Parameters<MgcpParameterType> parameters) throws MgcpCommandException { Optional<String> mode = parameters.getString(MgcpParameterType.MODE); try { if (!mode.isPresent()) { throw new MgcpCommandException(MgcpResponseCode.INVALID_OR_UNSUPPORTED_MODE); } else { return ConnectionMode.fromDescription(mode.get()); } } catch (IllegalArgumentException e) { throw new MgcpCommandException(MgcpResponseCode.INVALID_OR_UNSUPPORTED_MODE); } }
@Override protected void onFailed() { if(this.connectionFailureListener!=null) connectionFailureListener.onFailure(); if (rtpAudioChannel != null) { audioChannel.disconnect(); rtpAudioChannel.close(); } if (rtpVideoChannel != null) { videoChannel.disconnect(); rtpVideoChannel.close(); } }
@Override public String toString() { return "RTP Connection [" + getEndpoint().getLocalName() ; }
private Endpoint lookupConcrete(String id) throws UnknownEndpointException { for (int i = 0; i < queue.size(); i++) { if (queue.get(i).getLocalName().endsWith(id)) return queue.get(i); } throw new UnknownEndpointException(); }
/** * Registers endpoint. * After registration the endpoint can be looked up using its name. * * @param endpoint the endpoint to be registered. */ public void register(Endpoint endpoint) { synchronized(LOCK) { EndpointName name = new EndpointName(endpoint.getLocalName()); Node node = getNode(name.getCategory(), true); node.queue.add(endpoint); } }
/** * Unregisters endpoint. * Unregistered endpoint is not longer visible for lookups. * * @param endpoint the endpoint to be unregistered. */ public void unregister(Endpoint endpoint) { synchronized(LOCK) { EndpointName name = new EndpointName(endpoint.getLocalName()); Node node = getNode(name.getCategory(), true); node.queue.remove(endpoint); } }