org.fourthline.cling.model.meta.LocalDevice Java Examples

The following examples show how to use org.fourthline.cling.model.meta.LocalDevice. 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 File: OutgoingNotificationRequest.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected OutgoingNotificationRequest(Location location, LocalDevice device, NotificationSubtype type) {
    super(
            new UpnpRequest(UpnpRequest.Method.NOTIFY),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.type = type;

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));

    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
    getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(type));
}
 
Example #2
Source File: OutgoingSearchResponse.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public OutgoingSearchResponse(IncomingDatagramMessage request,
                              Location location,
                              LocalDevice device) {

    super(new UpnpResponse(UpnpResponse.Status.OK), request.getSourceAddress(), request.getSourcePort());

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));
    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.EXT, new EXTHeader());

    if (location.getNetworkAddress().getHardwareAddress() != null) {
        getHeaders().add(
                UpnpHeader.Type.EXT_IFACE_MAC,
                 new InterfaceMacHeader(location.getNetworkAddress().getHardwareAddress())
        );
    }
}
 
Example #3
Source File: ReceivingSearch.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void sendSearchResponseServiceType(ServiceType serviceType, NetworkAddress activeStreamServer) throws RouterException {
    log.fine("Responding to service type search: " + serviceType);
    Collection<Device> devices = getUpnpService().getRegistry().getDevices(serviceType);
    for (Device device : devices) {
        if (device instanceof LocalDevice) {

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

            log.finer("Sending matching service type search result: " + device);
            OutgoingSearchResponse message =
                new OutgoingSearchResponseServiceType(
                        getInputMessage(),
                        getDescriptorLocation(activeStreamServer, (LocalDevice) device),
                        (LocalDevice) device,
                        serviceType
                );
            prepareOutgoingSearchResponse(message);
            getUpnpService().getRouter().send(message);
        }
    }
}
 
Example #4
Source File: ReceivingSearch.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void sendSearchResponseServiceType(ServiceType serviceType, NetworkAddress activeStreamServer) throws RouterException {
    log.fine("Responding to service type search: " + serviceType);
    Collection<Device> devices = getUpnpService().getRegistry().getDevices(serviceType);
    for (Device device : devices) {
        if (device instanceof LocalDevice) {

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

            log.finer("Sending matching service type search result: " + device);
            OutgoingSearchResponse message =
                new OutgoingSearchResponseServiceType(
                        getInputMessage(),
                        getDescriptorLocation(activeStreamServer, (LocalDevice) device),
                        (LocalDevice) device,
                        serviceType
                );
            prepareOutgoingSearchResponse(message);
            getUpnpService().getRouter().send(message);
        }
    }
}
 
Example #5
Source File: ReceivingSearch.java    From TVRemoteIME with 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 #6
Source File: ReceivingSearch.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected List<OutgoingSearchResponse> createServiceTypeMessages(LocalDevice device,
                                                                 NetworkAddress activeStreamServer) {
    List<OutgoingSearchResponse> msgs = new ArrayList<OutgoingSearchResponse>();
    for (ServiceType serviceType : device.findServiceTypes()) {
        OutgoingSearchResponse message =
            new OutgoingSearchResponseServiceType(
                    getInputMessage(),
                    getDescriptorLocation(activeStreamServer, device),
                    device,
                    serviceType
            );
        prepareOutgoingSearchResponse(message);
        msgs.add(message);
    }
    return msgs;
}
 
Example #7
Source File: ReceivingSearch.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer) throws RouterException {
    log.fine("Responding to root device search with advertisement messages for all local root devices");
    for (LocalDevice device : getUpnpService().getRegistry().getLocalDevices()) {

        if (isAdvertisementDisabled(device))
            continue;

        OutgoingSearchResponse message =
            new OutgoingSearchResponseRootDevice(
                    getInputMessage(),
                    getDescriptorLocation(activeStreamServer, device),
                    device
            );
        prepareOutgoingSearchResponse(message);
        getUpnpService().getRouter().send(message);
    }
}
 
Example #8
Source File: ReceivingSearch.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected List<OutgoingSearchResponse> createServiceTypeMessages(LocalDevice device,
                                                                 NetworkAddress activeStreamServer) {
    List<OutgoingSearchResponse> msgs = new ArrayList<OutgoingSearchResponse>();
    for (ServiceType serviceType : device.findServiceTypes()) {
        OutgoingSearchResponse message =
            new OutgoingSearchResponseServiceType(
                    getInputMessage(),
                    getDescriptorLocation(activeStreamServer, device),
                    device,
                    serviceType
            );
        prepareOutgoingSearchResponse(message);
        msgs.add(message);
    }
    return msgs;
}
 
