Search in sources :

Example 1 with UpnpService

use of org.fourthline.cling.UpnpService in project libresonic by Libresonic.

the class ClingRouter method findConnectionService.

/**
     * Returns the UPnP service used for port mapping.
     */
private static Service findConnectionService(UpnpService upnpService) {
    class ConnectionServiceDiscoverer extends PortMappingListener {

        ConnectionServiceDiscoverer() {
            super(new PortMapping[0]);
        }

        @Override
        public Service discoverConnectionService(Device device) {
            return super.discoverConnectionService(device);
        }
    }
    ConnectionServiceDiscoverer discoverer = new ConnectionServiceDiscoverer();
    Collection<Device> devices = upnpService.getRegistry().getDevices();
    for (Device device : devices) {
        Service service = discoverer.discoverConnectionService(device);
        if (service != null) {
            return service;
        }
    }
    return null;
}
Also used : Device(org.fourthline.cling.model.meta.Device) UPnPService(org.libresonic.player.service.UPnPService) UpnpService(org.fourthline.cling.UpnpService) Service(org.fourthline.cling.model.meta.Service) PortMapping(org.fourthline.cling.support.model.PortMapping) PortMappingListener(org.fourthline.cling.support.igd.PortMappingListener)

Example 2 with UpnpService

use of org.fourthline.cling.UpnpService in project SmartApplianceEnabler by camueller.

the class SempDiscovery method run.

public void run() {
    try {
        final ExecutorService executorService = Executors.newSingleThreadExecutor();
        final UpnpService upnpService = new UpnpServiceImpl(serviceConfiguration);
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                upnpService.shutdown();
            }
        });
        // Add the bound local device to the registry
        upnpService.getRegistry().addDevice(createDevice());
    } catch (Exception ex) {
        System.err.println("Exception occured: " + ex);
        ex.printStackTrace(System.err);
        System.exit(1);
    }
}
Also used : UpnpService(org.fourthline.cling.UpnpService) UpnpServiceImpl(org.fourthline.cling.UpnpServiceImpl) ExecutorService(java.util.concurrent.ExecutorService) IOException(java.io.IOException) ValidationException(org.fourthline.cling.model.ValidationException) LocalServiceBindingException(org.fourthline.cling.binding.LocalServiceBindingException)

Aggregations

UpnpService (org.fourthline.cling.UpnpService)2 IOException (java.io.IOException)1 ExecutorService (java.util.concurrent.ExecutorService)1 UpnpServiceImpl (org.fourthline.cling.UpnpServiceImpl)1 LocalServiceBindingException (org.fourthline.cling.binding.LocalServiceBindingException)1 ValidationException (org.fourthline.cling.model.ValidationException)1 Device (org.fourthline.cling.model.meta.Device)1 Service (org.fourthline.cling.model.meta.Service)1 PortMappingListener (org.fourthline.cling.support.igd.PortMappingListener)1 PortMapping (org.fourthline.cling.support.model.PortMapping)1 UPnPService (org.libresonic.player.service.UPnPService)1