org.fourthline.cling.model.meta.RemoteDevice Java Examples

The following examples show how to use org.fourthline.cling.model.meta.RemoteDevice. 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: DevicesActivity.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
	Log.e("DeviceListRegistryListener",
			"remoteDeviceAdded:" + device.toString()
					+ device.getType().getType());

	if (device.getType().getNamespace().equals("schemas-upnp-org")
			&& device.getType().getType().equals("MediaServer")) {
		final DeviceItem display = new DeviceItem(device, device
				.getDetails().getFriendlyName(),
				device.getDisplayString(), "(REMOTE) "
						+ device.getType().getDisplayString());
		deviceAdded(display);
	}

	if (device.getType().getNamespace().equals("schemas-upnp-org")
			&& device.getType().getType().equals("MediaRenderer")) {
		final DeviceItem dmrDisplay = new DeviceItem(device, device
				.getDetails().getFriendlyName(),
				device.getDisplayString(), "(REMOTE) "
						+ device.getType().getDisplayString());
		dmrAdded(dmrDisplay);
	}
}
 
Example #2
Source File: RegistryImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
synchronized public boolean notifyDiscoveryStart(final RemoteDevice device) {
    // Exit if we have it already, this is atomic inside this method, finally
    if (getUpnpService().getRegistry().getRemoteDevice(device.getIdentity().getUdn(), true) != null) {
        log.finer("Not notifying listeners, already registered: " + device);
        return false;
    }
    for (final RegistryListener listener : getListeners()) {
        getConfiguration().getRegistryListenerExecutor().execute(
                new Runnable() {
                    public void run() {
                        listener.remoteDeviceDiscoveryStarted(RegistryImpl.this, device);
                    }
                }
        );
    }
    return true;
}
 
Example #3
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
synchronized public boolean notifyDiscoveryStart(final RemoteDevice device) {
    // Exit if we have it already, this is atomic inside this method, finally
    if (getUpnpService().getRegistry().getRemoteDevice(device.getIdentity().getUdn(), true) != null) {
        log.finer("Not notifying listeners, already registered: " + device);
        return false;
    }
    for (final RegistryListener listener : getListeners()) {
        getConfiguration().getRegistryListenerExecutor().execute(
                new Runnable() {
                    public void run() {
                        listener.remoteDeviceDiscoveryStarted(RegistryImpl.this, device);
                    }
                }
        );
    }
    return true;
}
 
Example #4
Source File: DLNARouteProvider.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
private void deviceRemoved(Device device) {
	if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) {
		final String id = device.getIdentity().getUdn().toString();
		removing.add(id);

		// Delay removal for a few seconds to make sure that it isn't just a temp disconnect
		dlnaService.getControlPoint().search();
		downloadService.postDelayed(new Runnable() {
			@Override
			public void run() {
				if(removing.contains(id)) {
					devices.remove(id);
					removing.remove(id);
					broadcastDescriptors();
				}
			}
		}, 5000L);
	}
}
 
Example #5
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #6
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #7
Source File: BrowserActivity.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void remoteDeviceDiscoveryFailed(Registry registry, final RemoteDevice device,
        final Exception ex) {
    runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(
                    BrowserActivity.this,
                    "Discovery failed of '"
                            + device.getDisplayString()
                            + "': "
                            + (ex != null ? ex.toString()
                                    : "Couldn't retrieve device/service descriptors"),
                    Toast.LENGTH_LONG).show();
        }
    });
    deviceRemoved(device);
}
 
Example #8
Source File: ClingRouter.java    From portmapper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void logRouterInfo() throws RouterException {
    final RemoteDevice device = service.getDevice();
    final UDAVersion version = device.getVersion();
    final DeviceDetails deviceDetails = device.getDetails();
    logger.info("Service id: {}", service.getServiceId());
    logger.info("Reference: {}", service.getReference());
    logger.info("Display name: {}", device.getDisplayString());
    logger.info("Version: {}.{}", version.getMajor(), version.getMinor());
    logger.info("Control uri: {}", service.getControlURI());
    logger.info("Descriptor uri: {}", service.getDescriptorURI());
    logger.info("Event subscription uri: {}", service.getEventSubscriptionURI());
    logger.info("Device base url: {}", deviceDetails.getBaseURL());
    logger.info("Device presentation uri: {}", deviceDetails.getPresentationURI());
}
 
