org.fourthline.cling.UpnpServiceImpl Java Examples

The following examples show how to use org.fourthline.cling.UpnpServiceImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UPnPService.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
private synchronized void createService() throws Exception {
    upnpService = new UpnpServiceImpl(new ApacheUpnpServiceConfiguration());

    // Asynch search for other devices (most importantly UPnP-enabled routers for port-mapping)
    upnpService.getControlPoint().search();

    // Start DLNA media server?
    setMediaServerEnabled(settingsService.isDlnaEnabled());

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            System.err.println("Shutting down UPnP service...");
            upnpService.shutdown();
            System.err.println("Shutting down UPnP service - Done!");
        }
    });
}
 
Example #2
Source File: ClingRouterFactory.java    From portmapper with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<IRouter> findRoutersInternal() throws RouterException {
    final UpnpServiceConfiguration config = new DefaultUpnpServiceConfiguration();
    final ClingRegistryListener clingRegistryListener = new ClingRegistryListener();
    final UpnpService upnpService = new UpnpServiceImpl(config, clingRegistryListener);
    shutdownServiceOnExit(upnpService);

    final UpnpHeader<?> searchType = new UDADeviceTypeHeader(ClingRegistryListener.IGD_DEVICE_TYPE);
    log.info("Start searching {} for device type {}", DISCOVERY_TIMEOUT, searchType);
    upnpService.getControlPoint().search(searchType, (int) DISCOVERY_TIMEOUT.toSeconds());
    return clingRegistryListener
            .waitForServiceFound(DISCOVERY_TIMEOUT) //
            .map(service -> (RemoteService) service)
            .map(service -> createRouter(service, upnpService)) //
            .collect(toList());
}
 
Example #3
Source File: AndroidUpnpServiceImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Starts the UPnP service.
 */
@Override
public void onCreate() {
    super.onCreate();

    upnpService = new UpnpServiceImpl(createConfiguration()) {

        @Override
        protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return AndroidUpnpServiceImpl.this.createRouter(
                getConfiguration(),
                protocolFactory,
                AndroidUpnpServiceImpl.this
            );
        }

        @Override
        public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
Example #4
Source File: AndroidUpnpServiceImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Starts the UPnP service.
 */
@Override
public void onCreate() {
    super.onCreate();

    upnpService = new UpnpServiceImpl(createConfiguration()) {

        @Override
        protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return AndroidUpnpServiceImpl.this.createRouter(
                getConfiguration(),
                protocolFactory,
                AndroidUpnpServiceImpl.this
            );
        }

        @Override
        public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
Example #5
Source File: UpnpPortMappingServicesRegistrar.java    From bt with Apache License 2.0 4 votes vote down vote up
/**
 * Creates corresponding UPNP serive for port mapping.
 *
 * @param portMapping desired port mapping;
 */
public void registerPortMapping(PortMapping portMapping) {
    final UpnpService service = new UpnpServiceImpl(upnpServiceConfiguration, new PortMappingListener(portMapping));
    service.getControlPoint().search();
    bindShutdownHook(service);
}
 
Example #6
Source File: UPnPService.java    From airsonic-advanced with GNU General Public License v3.0 3 votes vote down vote up
private synchronized void createService() {
    upnpService = new UpnpServiceImpl(new ApacheUpnpServiceConfiguration(settingsService.getUPnpPort()));

    // Asynch search for other devices (most importantly UPnP-enabled routers for port-mapping)
    upnpService.getControlPoint().search();

}
 
Example #7
Source File: UPnPService.java    From airsonic with GNU General Public License v3.0 3 votes vote down vote up
private synchronized void createService() {
    upnpService = new UpnpServiceImpl(new ApacheUpnpServiceConfiguration(SettingsService.getDefaultUPnPPort()));

    // Asynch search for other devices (most importantly UPnP-enabled routers for port-mapping)
    upnpService.getControlPoint().search();

}