@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DeviceItem that = (DeviceItem) o; if (!udn.equals(that.udn)) return false; return true; }
public static void main(String[] args) throws Exception { System.out.println("Starting Cling..."); UpnpService upnpService = new UpnpServiceImpl(); long noOfDevices = args.length == 1 ? Long.valueOf(args[0]) : 10; System.out.println("Registering BinaryLight devices: " + noOfDevices); for (long i = 0; i <= noOfDevices; i++) { LocalService service = new AnnotationLocalServiceBinder().read(DemoBinaryLight.class); service.setManager(new DefaultServiceManager(service, DemoBinaryLight.class)); upnpService.getRegistry().addDevice( DemoBinaryLight.createDefaultDevice(UDN.uniqueSystemIdentifier(Long.toString(i)), "Device: " + i, service) ); } System.out.println("Completed device registration"); } }
@Override public String toString() { return PREFIX + getIdentifierString(); }
@Override public String toString() { return udn == null || serviceId == null ? "" : udn.toString() + DELIMITER + serviceId.toString(); }
DeviceIdentity identity = new DeviceIdentity(UDN.uniqueSystemIdentifier("tinyMediaManager"), 600); DeviceType type = new UDADeviceType("MediaServer", 1); String hostname = NetworkUtil.getMachineHostname(); new ModelDetails("tinyMediaManager", "tinyMediaManager - Media Server", ReleaseInfo.getVersion()), new URI("http://" + hostname + ":" + UPNP_PORT + "/dev/" + identity.getUdn().getIdentifierString() + "/desc"), new DLNADoc[] { new DLNADoc("DMS", DLNADoc.Version.V1_5), LOGGER.info("Hello, i'm " + identity.getUdn().getIdentifierString());
public ServiceReference(String s) { String[] split = s.split("/"); if (split.length == 2) { this.udn = UDN.valueOf(split[0]); this.serviceId = ServiceId.valueOf(split[1]); } else { this.udn = null; this.serviceId = null; } }
public static UDN valueOf(String udnString) { return new UDN(udnString.startsWith(PREFIX) ? udnString.substring(PREFIX.length()) : udnString); }
@Override public int hashCode() { return udn.hashCode(); } }
public String getString() { return getValue().toString(); } }
public static NamedServiceType valueOf(String s) throws InvalidValueException { String[] strings = s.split("::"); if (strings.length != 2) { throw new InvalidValueException("Can't parse UDN::ServiceType from: " + s); } UDN udn; try { udn = UDN.valueOf(strings[0]); } catch (Exception ex) { throw new InvalidValueException("Can't parse UDN: " + strings[0]); } ServiceType serviceType = ServiceType.valueOf(strings[1]); return new NamedServiceType(udn, serviceType); }
public void setString(String s) throws InvalidHeaderException { if (!s.startsWith(UDN.PREFIX) || !s.endsWith(ROOT_DEVICE_SUFFIX)) { throw new InvalidHeaderException( "Invalid root device USN header value, must start with '" + UDN.PREFIX + "' and end with '" + ROOT_DEVICE_SUFFIX + "' but is '" + s + "'" ); } UDN udn = new UDN(s.substring(UDN.PREFIX.length(), s.length() - ROOT_DEVICE_SUFFIX.length())); setValue(udn); }
@Override public int hashCode() { return udn.hashCode(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DeviceIdentity that = (DeviceIdentity) o; if (!udn.equals(that.udn)) return false; return true; }
public String getString() { return getValue().toString() + ROOT_DEVICE_SUFFIX; }
public static NamedDeviceType valueOf(String s) throws InvalidValueException { String[] strings = s.split("::"); if (strings.length != 2) { throw new InvalidValueException("Can't parse UDN::DeviceType from: " + s); } UDN udn; try { udn = UDN.valueOf(strings[0]); } catch (Exception ex) { throw new InvalidValueException("Can't parse UDN: " + strings[0]); } DeviceType deviceType = DeviceType.valueOf(strings[1]); return new NamedDeviceType(udn, deviceType); }
protected String getDevicePath(Device device) { if (device.getIdentity().getUdn() == null) { throw new IllegalStateException("Can't generate local URI prefix without UDN"); } StringBuilder s = new StringBuilder(); s.append(DEVICE).append("/"); s.append(URIUtil.encodePathSegment(device.getIdentity().getUdn().getIdentifierString())); return s.toString(); }
public void setString(String s) throws InvalidHeaderException { if (!s.startsWith(UDN.PREFIX)) { throw new InvalidHeaderException("Invalid UDA header value, must start with '"+UDN.PREFIX+"': " + s); } if (s.contains("::urn")) { throw new InvalidHeaderException("Invalid UDA header value, must not contain '::urn': " + s); } UDN udn = new UDN( s.substring(UDN.PREFIX.length()) ); setValue(udn); }
@Override public int hashCode() { int result = udn.hashCode(); result = 31 * result + deviceType.hashCode(); return result; } }
new DeviceIdentity(UDN.uniqueSystemIdentifier("Cling MediaRenderer")), new UDADeviceType("MediaRenderer", 1), new DeviceDetails(
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof NamedServiceType)) return false; NamedServiceType that = (NamedServiceType) o; if (!serviceType.equals(that.serviceType)) return false; if (!udn.equals(that.udn)) return false; return true; }