Example #9
Source File: DevicesActivity.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
	final DeviceItem display = new DeviceItem(device,
			device.getDisplayString());
	deviceRemoved(display);

	if (device.getType().getNamespace().equals("schemas-upnp-org")
			&& device.getType().getType().equals("MediaRenderer")) {
		final DeviceItem dmrDisplay = new DeviceItem(device, device
				.getDetails().getFriendlyName(),
				device.getDisplayString(), "(REMOTE) "
						+ device.getType().getDisplayString());
		dmrRemoved(dmrDisplay);
	}
}
 
Example #10
Source File: UPnPService.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
public List<String> getSonosControllerHosts() {
    List<String> result = new ArrayList<String>();
    for (Device device : upnpService.getRegistry().getDevices(new DeviceType("schemas-upnp-org", "ZonePlayer"))) {
        if (device instanceof RemoteDevice) {
            URL descriptorURL = ((RemoteDevice) device).getIdentity().getDescriptorURL();
            if (descriptorURL != null) {
                result.add(descriptorURL.getHost());
            }
        }
    }
    return result;
}
 
Example #11
Source File: RemoteItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
void maintain() {

        if (getDeviceItems().isEmpty()) return;

        // Remove expired remote devices
        Map<UDN, RemoteDevice> expiredRemoteDevices = new HashMap();
        for (RegistryItem<UDN, RemoteDevice> remoteItem : getDeviceItems()) {
            if (log.isLoggable(Level.FINEST))
                log.finest("Device '" + remoteItem.getItem() + "' expires in seconds: "
                                   + remoteItem.getExpirationDetails().getSecondsUntilExpiration());
            if (remoteItem.getExpirationDetails().hasExpired(false)) {
                expiredRemoteDevices.put(remoteItem.getKey(), remoteItem.getItem());
            }
        }
        for (RemoteDevice remoteDevice : expiredRemoteDevices.values()) {
            if (log.isLoggable(Level.FINE))
                log.fine("Removing expired: " + remoteDevice);
            remove(remoteDevice);
        }

        // Renew outgoing subscriptions
        Set<RemoteGENASubscription> expiredOutgoingSubscriptions = new HashSet();
        for (RegistryItem<String, RemoteGENASubscription> item : getSubscriptionItems()) {
            if (item.getExpirationDetails().hasExpired(true)) {
                expiredOutgoingSubscriptions.add(item.getItem());
            }
        }
        for (RemoteGENASubscription subscription : expiredOutgoingSubscriptions) {
            if (log.isLoggable(Level.FINEST))
                log.fine("Renewing outgoing subscription: " + subscription);
            renewOutgoingSubscription(subscription);
        }
    }
 
Example #12
Source File: RemoteItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void resume() {
    log.fine("Updating remote device expiration timestamps on resume");
    List<RemoteDeviceIdentity> toUpdate = new ArrayList<RemoteDeviceIdentity>();
    for (RegistryItem<UDN, RemoteDevice> remoteItem : getDeviceItems()) {
        toUpdate.add(remoteItem.getItem().getIdentity());
    }
    for (RemoteDeviceIdentity identity : toUpdate) {
        update(identity);
    }
}
 
Example #13
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public void notifyDiscoveryFailure(final RemoteDevice device, final Exception ex) {
    for (final RegistryListener listener : getListeners()) {
        getConfiguration().getRegistryListenerExecutor().execute(
                new Runnable() {
                    public void run() {
                        listener.remoteDeviceDiscoveryFailed(RegistryImpl.this, device, ex);
                    }
                }
        );
    }
}
 
Example #14
Source File: RegistryImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public void notifyDiscoveryFailure(final RemoteDevice device, final Exception ex) {
    for (final RegistryListener listener : getListeners()) {
        getConfiguration().getRegistryListenerExecutor().execute(
                new Runnable() {
                    public void run() {
                        listener.remoteDeviceDiscoveryFailed(RegistryImpl.this, device, ex);
                    }
                }
        );
    }
}
 
Example #15
Source File: RegistryImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public boolean removeDevice(UDN udn) {
    Device device = getDevice(udn, true);
    if (device != null && device instanceof LocalDevice)
        return removeDevice((LocalDevice) device);
    if (device != null && device instanceof RemoteDevice)
        return removeDevice((RemoteDevice) device);
    return false;
}
 
Example #16
Source File: RemoteItems.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void resume() {
    log.fine("Updating remote device expiration timestamps on resume");
    List<RemoteDeviceIdentity> toUpdate = new ArrayList<RemoteDeviceIdentity>();
    for (RegistryItem<UDN, RemoteDevice> remoteItem : getDeviceItems()) {
        toUpdate.add(remoteItem.getItem().getIdentity());
    }
    for (RemoteDeviceIdentity identity : toUpdate) {
        update(identity);
    }
}
 
