org.fourthline.cling.binding.xml.DeviceDescriptorBinder Java Examples

The following examples show how to use org.fourthline.cling.binding.xml.DeviceDescriptorBinder. 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: SempDiscovery.java    From SmartApplianceEnabler with GNU General Public License v2.0 6 votes vote down vote up
private UpnpServiceConfiguration createServiceConfiguration() {
    return new DefaultUpnpServiceConfiguration() {
        @Override
        public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10() {
            return new SempDeviceDescriptorBinderImpl(this, sempServerUrl);
        }

        @Override
        public StreamClient createStreamClient() {
            // disable the client in order to avoid requesting descriptors from UPnP devices
            return null;
        }

        @Override
        public StreamServer createStreamServer(NetworkAddressFactory networkAddressFactory) {
            return new org.fourthline.cling.transport.impl.apache.StreamServerImpl(
                    new StreamServerConfigurationImpl()
            );
        }
    };
}
 
Example #2
Source File: ReceivingRetrieval.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected StreamResponseMessage createResponse(URI requestedURI, Resource resource) {

        StreamResponseMessage response;

        try {

            if (DeviceDescriptorResource.class.isAssignableFrom(resource.getClass())) {

                log.fine("Found local device matching relative request URI: " + requestedURI);
                LocalDevice device = (LocalDevice) resource.getModel();

                DeviceDescriptorBinder deviceDescriptorBinder =
                        getUpnpService().getConfiguration().getDeviceDescriptorBinderUDA10();
                String deviceDescriptor = deviceDescriptorBinder.generate(
                        device,
                        getRemoteClientInfo(),
                        getUpnpService().getConfiguration().getNamespace()
                );
                response = new StreamResponseMessage(
                        deviceDescriptor,
                        new ContentTypeHeader(ContentTypeHeader.DEFAULT_CONTENT_TYPE)
                );
            } else if (ServiceDescriptorResource.class.isAssignableFrom(resource.getClass())) {


                log.fine("Found local service matching relative request URI: " + requestedURI);
                LocalService service = (LocalService) resource.getModel();

                ServiceDescriptorBinder serviceDescriptorBinder =
                        getUpnpService().getConfiguration().getServiceDescriptorBinderUDA10();
                String serviceDescriptor = serviceDescriptorBinder.generate(service);
                response = new StreamResponseMessage(
                        serviceDescriptor,
                        new ContentTypeHeader(ContentTypeHeader.DEFAULT_CONTENT_TYPE)
                );

            } else if (IconResource.class.isAssignableFrom(resource.getClass())) {

                log.fine("Found local icon matching relative request URI: " + requestedURI);
                Icon icon = (Icon) resource.getModel();
                response = new StreamResponseMessage(icon.getData(), icon.getMimeType());

            } else {

                log.fine("Ignoring GET for found local resource: " + resource);
                return null;
            }

        } catch (DescriptorBindingException ex) {
            log.warning("Error generating requested device/service descriptor: " + ex.toString());
            log.log(Level.WARNING, "Exception root cause: ", Exceptions.unwrap(ex));
            response = new StreamResponseMessage(UpnpResponse.Status.INTERNAL_SERVER_ERROR);
        }
        
        response.getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());

        return response;
    }
 
Example #3
Source File: ManagedUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10() {
    return deviceDescriptorBinderUDA10;
}
 
Example #4
Source File: ManagedUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new UDA10DeviceDescriptorBinderImpl();
}
 
Example #5
Source File: DefaultUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10() {
    return deviceDescriptorBinderUDA10;
}
 
Example #6
Source File: DefaultUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new UDA10DeviceDescriptorBinderImpl();
}
 
Example #7
Source File: AndroidUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new RecoveringUDA10DeviceDescriptorBinderImpl();
}
 
Example #8
Source File: ReceivingRetrieval.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected StreamResponseMessage createResponse(URI requestedURI, Resource resource) {

        StreamResponseMessage response;

        try {

            if (DeviceDescriptorResource.class.isAssignableFrom(resource.getClass())) {

                log.fine("Found local device matching relative request URI: " + requestedURI);
                LocalDevice device = (LocalDevice) resource.getModel();

                DeviceDescriptorBinder deviceDescriptorBinder =
                        getUpnpService().getConfiguration().getDeviceDescriptorBinderUDA10();
                String deviceDescriptor = deviceDescriptorBinder.generate(
                        device,
                        getRemoteClientInfo(),
                        getUpnpService().getConfiguration().getNamespace()
                );
                response = new StreamResponseMessage(
                        deviceDescriptor,
                        new ContentTypeHeader(ContentTypeHeader.DEFAULT_CONTENT_TYPE)
                );
            } else if (ServiceDescriptorResource.class.isAssignableFrom(resource.getClass())) {


                log.fine("Found local service matching relative request URI: " + requestedURI);
                LocalService service = (LocalService) resource.getModel();

                ServiceDescriptorBinder serviceDescriptorBinder =
                        getUpnpService().getConfiguration().getServiceDescriptorBinderUDA10();
                String serviceDescriptor = serviceDescriptorBinder.generate(service);
                response = new StreamResponseMessage(
                        serviceDescriptor,
                        new ContentTypeHeader(ContentTypeHeader.DEFAULT_CONTENT_TYPE)
                );

            } else if (IconResource.class.isAssignableFrom(resource.getClass())) {

                log.fine("Found local icon matching relative request URI: " + requestedURI);
                Icon icon = (Icon) resource.getModel();
                response = new StreamResponseMessage(icon.getData(), icon.getMimeType());

            } else {

                log.fine("Ignoring GET for found local resource: " + resource);
                return null;
            }

        } catch (DescriptorBindingException ex) {
            log.warning("Error generating requested device/service descriptor: " + ex.toString());
            log.log(Level.WARNING, "Exception root cause: ", Exceptions.unwrap(ex));
            response = new StreamResponseMessage(UpnpResponse.Status.INTERNAL_SERVER_ERROR);
        }
        
        response.getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());

        return response;
    }
 
Example #9
Source File: ManagedUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10() {
    return deviceDescriptorBinderUDA10;
}
 
Example #10
Source File: ManagedUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new UDA10DeviceDescriptorBinderImpl();
}
 
Example #11
Source File: DefaultUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10() {
    return deviceDescriptorBinderUDA10;
}
 
Example #12
Source File: DefaultUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new UDA10DeviceDescriptorBinderImpl();
}
 
Example #13
Source File: AndroidUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected DeviceDescriptorBinder createDeviceDescriptorBinderUDA10() {
    return new RecoveringUDA10DeviceDescriptorBinderImpl();
}
 
Example #14
Source File: UpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @return The shared implementation of {@link org.fourthline.cling.binding.xml.DeviceDescriptorBinder} for the UPnP 1.0 Device Architecture..
 */
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10();
 
Example #15
Source File: UpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @return The shared implementation of {@link org.fourthline.cling.binding.xml.DeviceDescriptorBinder} for the UPnP 1.0 Device Architecture..
 */
public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10();