org.fourthline.cling.model.meta.Device类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.fourthline.cling.model.meta.Device类的一些代码示例,展示了Device类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device类的具体详情如下:
包路径:org.fourthline.cling.model.meta.Device
类名称:Device

Device介绍

[英]Describes either a root or embedded device.
[中]描述根设备或嵌入式设备。

代码示例

代码示例来源:origin: 4thline/cling

@Override
public Service getMatchingAVTransportService(Device device, List<ProtocolInfo> infos, Res resource) {
  final Service avTransportService =
      device.findService(SUPPORTED_AV_TRANSPORT_TYPE);
  return avTransportService != null && isProtocolInfoMatch(infos, resource)
      ? avTransportService : null;
}

代码示例来源:origin: 4thline/cling

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;
}

代码示例来源:origin: 4thline/cling

@Override
  public String toString() {
    String name =
      getDevice().getDetails() != null && getDevice().getDetails().getFriendlyName() != null
        ? getDevice().getDetails().getFriendlyName()
        : getDevice().getDisplayString();
    // Display a little star while the device is being loaded (see performance optimization earlier)
    return device.isFullyHydrated() ? name : name + " *";
  }
}

代码示例来源:origin: 4thline/cling

public S[] findServices(ServiceType serviceType) {
  return toServiceArray(findServices(serviceType, null, (D) this));
}

代码示例来源:origin: 4thline/cling

protected Collection<D> findEmbeddedDevices(D current) {
  Collection<D> devices = new HashSet<>();
  if (!current.isRoot() && current.getIdentity().getUdn() != null)
    devices.add(current);
  if (current.hasEmbeddedDevices()) {
    for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) {
      devices.addAll(findEmbeddedDevices(embeddedDevice));
    }
  }
  return devices;
}

代码示例来源:origin: 4thline/cling

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;
}

代码示例来源:origin: 4thline/cling