Example #17
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public boolean removeDevice(UDN udn) {
    Device device = getDevice(udn, true);
    if (device != null && device instanceof LocalDevice)
        return removeDevice((LocalDevice) device);
    if (device != null && device instanceof RemoteDevice)
        return removeDevice((RemoteDevice) device);
    return false;
}
 
Example #18
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice device, Exception ex) {
    failedRemoteDeviceDiscoveryEvent.fire(
            new FailedRemoteDeviceDiscovery(device, ex)
    );
}
 
Example #19
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
    remoteDeviceDiscoveryEvent.select(Phase.COMPLETE).fire(
            new RemoteDeviceDiscovery(device)
    );
}
 
Example #20
Source File: DevicesActivity.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryFailed(Registry registry,
		final RemoteDevice device, final Exception ex) {
}
 
Example #21
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceUpdated(Registry registry, RemoteDevice device) {
    remoteDeviceDiscoveryEvent.select(Phase.UPDATED).fire(
            new RemoteDeviceDiscovery(device)
    );
}
 
Example #22
Source File: BrowserActivity.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
    deviceRemoved(device);
}
 
Example #23
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
synchronized public Collection<RemoteDevice> getRemoteDevices() {
    return Collections.unmodifiableCollection(remoteItems.get());
}
 
Example #24
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device) {
    remoteDeviceDiscoveryEvent.select(Phase.ALIVE).fire(
            new RemoteDeviceDiscovery(device)
    );
}
 
Example #25
Source File: FailedRemoteDeviceDiscovery.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public FailedRemoteDeviceDiscovery(RemoteDevice device, Exception ex) {
    super(device);
    this.exception = ex;
}
 
Example #26
Source File: RetrieveRemoteDescriptors.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected RemoteDevice describeServices(RemoteDevice currentDevice)
        throws RouterException, DescriptorBindingException, ValidationException {

    List<RemoteService> describedServices = new ArrayList();
    if (currentDevice.hasServices()) {
        List<RemoteService> filteredServices = filterExclusiveServices(currentDevice.getServices());
        for (RemoteService service : filteredServices) {
            RemoteService svc = describeService(service);
            if (svc == null) { // Something went wrong, bail out
                return null;
            }
            describedServices.add(svc);
        }
    }

    List<RemoteDevice> describedEmbeddedDevices = new ArrayList();
    if (currentDevice.hasEmbeddedDevices()) {
        for (RemoteDevice embeddedDevice : currentDevice.getEmbeddedDevices()) {
            if (embeddedDevice == null) continue;
            RemoteDevice describedEmbeddedDevice = describeServices(embeddedDevice);
            if (describedEmbeddedDevice == null) { // Something was wrong, recursively
                return null;
            }
            describedEmbeddedDevices.add(describedEmbeddedDevice);
        }
    }

    Icon[] iconDupes = new Icon[currentDevice.getIcons().length];
    for (int i = 0; i < currentDevice.getIcons().length; i++) {
        Icon icon = currentDevice.getIcons()[i];
        iconDupes[i] = icon.deepCopy();
    }

    // Yes, we create a completely new immutable graph here
    return currentDevice.newInstance(
            currentDevice.getIdentity().getUdn(),
            currentDevice.getVersion(),
            currentDevice.getType(),
            currentDevice.getDetails(),
            iconDupes,
            currentDevice.toServiceArray(describedServices),
            describedEmbeddedDevices
    );
}
 
Example #27
Source File: RetrieveRemoteDescriptors.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RetrieveRemoteDescriptors(UpnpService upnpService, RemoteDevice rd) {
    this.upnpService = upnpService;
    this.rd = rd;
}
 
Example #28
Source File: AddPortMappingAction.java    From portmapper with GNU General Public License v3.0 4 votes vote down vote up
public AddPortMappingAction(final Service<RemoteDevice, RemoteService> service, final PortMapping portMapping) {
    super(service, "AddPortMapping");
    this.portMapping = portMapping;
}
 
Example #29
Source File: RetrieveRemoteDescriptors.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public RetrieveRemoteDescriptors(UpnpService upnpService, RemoteDevice rd) {
    this.upnpService = upnpService;
    this.rd = rd;
}
 
Example #30
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
    remoteDeviceDiscoveryEvent.select(Phase.BYEBYE).fire(
            new RemoteDeviceDiscovery(device)
    );
}