Java Code Examples for org.fourthline.cling.model.types.DeviceType

The following examples show how to use org.fourthline.cling.model.types.DeviceType. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TVRemoteIME   Source File: ReceivingSearch.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void sendSearchResponseDeviceType(DeviceType deviceType, NetworkAddress activeStreamServer) throws RouterException{
    log.fine("Responding to device type search: " + deviceType);
    Collection<Device> devices = getUpnpService().getRegistry().getDevices(deviceType);
    for (Device device : devices) {
        if (device instanceof LocalDevice) {

            if (isAdvertisementDisabled((LocalDevice)device))
                continue;

            log.finer("Sending matching device type search result for: " + device);
            OutgoingSearchResponse message =
                new OutgoingSearchResponseDeviceType(
                        getInputMessage(),
                        getDescriptorLocation(activeStreamServer, (LocalDevice) device),
                        (LocalDevice) device
                );
            prepareOutgoingSearchResponse(message);
            getUpnpService().getRouter().send(message);
        }
    }
}
 
Example 2
private LocalDevice createDevice()
        throws ValidationException, LocalServiceBindingException, IOException {

    DeviceIdentity identity =
            new DeviceIdentity(
                    UDN.uniqueSystemIdentifier(SmartApplianceEnabler.class.getSimpleName())
            );

    DeviceType type = new SmartApplianceEnablerDeviceType();

    DeviceDetails details =
            new DeviceDetails(
                    SmartApplianceEnabler.class.getSimpleName(),
                    new ManufacturerDetails(SmartApplianceEnabler.MANUFACTURER_NAME, URI.create(SmartApplianceEnabler.MANUFACTURER_URI)),
                    new ModelDetails(
                            SmartApplianceEnabler.class.getSimpleName(),
                            SmartApplianceEnabler.DESCRIPTION,
                            SmartApplianceEnabler.VERSION,
                            URI.create(SmartApplianceEnabler.MODEL_URI)
                    )
            );

    return new LocalDevice(identity, type, details, (Icon) null, (LocalService) null);
}
 
Example 3
Source Project: DroidDLNA   Source File: ReceivingSearch.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void sendSearchResponseDeviceType(DeviceType deviceType, NetworkAddress activeStreamServer) throws RouterException{
    log.fine("Responding to device type search: " + deviceType);
    Collection<Device> devices = getUpnpService().getRegistry().getDevices(deviceType);
    for (Device device : devices) {
        if (device instanceof LocalDevice) {

            if (isAdvertisementDisabled((LocalDevice)device))
                continue;

            log.finer("Sending matching device type search result for: " + device);
            OutgoingSearchResponse message =
                new OutgoingSearchResponseDeviceType(
                        getInputMessage(),
                        getDescriptorLocation(activeStreamServer, (LocalDevice) device),
                        (LocalDevice) device
                );
            prepareOutgoingSearchResponse(message);
            getUpnpService().getRouter().send(message);
        }
    }
}
 
Example 4
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 5
Source Project: DroidDLNA   Source File: DeviceTypeHeader.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(DeviceType.valueOf(s));
    } catch (RuntimeException ex) {
        throw new InvalidHeaderException("Invalid device type header value, " + ex.getMessage());
    }
}
 
Example 6
Source Project: DroidDLNA   Source File: RegistryItems.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns all devices (root or embedded) with a compatible type.
 * <p>
 * This routine will check compatible versions, as described by the UDA.
 * </p>
 *
 * @param deviceType The minimum device type required.
 * @return Any registered root or embedded device with a compatible type.
 */
Collection<D> get(DeviceType deviceType) {
    Collection<D> devices = new HashSet();
    for (RegistryItem<UDN, D> item : deviceItems) {
        D[] d = (D[])item.getItem().findDevices(deviceType);
        if (d != null) {
            devices.addAll(Arrays.asList(d));
        }
    }
    return devices;
}
 
Example 7
Source Project: DroidDLNA   Source File: MediaServer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public MediaServer(Context context ) throws ValidationException {
    mContext = context;
    DeviceType type = new UDADeviceType(deviceType, version);

    DeviceDetails details = new DeviceDetails(SettingActivity.getDeviceName(context) + " ("
            + android.os.Build.MODEL + ")", new ManufacturerDetails(
            android.os.Build.MANUFACTURER), new ModelDetails(android.os.Build.MODEL,
            Utils.DMS_DESC, "v1"));

    LocalService service = new AnnotationLocalServiceBinder()
            .read(ContentDirectoryService.class);

    service.setManager(new DefaultServiceManager<ContentDirectoryService>(service,
            ContentDirectoryService.class));

    udn = UpnpUtil.uniqueSystemIdentifier("msidms");

    localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, createDefaultDeviceIcon(), service);

    Log.v(LOGTAG, "MediaServer device created: ");
    Log.v(LOGTAG, "friendly name: " + details.getFriendlyName());
    Log.v(LOGTAG, "manufacturer: " + details.getManufacturerDetails().getManufacturer());
    Log.v(LOGTAG, "model: " + details.getModelDetails().getModelName());

    // start http server
    try {
        new HttpServer(PORT);
    } catch (IOException ioe) {
        System.err.println("Couldn't start server:\n" + ioe);
        System.exit(-1);
    }

    Log.v(LOGTAG, "Started Http Server on port " + PORT);
}
 