addIfNotNull(deviceNode, "UDN: ", device.getIdentity().getUdn());
addIfNotNull(deviceNode, "Device Type: ", device.getType().toString());
if (device.getDetails().getDlnaDocs() != null) {
  for (DLNADoc dlnaDoc : device.getDetails().getDlnaDocs()) {
    addIfNotNull(deviceNode, "DLNA Doc: ", dlnaDoc);
addIfNotNull(deviceNode, "DLNA Caps: ", device.getDetails().getDlnaCaps());
addIfNotNull(deviceNode, "Manufacturer: ", device.getDetails().getManufacturerDetails().getManufacturer());
addIfNotNull(deviceNode, "Manufacturer URL/URI: ", device.getDetails().getManufacturerDetails().getManufacturerURI(), device);
addIfNotNull(deviceNode, "Model Name: ", device.getDetails().getModelDetails().getModelName());
addIfNotNull(deviceNode, "Model #: ", device.getDetails().getModelDetails().getModelNumber());
addIfNotNull(deviceNode, "Model Description: ", device.getDetails().getModelDetails().getModelDescription());
addIfNotNull(deviceNode, "Model URL/URI: ", device.getDetails().getModelDetails().getModelURI(), device);
addIfNotNull(deviceNode, "Serial #: ", device.getDetails().getSerialNumber());
addIfNotNull(deviceNode, "Universal Product Code: ", device.getDetails().getUpc());
addIfNotNull(deviceNode, "Presentation URI: ", device.getDetails().getPresentationURI(), device);
if (device.hasIcons()) {
  for (Icon icon : device.getIcons()) {
    deviceNode.add(new DefaultMutableTreeNode(icon));
if (device.hasServices()) {
  for (Service service : device.getServices()) {
    DefaultMutableTreeNode serviceNode = new DefaultMutableTreeNode(service);
    deviceNode.add(serviceNode);
if (device.hasEmbeddedDevices()) {

代码示例来源:origin: 4thline/cling

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;
}

代码示例来源:origin: 4thline/cling

public DeviceDetails getDetails(RemoteClientInfo info) {
  return this.getDetails();
}

代码示例来源:origin: 4thline/cling

appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());
DeviceDetails deviceModelDetails = deviceModel.getDetails(info);
appendNewElementIfNotNull(
    descriptor, deviceElement, ELEMENT.friendlyName,
    deviceModelDetails.getSerialNumber()
);
appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.UDN, deviceModel.getIdentity().getUdn());
appendNewElementIfNotNull(
    descriptor, deviceElement, ELEMENT.presentationURL,

代码示例来源:origin: 4thline/cling

Device nodeDevice = (Device) node.getUserObject();
if (nodeDevice.isRoot()) {
  if (rootDeviceIcon != null) {
    setIcon(new ImageIcon(rootDeviceIcon.getImage().getScaledInstance(24, 24, java.awt.Image.SCALE_SMOOTH)));
    nodeDevice.getDisplayString()
        + " (UPnP Version: " + nodeDevice.getVersion().getMajor() + "." + nodeDevice.getVersion().getMinor() + ")"
);
setText(nodeDevice.getDetails().getFriendlyName());

代码示例来源:origin: 4thline/cling

public String getDetailsMessage() {
  StringBuilder sb = new StringBuilder();
  if (getDevice().isFullyHydrated()) {
    sb.append(getDevice().getDisplayString());
    sb.append("\n\n");
    for (Service service : getDevice().getServices()) {
      sb.append(service.getServiceType()).append("\n");
    }
  } else {
    sb.append(getString(R.string.deviceDetailsNotYetAvailable));
  }
  return sb.toString();
}
// DOC:DETAILS

代码示例来源:origin: 4thline/cling

@Override
public int indexOf(Object o) {
  if (o instanceof Device) {
    Device device = (Device) o;
    DeviceItem display = new DeviceItem(device, device.getDisplayString());
    return indexOf(display);
  }
  return super.indexOf(o);
}

代码示例来源:origin: 4thline/cling

protected Collection<S> findServices(ServiceType serviceType, ServiceId serviceId, D current) {
  Collection services = new HashSet<>();
  if (current.hasServices()) {
    for (Service service : current.getServices()) {
      if (isMatch(service, serviceType, serviceId))
        services.add(service);
    }
  }
  Collection<D> embeddedDevices = findEmbeddedDevices(current);
  if (embeddedDevices != null) {
    for (D embeddedDevice : embeddedDevices) {
      if (embeddedDevice.hasServices()) {
        for (Service service : embeddedDevice.getServices()) {
          if (isMatch(service, serviceType, serviceId))
            services.add(service);
        }
      }
    }
  }
  return services;
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

/**
 * Sets a device as our player for play/stop and other services<br>
 * Use getAvailablePlayers() for a list of them.
 * 
 * @param device
 *          device for playing
 */
public void setPlayer(Device device) {
 this.playerService = device.findService(new UDAServiceId("AVTransport"));
 if (this.playerService == null) {
  LOGGER.warn("Could not find AVTransportService on device " + device.getDisplayString());
 }
}

代码示例来源:origin: 4thline/cling

protected D find(UDN udn, D current) {
  if (current.getIdentity() != null && current.getIdentity().getUdn() != null) {
    if (current.getIdentity().getUdn().equals(udn)) return current;
  }
  if (current.hasEmbeddedDevices()) {
    for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) {
      D match;
      if ((match = find(udn, embeddedDevice)) != null) return match;
    }
  }
  return null;
}

代码示例来源:origin: 4thline/cling

public S findService(ServiceId serviceId) {
  Collection<S> services = findServices(null, serviceId, (D) this);
  return services.size() == 1 ? services.iterator().next() : null;
}

代码示例来源:origin: 4thline/cling

public DeviceItem(Device device, String... label) {
  this.udn = device.getIdentity().getUdn();
  this.device = device;
  this.label = label;
}

代码示例来源:origin: 4thline/cling

public void init(Service service) {
  this.service = service;
  view.setPresenter(this);
  view.setTitle("WAN IP Connection on " + service.getDevice().getRoot().getDetails().getFriendlyName());
  portMappingPresenter.init(
      view.getPortMappingListView(),
      view.getPortMappingEditView(),
      service,
      this
  );
  updateConnectionInfo();
}

代码示例来源:origin: 4thline/cling

protected void generateServiceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
  if (!deviceModel.hasServices()) return;
  Element serviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.serviceList);
  for (Service service : deviceModel.getServices()) {
    Element serviceElement = appendNewElement(descriptor, serviceListElement, ELEMENT.service);
    appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceType, service.getServiceType());
    appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceId, service.getServiceId());
    if (service instanceof RemoteService) {
      RemoteService rs = (RemoteService) service;
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, rs.getDescriptorURI());
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, rs.getControlURI());
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, rs.getEventSubscriptionURI());
    } else if (service instanceof LocalService) {
      LocalService ls = (LocalService) service;
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, namespace.getDescriptorPath(ls));
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, namespace.getControlPath(ls));
      appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, namespace.getEventSubscriptionPath(ls));
    }
  }
}

相关文章