protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
protected Service discoverConnectionService(Device device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { return null; } Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { log.fine("IGD doesn't support '" + CONNECTION_DEVICE_TYPE + "': " + device); return null; } Device connectionDevice = connectionDevices[0]; log.fine("Using first discovered WAN connection device: " + connectionDevice); Service ipConnectionService = connectionDevice.findService(IP_SERVICE_TYPE); Service pppConnectionService = connectionDevice.findService(PPP_SERVICE_TYPE); if (ipConnectionService == null && pppConnectionService == null) { log.fine("IGD doesn't support IP or PPP WAN connection service: " + device); } return ipConnectionService != null ? ipConnectionService : pppConnectionService; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if(getIdentity() != null) { errors.addAll(getIdentity().validate()); } if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
public static boolean isMediaServerDevice(Device device) { if ("urn:schemas-upnp-org:device:MediaServer:1" .equalsIgnoreCase(device.getType().getType())) { return true; } return false; }
public static boolean isMediaRenderDevice(Device device) { if ("urn:schemas-upnp-org:device:MediaRenderer:1".equalsIgnoreCase(device.getType() .getType())) { return true; } return false; }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
addIfNotNull(deviceNode, "Device Type: ", device.getType().toString()); if (device.getDetails().getDlnaDocs() != null) { for (DLNADoc dlnaDoc : device.getDetails().getDlnaDocs()) {
protected Service discoverConnectionService(Device device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { return null; } Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { log.fine("IGD doesn't support '" + CONNECTION_DEVICE_TYPE + "': " + device); return null; } Device connectionDevice = connectionDevices[0]; log.fine("Using first discovered WAN connection device: " + connectionDevice); Service ipConnectionService = connectionDevice.findService(IP_SERVICE_TYPE); Service pppConnectionService = connectionDevice.findService(PPP_SERVICE_TYPE); if (ipConnectionService == null && pppConnectionService == null) { log.fine("IGD doesn't support IP or PPP WAN connection service: " + device); } return ipConnectionService != null ? ipConnectionService : pppConnectionService; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());
protected Service<?, ?> discoverConnectionService(@SuppressWarnings("rawtypes") final Device<?, Device, ?> device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { logger.debug("Found service of wrong type {}, expected {}.", device.getType(), IGD_DEVICE_TYPE); return null; } @SuppressWarnings("rawtypes") final Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { logger.debug("IGD doesn't support '{}': {}", CONNECTION_DEVICE_TYPE, device); return null; } logger.debug("Found {} devices", connectionDevices.length); return findConnectionService(connectionDevices); }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
/** * Finds all available Players (implementing the MediaRenderer stack)<br> * You might want to call sendPlayerSearchRequest() a few secs before, to populate freshly * * @return List of devices */ public List<Device> getAvailablePlayers() { createUpnpService(); List<Device> ret = new ArrayList<>(); for (Device device : this.upnpService.getRegistry().getDevices()) { if (device.getType().getType().equals("MediaRenderer")) { ret.add(device); } } return ret; }
protected Service discoverConnectionService(Device device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { return null; } Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { log.fine("IGD doesn't support '" + CONNECTION_DEVICE_TYPE + "': " + device); return null; } Device connectionDevice = connectionDevices[0]; log.fine("Using first discovered WAN connection device: " + connectionDevice); Service ipConnectionService = connectionDevice.findService(IP_SERVICE_TYPE); Service pppConnectionService = connectionDevice.findService(PPP_SERVICE_TYPE); if (ipConnectionService == null && pppConnectionService == null) { log.fine("IGD doesn't support IP or PPP WAN connection service: " + device); } return ipConnectionService != null ? ipConnectionService : pppConnectionService; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getType() != null) { // Only validate the graph if we have a device type - that means we validate only if there // actually is a fully hydrated graph, not just a discovered device of which we haven't even // retrieved the descriptor yet. This assumes that the descriptor will ALWAYS contain a device // type. Now that is a risky assumption... errors.addAll(getVersion().validate()); if(getIdentity() != null) { errors.addAll(getIdentity().validate()); } if (getDetails() != null) { errors.addAll(getDetails().validate()); } if (hasServices()) { for (Service service : getServices()) { if (service != null) errors.addAll(service.validate()); } } if (hasEmbeddedDevices()) { for (Device embeddedDevice : getEmbeddedDevices()) { if (embeddedDevice != null) errors.addAll(embeddedDevice.validate()); } } } return errors; }
appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());
appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());