예제 #1
0
 public static boolean isUpnpControllable(String uuid) {
   // Disable manually for Panasonic TVs since they lie
   if (rendererMap.containsKey(uuid)
       && !getDeviceDetailsString(getDevice(uuid)).contains("VIERA")) {
     return rendererMap.get(uuid, "0").controls != 0;
   }
   return false;
 }
예제 #2
0
 protected void rendererUpdated(Device d) {
   String uuid = getUUID(d);
   if (rendererMap.containsKey(uuid)) {
     if (rendererMap.get(uuid, "0").needsRenewal()) {
       LOGGER.debug("Renewing subscriptions to ", getFriendlyName(d));
       subscribeAll(d, uuid);
     }
     rendererMap.mark(uuid, ACTIVE, true);
   }
 }
예제 #3
0
 @Override
 public void eventReceived(GENASubscription subscription) {
   rendererMap.mark(uuid, ACTIVE, true);
   if (subscription.getCurrentValues().containsKey("LastChange")) {
     xml2d(uuid, subscription.getCurrentValues().get("LastChange").toString(), null);
   }
 }
예제 #4
0
 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);
 }
예제 #5
0
 public static synchronized void xml2d(String uuid, String xml, Renderer item) {
   try {
     Document doc = db.parse(new ByteArrayInputStream(xml.getBytes()));
     //			doc.getDocumentElement().normalize();
     NodeList ids = doc.getElementsByTagName("InstanceID");
     for (int i = 0; i < ids.getLength(); i++) {
       NodeList c = ids.item(i).getChildNodes();
       String id = ((Element) ids.item(i)).getAttribute("val");
       //				if (DEBUG) LOGGER.debug("InstanceID: " + id);
       if (item == null) {
         item = rendererMap.get(uuid, id);
       }
       item.data.put("InstanceID", id);
       for (int n = 0; n < c.getLength(); n++) {
         if (c.item(n).getNodeType() != Node.ELEMENT_NODE) {
           //						LOGGER.debug("skip this " + c.item(n));
           continue;
         }
         Element e = (Element) c.item(n);
         String name = e.getTagName();
         String val = e.getAttribute("val");
         if (DEBUG) {
           LOGGER.debug(name + ": " + val);
         }
         item.data.put(name, val);
       }
       item.alert();
     }
   } catch (Exception e) {
     LOGGER.debug("Error parsing xml: " + e);
   }
 }
예제 #6
0
 protected synchronized boolean addRenderer(Device d) {
   if (d != null) {
     String uuid = getUUID(d);
     if (isMediaRenderer(d) && rendererFound(d, uuid) != null) {
       LOGGER.debug("Adding device: {} {}", d.getType(), d.toString());
       rendererMap.mark(uuid, ACTIVE, true);
       subscribeAll(d, uuid);
       rendererReady(uuid);
       return true;
     }
   }
   return false;
 }
예제 #7
0
 @Override
 public void ended(GENASubscription sub, CancelReason reason, UpnpResponse response) {
   // Reason should be null, or it didn't end regularly
   if (reason != null) {
     LOGGER.debug(
         "Subscription cancelled: "
             + sub.getService().getServiceId().getId()
             + " on "
             + uuid
             + ": "
             + reason);
   }
   rendererMap.mark(uuid, RENEW, true);
 }
예제 #8
0
 public static Map<String, String> getData(String uuid, String instanceID) {
   return rendererMap.get(uuid, instanceID).data;
 }
예제 #9
0
 public static void connect(String uuid, String instanceID, ActionListener listener) {
   rendererMap.get(uuid, instanceID).connect(listener);
 }
예제 #10
0
 public static Renderer getRenderer(String uuid) {
   if (rendererMap.containsKey(uuid)) {
     return rendererMap.get(uuid, "0");
   }
   return null;
 }
예제 #11
0
 protected Renderer rendererFound(Device d, String uuid) {
   // Create an instance
   return rendererMap.get(uuid, "0");
 }
예제 #12
0
 public static boolean isActive(String uuid, String id) {
   if (rendererMap.containsKey(uuid, id)) {
     return rendererMap.get(uuid, id).active;
   }
   return false;
 }