public static List<String> getServiceNames(Device d) { ArrayList<String> services = new ArrayList<>(); for (Service s : d.getServices()) { services.add(s.getServiceId().getId()); } return services; }
protected void subscribeAll(Device d, String uuid) { String name = getFriendlyName(d); int ctrl = 0; for (Service s : d.getServices()) { String sid = s.getServiceId().getId(); LOGGER.debug("Subscribing to " + sid + " service on " + name); if (sid.contains("AVTransport")) { ctrl |= AVT; } else if (sid.contains("RenderingControl")) { ctrl |= RC; } upnpService.getControlPoint().execute(new SubscriptionCB(s)); } rendererMap.mark(uuid, RENEW, false); rendererMap.mark(uuid, CONTROLS, ctrl); }
// Convenience functions for sending various upnp service requests public static ActionInvocation send( final Device dev, String instanceID, String service, String action, String... args) { Service svc = dev.findService(ServiceId.valueOf("urn:upnp-org:serviceId:" + service)); final String uuid = getUUID(dev); if (svc != null) { Action x = svc.getAction(action); String name = getFriendlyName(dev); boolean log = !action.equals("GetPositionInfo"); if (x != null) { ActionInvocation a = new ActionInvocation(x); a.setInput("InstanceID", instanceID); for (int i = 0; i < args.length; i += 2) { a.setInput(args[i], args[i + 1]); } if (log) { LOGGER.debug("Sending upnp {}.{} {} to {}[{}]", service, action, args, name, instanceID); } new ActionCallback(a, upnpService.getControlPoint()) { @Override public void success(ActionInvocation invocation) { rendererMap.mark(uuid, ACTIVE, true); } @Override public void failure( ActionInvocation invocation, UpnpResponse operation, String defaultMsg) { LOGGER.debug("Action failed: {}", defaultMsg); rendererMap.mark(uuid, ACTIVE, false); } }.run(); if (log) { for (ActionArgumentValue arg : a.getOutput()) { LOGGER.debug( "Received from {}[{}]: {}={}", name, instanceID, arg.getArgument().getName(), arg.toString()); } } return a; } } return null; }
public SubscriptionCB(Service s) { super(s); uuid = getUUID(s.getDevice()); }