@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()); } }
@Override public String toString() { return "Local Connection [" + getEndpoint().getLocalName() + "]"; }
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(); } }
baseEndpoint = (BaseEndpointImpl) endpoint; } catch (ClassCastException e) { logger.error("Unsupported endpoint implementation " + endpoint.getLocalName()); return; baseEndpoint.setRtpManager(rtpManager); logger.info("Installing " + endpoint.getLocalName()); endpoint.start(); } catch (Exception e) { logger.error("Couldn't start endpoint " + endpoint.getLocalName(), e); return; namingService.register(endpoint); } catch (Exception e) { endpoint.stop(); logger.error("Could not register endpoint " + endpoint.getLocalName(), e); endpoints.put(endpoint.getLocalName(), endpoint);
/** * (Non Java-doc.) * * @throws ResourceUnavailableException */ public void install() { ClassLoader loader = Server.class.getClassLoader(); nameParser.setPattern(namePattern); while (nameParser.hasMore()) { String name = nameParser.next(); try { Constructor constructor = loader.loadClass(this.endpointClass).getConstructor(String.class); Endpoint endpoint = (Endpoint) constructor.newInstance(name); endpoint.setDspFactory(dspFactory); endpoint.setLocalConnections(localConnections); endpoint.setRtpConnections(rtpConnections); server.install(endpoint); } catch (Exception e) { server.logger.error("Couldn't instantiate endpoint", e); } } }
/** * 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); } }
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(); }
@Override public String toString() { return "RTP Connection [" + getEndpoint().getLocalName() ; }
/** * 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); } }