Example #9
Source File: LocalItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
Collection<LocalDevice> get() {
    Set<LocalDevice> c = new HashSet();
    for (RegistryItem<UDN, LocalDevice> item : getDeviceItems()) {
        c.add(item.getItem());
    }
    return Collections.unmodifiableCollection(c);
}
 
Example #10
Source File: LocalItems.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void advertiseAlive(final LocalDevice localDevice) {
    registry.executeAsyncProtocol(new Runnable() {
        public void run() {
            try {
                log.finer("Sleeping some milliseconds to avoid flooding the network with ALIVE msgs");
                Thread.sleep(randomGenerator.nextInt(100));
            } catch (InterruptedException ex) {
                log.severe("Background execution interrupted: " + ex.getMessage());
            }
            registry.getProtocolFactory().createSendingNotificationAlive(localDevice).run();
        }
    });
}
 
Example #11
Source File: OutgoingNotificationRequestRootDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public OutgoingNotificationRequestRootDevice(Location location, LocalDevice device, NotificationSubtype type) {
    super(location, device, type);

    getHeaders().add(UpnpHeader.Type.NT, new RootDeviceHeader());
    getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn()));

    if (location.getNetworkAddress().getHardwareAddress() != null) {
        getHeaders().add(
                UpnpHeader.Type.EXT_IFACE_MAC,
                 new InterfaceMacHeader(location.getNetworkAddress().getHardwareAddress())
        );
    }
}
 
Example #12
Source File: OutgoingNotificationRequestServiceType.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public OutgoingNotificationRequestServiceType(Location location,
                                              LocalDevice device, NotificationSubtype type,
                                              ServiceType serviceType) {

    super(location, device, type);

    getHeaders().add(UpnpHeader.Type.NT, new ServiceTypeHeader(serviceType));
    getHeaders().add(UpnpHeader.Type.USN, new ServiceUSNHeader(device.getIdentity().getUdn(), serviceType));
}
 
Example #13
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public boolean removeDevice(UDN udn) {
    Device device = getDevice(udn, true);
    if (device != null && device instanceof LocalDevice)
        return removeDevice((LocalDevice) device);
    if (device != null && device instanceof RemoteDevice)
        return removeDevice((RemoteDevice) device);
    return false;
}
 
Example #14
Source File: MockUpnpService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SendingNotificationAlive createSendingNotificationAlive(LocalDevice localDevice) {
    return new SendingNotificationAlive(getUpnpService(), localDevice) {
        @Override
        protected void execute() throws RouterException {
            if (sendsAlive) super.execute();
        }
    };
}
 
Example #15
Source File: OutgoingSearchResponseRootDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public OutgoingSearchResponseRootDevice(IncomingDatagramMessage request,
                                        Location location,
                                        LocalDevice device) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new RootDeviceHeader());
    getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn()));
}
 
Example #16
Source File: OutgoingSearchResponseDeviceType.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public OutgoingSearchResponseDeviceType(IncomingDatagramMessage request,
                                        Location location,
                                        LocalDevice device) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new DeviceTypeHeader(device.getType()));
    getHeaders().add(UpnpHeader.Type.USN, new DeviceUSNHeader(device.getIdentity().getUdn(), device.getType()));
}
 
Example #17
Source File: SendingNotification.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected List<OutgoingNotificationRequest> createDeviceMessages(LocalDevice device,
                                                                 Location descriptorLocation) {
    List<OutgoingNotificationRequest> msgs = new ArrayList();

    // See the tables in UDA 1.0 section 1.1.2

    if (device.isRoot()) {
        msgs.add(
                new OutgoingNotificationRequestRootDevice(
                        descriptorLocation,
                        device,
                        getNotificationSubtype()
                )
        );
    }

    msgs.add(
            new OutgoingNotificationRequestUDN(
                    descriptorLocation, device, getNotificationSubtype()
            )
    );
    msgs.add(
            new OutgoingNotificationRequestDeviceType(
                    descriptorLocation, device, getNotificationSubtype()
            )
    );

    return msgs;
}
 
Example #18
Source File: OutgoingSearchResponseServiceType.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public OutgoingSearchResponseServiceType(IncomingDatagramMessage request,
                                         Location location,
                                         LocalDevice device,
                                         ServiceType serviceType) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new ServiceTypeHeader(serviceType));
    getHeaders().add(UpnpHeader.Type.USN, new ServiceUSNHeader(device.getIdentity().getUdn(), serviceType));
}
 
