Search in sources :

Example 1 with PortMapping

use of org.fourthline.cling.support.model.PortMapping 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)

Aggregations

UpnpService (org.fourthline.cling.UpnpService)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