Example 8
Source Project: TVRemoteIME   Source File: LocalDevice.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocalDevice newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
                               Icon[] icons, LocalService[] services, List<LocalDevice> embeddedDevices)
        throws ValidationException {
    return new LocalDevice(
            new DeviceIdentity(udn, getIdentity().getMaxAgeSeconds()),
            version, type, details, icons,
            services,
            embeddedDevices.size() > 0 ? embeddedDevices.toArray(new LocalDevice[embeddedDevices.size()]) : null
    );
}
 
Example 9
Source Project: TVRemoteIME   Source File: RegistryItems.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns all devices (root or embedded) with a compatible type.
 * <p>
 * This routine will check compatible versions, as described by the UDA.
 * </p>
 *
 * @param deviceType The minimum device type required.
 * @return Any registered root or embedded device with a compatible type.
 */
Collection<D> get(DeviceType deviceType) {
    Collection<D> devices = new HashSet();
    for (RegistryItem<UDN, D> item : deviceItems) {
        D[] d = (D[])item.getItem().findDevices(deviceType);
        if (d != null) {
            devices.addAll(Arrays.asList(d));
        }
    }
    return devices;
}
 
Example 10
Source Project: airsonic   Source File: UPnPService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public List<String> getSonosControllerHosts() {
    ensureServiceStarted();
    List<String> result = new ArrayList<String>();
    for (Device device : upnpService.getRegistry().getDevices(new DeviceType("schemas-upnp-org", "ZonePlayer"))) {
        if (device instanceof RemoteDevice) {
            URL descriptorURL = ((RemoteDevice) device).getIdentity().getDescriptorURL();
            if (descriptorURL != null) {
                result.add(descriptorURL.getHost());
            }
        }
    }
    return result;
}
 
Example 11
Source Project: subsonic   Source File: UPnPService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public List<String> getSonosControllerHosts() {
    List<String> result = new ArrayList<String>();
    for (Device device : upnpService.getRegistry().getDevices(new DeviceType("schemas-upnp-org", "ZonePlayer"))) {
        if (device instanceof RemoteDevice) {
            URL descriptorURL = ((RemoteDevice) device).getIdentity().getDescriptorURL();
            if (descriptorURL != null) {
                result.add(descriptorURL.getHost());
            }
        }
    }
    return result;
}
 
Example 12
Source Project: DroidDLNA   Source File: Device.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 13
Source Project: DroidDLNA   Source File: RegistryImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
synchronized public Collection<Device> getDevices(DeviceType deviceType) {
    Collection<Device> devices = new HashSet();

    devices.addAll(localItems.get(deviceType));
    devices.addAll(remoteItems.get(deviceType));

    return Collections.unmodifiableCollection(devices);
}
 
Example 14
private LocalDevice createMediaServerDevice() throws Exception {

        String serverName = settingsService.getDlnaServerName();
        DeviceIdentity identity = new DeviceIdentity(UDN.uniqueSystemIdentifier(serverName));
        DeviceType type = new UDADeviceType("MediaServer", 1);

        // TODO: DLNACaps

        DeviceDetails details = new DeviceDetails(serverName, new ManufacturerDetails(serverName),
                new ModelDetails(serverName),
                new DLNADoc[]{new DLNADoc("DMS", DLNADoc.Version.V1_5)}, null);

        InputStream in = getClass().getResourceAsStream("logo-512.png");
        Icon icon = new Icon("image/png", 512, 512, 32, "logo-512", in);
        FileUtil.closeQuietly(in);

        LocalService<CustomContentDirectory> contentDirectoryservice = new AnnotationLocalServiceBinder().read(CustomContentDirectory.class);
        contentDirectoryservice.setManager(new DefaultServiceManager<CustomContentDirectory>(contentDirectoryservice) {

            @Override
            protected CustomContentDirectory createServiceInstance() {
                return dispatchingContentDirectory;
            }
        });

        final ProtocolInfos protocols = new ProtocolInfos();
        for (DLNAProfiles dlnaProfile : DLNAProfiles.values()) {
            if (dlnaProfile == DLNAProfiles.NONE) {
                continue;
            }
            try {
                protocols.add(new DLNAProtocolInfo(dlnaProfile));
            } catch (Exception e) {
                // Silently ignored.
            }
        }

        LocalService<ConnectionManagerService> connetionManagerService = new AnnotationLocalServiceBinder().read(ConnectionManagerService.class);
        connetionManagerService.setManager(new DefaultServiceManager<ConnectionManagerService>(connetionManagerService) {
            @Override
            protected ConnectionManagerService createServiceInstance() {
                return new ConnectionManagerService(protocols, null);
            }
        });

        // For compatibility with Microsoft
        LocalService<MSMediaReceiverRegistrarService> receiverService = new AnnotationLocalServiceBinder().read(MSMediaReceiverRegistrarService.class);
        receiverService.setManager(new DefaultServiceManager<>(receiverService, MSMediaReceiverRegistrarService.class));

        return new LocalDevice(identity, type, details, new Icon[]{icon}, new LocalService[]{contentDirectoryservice, connetionManagerService, receiverService});
    }
 