Example #19
Source File: DevicesActivity.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void localDeviceRemoved(Registry registry, LocalDevice device) {
	Log.e("DeviceListRegistryListener",
			"localDeviceRemoved:" + device.toString()
					+ device.getType().getType());

	final DeviceItem display = new DeviceItem(device,
			device.getDisplayString());
	deviceRemoved(display);
}
 
Example #20
Source File: OutgoingSearchResponseServiceType.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public OutgoingSearchResponseServiceType(IncomingDatagramMessage request,
                                         Location location,
                                         LocalDevice device,
                                         ServiceType serviceType) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new ServiceTypeHeader(serviceType));
    getHeaders().add(UpnpHeader.Type.USN, new ServiceUSNHeader(device.getIdentity().getUdn(), serviceType));
}
 
Example #21
Source File: DevicesActivity.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void localDeviceAdded(Registry registry, LocalDevice device) {
	Log.e("DeviceListRegistryListener",
			"localDeviceAdded:" + device.toString()
					+ device.getType().getType());

	final DeviceItem display = new DeviceItem(device, device
			.getDetails().getFriendlyName(), device.getDisplayString(),
			"(REMOTE) " + device.getType().getDisplayString());
	deviceAdded(display);
}
 
Example #22
Source File: OutgoingSearchResponseRootDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public OutgoingSearchResponseRootDevice(IncomingDatagramMessage request,
                                        Location location,
                                        LocalDevice device) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new RootDeviceHeader());
    getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn()));
}
 
Example #23
Source File: OutgoingSearchResponseDeviceType.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public OutgoingSearchResponseDeviceType(IncomingDatagramMessage request,
                                        Location location,
                                        LocalDevice device) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new DeviceTypeHeader(device.getType()));
    getHeaders().add(UpnpHeader.Type.USN, new DeviceUSNHeader(device.getIdentity().getUdn(), device.getType()));
}
 
Example #24
Source File: OutgoingNotificationRequestRootDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public OutgoingNotificationRequestRootDevice(Location location, LocalDevice device, NotificationSubtype type) {
    super(location, device, type);

    getHeaders().add(UpnpHeader.Type.NT, new RootDeviceHeader());
    getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn()));

    if (location.getNetworkAddress().getHardwareAddress() != null) {
        getHeaders().add(
                UpnpHeader.Type.EXT_IFACE_MAC,
                 new InterfaceMacHeader(location.getNetworkAddress().getHardwareAddress())
        );
    }
}
 
Example #25
Source File: RegistryImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public boolean removeDevice(UDN udn) {
    Device device = getDevice(udn, true);
    if (device != null && device instanceof LocalDevice)
        return removeDevice((LocalDevice) device);
    if (device != null && device instanceof RemoteDevice)
        return removeDevice((RemoteDevice) device);
    return false;
}
 
Example #26
Source File: LocalItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void advertiseByebye(final LocalDevice localDevice, boolean asynchronous) {
    final SendingAsync prot = registry.getProtocolFactory().createSendingNotificationByebye(localDevice);
    if (asynchronous) {
        registry.executeAsyncProtocol(prot);
    } else {
        prot.run();
    }
}
 
Example #27
Source File: LocalItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void advertiseAlive(final LocalDevice localDevice) {
    registry.executeAsyncProtocol(new Runnable() {
        public void run() {
            try {
                log.finer("Sleeping some milliseconds to avoid flooding the network with ALIVE msgs");
                Thread.sleep(randomGenerator.nextInt(100));
            } catch (InterruptedException ex) {
                log.severe("Background execution interrupted: " + ex.getMessage());
            }
            registry.getProtocolFactory().createSendingNotificationAlive(localDevice).run();
        }
    });
}
 
Example #28
Source File: OutgoingSearchResponseUDN.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public OutgoingSearchResponseUDN(IncomingDatagramMessage request,
                                 Location location,
                                 LocalDevice device) {
    super(request, location, device);

    getHeaders().add(UpnpHeader.Type.ST, new UDNHeader(device.getIdentity().getUdn()));
    getHeaders().add(UpnpHeader.Type.USN, new UDNHeader(device.getIdentity().getUdn()));
}
 
Example #29
Source File: LocalItems.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void advertiseLocalDevices() {
    for (RegistryItem<UDN, LocalDevice> localItem : deviceItems) {
        if (isAdvertised(localItem.getKey()))
            advertiseAlive(localItem.getItem());
    }
}
 
Example #30
Source File: ManagedUpnpService.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void localDeviceAdded(Registry registry, LocalDevice device) {
    localDeviceDiscoveryEvent.select(Phase.COMPLETE).fire(
            new LocalDeviceDiscovery(device)
    );
}