Example 15
Source Project: DroidDLNA   Source File: LocalDevice.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService service, LocalDevice embeddedDevice) throws ValidationException {
    super(identity, type, details, icons, new LocalService[]{service}, new LocalDevice[]{embeddedDevice});
    this.deviceDetailsProvider = null;
}
 
Example 16
Source Project: TVRemoteIME   Source File: ReceivingSearch.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected void sendResponses(UpnpHeader searchTarget, NetworkAddress activeStreamServer) throws RouterException {
    if (searchTarget instanceof STAllHeader) {

        sendSearchResponseAll(activeStreamServer);

    } else if (searchTarget instanceof RootDeviceHeader) {

        sendSearchResponseRootDevices(activeStreamServer);

    } else if (searchTarget instanceof UDNHeader) {

        sendSearchResponseUDN((UDN) searchTarget.getValue(), activeStreamServer);

    } else if (searchTarget instanceof DeviceTypeHeader) {

        sendSearchResponseDeviceType((DeviceType) searchTarget.getValue(), activeStreamServer);

    } else if (searchTarget instanceof ServiceTypeHeader) {

        sendSearchResponseServiceType((ServiceType) searchTarget.getValue(), activeStreamServer);

    } else {
        log.warning("Non-implemented search request target: " + searchTarget.getClass());
    }
}
 
Example 17
Source Project: TVRemoteIME   Source File: MutableDevice.java    License: GNU General Public License v2.0 4 votes vote down vote up
public DeviceType createDeviceType() {
    return DeviceType.valueOf(deviceType);
}
 
Example 18
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Device(DI identity, DeviceType type, DeviceDetails details,
              Icon[] icons, S[] services) throws ValidationException {
    this(identity, null, type, details, icons, services, null);
}
 
Example 19
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Device(DI identity, DeviceType type, DeviceDetails details,
              Icon[] icons, S[] services, D[] embeddedDevices) throws ValidationException {
    this(identity, null, type, details, icons, services, embeddedDevices);
}
 
Example 20
Source Project: DroidDLNA   Source File: LocalDevice.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetailsProvider deviceDetailsProvider,
                   Icon icon, LocalService[] services) throws ValidationException {
    super(identity, type, null, new Icon[]{icon}, services);
    this.deviceDetailsProvider = deviceDetailsProvider;
}
 
Example 21
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 4 votes vote down vote up
public DeviceType getType() {
    return type;
}
 
Example 22
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 4 votes vote down vote up
public D[] findDevices(DeviceType deviceType) {
    return toDeviceArray(find(deviceType, (D) this));
}
 
Example 23
Source Project: TVRemoteIME   Source File: Device.java    License: GNU General Public License v2.0 4 votes vote down vote up
public abstract D newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
Icon[] icons, S[] services, List<D> embeddedDevices) throws ValidationException;
 
Example 24
Source Project: DroidDLNA   Source File: LocalDevice.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetailsProvider deviceDetailsProvider,
                   LocalService service) throws ValidationException {
    super(identity, type, null, null, new LocalService[]{service});
    this.deviceDetailsProvider = deviceDetailsProvider;
}
 
Example 25
Source Project: DroidDLNA   Source File: LocalDevice.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService service) throws ValidationException {
    super(identity, type, details, icons, new LocalService[]{service});
    this.deviceDetailsProvider = null;
}
 
Example 26
Source Project: TVRemoteIME   Source File: RemoteDevice.java    License: GNU General Public License v2.0 4 votes vote down vote up
public RemoteDevice(RemoteDeviceIdentity identity, DeviceType type, DeviceDetails details,
                   RemoteService[] services) throws ValidationException {
    super(identity, type, details, null, services);
}
 
Example 27
Source Project: TVRemoteIME   Source File: RemoteDevice.java    License: GNU General Public License v2.0 4 votes vote down vote up
public RemoteDevice(RemoteDeviceIdentity identity, DeviceType type, DeviceDetails details,
                   RemoteService[] services, RemoteDevice[] embeddedDevices) throws ValidationException {
    super(identity, type, details, null, services, embeddedDevices);
}
 
Example 28
Source Project: TVRemoteIME   Source File: RemoteDevice.java    License: GNU General Public License v2.0 4 votes vote down vote up
public RemoteDevice(RemoteDeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon icon, RemoteService service) throws ValidationException {
    super(identity, type, details, new Icon[]{icon}, new RemoteService[]{service});
}
 
Example 29
public UDADeviceTypeHeader(DeviceType value) {
    super(value);
}
 
Example 30
Source Project: TVRemoteIME   Source File: RemoteDevice.java    License: GNU General Public License v2.0 4 votes vote down vote up
public RemoteDevice(RemoteDeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon icon, RemoteService[] services) throws ValidationException {
    super(identity, type, details, new Icon[]{icon}, services);
}