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

The following examples show how to use org.fourthline.cling.model.meta.Icon. 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: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #2
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #3
Source File: ZxtMediaRenderer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected Icon createDefaultDeviceIcon() {
    try {
        return new Icon("image/png", 48, 48, 32, "msi.png", mContext.getResources().getAssets()
                .open(FileUtil.LOGO));
    } catch (IOException e) {
        Log.w(TAG, "createDefaultDeviceIcon IOException");
        return null;
    }
}
 
Example #4
Source File: MutableDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public Icon[] createIcons() {
    Icon[] iconArray = new Icon[icons.size()];
    int i = 0;
    for (MutableIcon icon : icons) {
        iconArray[i++] = icon.build();
    }
    return iconArray;
}
 
Example #5
Source File: MediaServer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected Icon createDefaultDeviceIcon() {
    try {
        return new Icon("image/png", 48, 48, 32, "msi.png", mContext.getResources().getAssets()
                .open(FileUtil.LOGO));
    } catch (IOException e) {
        Log.w(LOGTAG, "createDefaultDeviceIcon IOException");
        return null;
    }
}
 
Example #6
Source File: ZxtMediaRenderer.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected Icon createDefaultDeviceIcon() {
    try {
        return new Icon("image/png", 48, 48, 32, "msi.png", mContext.getResources().getAssets()
                .open(FileUtil.LOGO));
    } catch (IOException e) {
        Log.w(TAG, "createDefaultDeviceIcon IOException");
        return null;
    }
}
 
Example #7
Source File: MutableDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public Icon[] createIcons() {
    Icon[] iconArray = new Icon[icons.size()];
    int i = 0;
    for (MutableIcon icon : icons) {
        iconArray[i++] = icon.build();
    }
    return iconArray;
}
 
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: ZxtMediaRenderer.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ZxtMediaRenderer(int numberOfPlayers,Context context) {
         mContext = context;

        // This is the backend which manages the actual player instances
        mediaPlayers = new ZxtMediaPlayers(
                numberOfPlayers,
                context,
                avTransportLastChange,
                renderingControlLastChange
        ) {
            // These overrides connect the player instances to the output/display
            @Override
            protected void onPlay(ZxtMediaPlayer player) {
//                getDisplayHandler().onPlay(player);
            }

            @Override
            protected void onStop(ZxtMediaPlayer player) {
//                getDisplayHandler().onStop(player);
            }
        };

        // The connection manager doesn't have to do much, HTTP is stateless
        LocalService connectionManagerService = binder.read(ZxtConnectionManagerService.class);
        connectionManager =
                new DefaultServiceManager(connectionManagerService) {
                    @Override
                    protected Object createServiceInstance() throws Exception {
                        return new ZxtConnectionManagerService();
                    }
                };
        connectionManagerService.setManager(connectionManager);

        // The AVTransport just passes the calls on to the backend players
        LocalService<AVTransportService> avTransportService = binder.read(AVTransportService.class);
        avTransport =
                new LastChangeAwareServiceManager<AVTransportService>(
                        avTransportService,
                        new AVTransportLastChangeParser()
                ) {
                    @Override
                    protected AVTransportService createServiceInstance() throws Exception {
                        return new AVTransportService(avTransportLastChange, mediaPlayers);
                    }
                };
        avTransportService.setManager(avTransport);

        // The Rendering Control just passes the calls on to the backend players
        LocalService<AudioRenderingControl> renderingControlService = binder.read(AudioRenderingControl.class);
        renderingControl =
                new LastChangeAwareServiceManager<AudioRenderingControl>(
                        renderingControlService,
                        new RenderingControlLastChangeParser()
                ) {
                    @Override
                    protected AudioRenderingControl createServiceInstance() throws Exception {
                        return new AudioRenderingControl(renderingControlLastChange, mediaPlayers);
                    }
                };
        renderingControlService.setManager(renderingControl);

        try {
            UDN  udn = UpnpUtil.uniqueSystemIdentifier("msidmr");

            device = new LocalDevice(
                    //TODO zxt

                    new DeviceIdentity(udn),
                    new UDADeviceType("MediaRenderer", 1),
                    new DeviceDetails(
                             SettingActivity.getRenderName(context) + " (" + android.os.Build.MODEL + ")",
                            new ManufacturerDetails(Utils.MANUFACTURER),
                            new ModelDetails(Utils.DMR_NAME, Utils.DMR_DESC, "1", Utils.DMR_MODEL_URL),
                            new DLNADoc[] {
                                new DLNADoc("DMR", DLNADoc.Version.V1_5)
                            }, new DLNACaps(new String[] {
                                 "av-upload", "image-upload", "audio-upload"
                            })
                    ),
                    new Icon[]{createDefaultDeviceIcon()},
                    new LocalService[]{
                            avTransportService,
                            renderingControlService,
                            connectionManagerService
                    }
            );
            Log.i(TAG,  "getType: " +  device.getType().toString());
        } catch (ValidationException ex) {
            throw new RuntimeException(ex);
        }

        runLastChangePushThread();
    }
 
Example #10
Source File: Namespace.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public URI getIconPath(Icon icon) {
    return URI.create(getPath(icon.getDevice()).toString() + "/" + icon.getUri().toString());
}
 
Example #11
Source File: IconResource.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public IconResource(URI localURI, Icon model) {
    super(localURI, model);
}
 
Example #12
Source File: MutableIcon.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Icon build() {
    return new Icon(mimeType, width, height, depth, uri);
}
 
Example #13
Source File: RetrieveRemoteDescriptors.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected RemoteDevice describeServices(RemoteDevice currentDevice)
        throws RouterException, DescriptorBindingException, ValidationException {

    List<RemoteService> describedServices = new ArrayList();
    if (currentDevice.hasServices()) {
        List<RemoteService> filteredServices = filterExclusiveServices(currentDevice.getServices());
        for (RemoteService service : filteredServices) {
            RemoteService svc = describeService(service);
            if (svc == null) { // Something went wrong, bail out
                return null;
            }
            describedServices.add(svc);
        }
    }

    List<RemoteDevice> describedEmbeddedDevices = new ArrayList();
    if (currentDevice.hasEmbeddedDevices()) {
        for (RemoteDevice embeddedDevice : currentDevice.getEmbeddedDevices()) {
            if (embeddedDevice == null) continue;
            RemoteDevice describedEmbeddedDevice = describeServices(embeddedDevice);
            if (describedEmbeddedDevice == null) { // Something was wrong, recursively
                return null;
            }
            describedEmbeddedDevices.add(describedEmbeddedDevice);
        }
    }

    Icon[] iconDupes = new Icon[currentDevice.getIcons().length];
    for (int i = 0; i < currentDevice.getIcons().length; i++) {
        Icon icon = currentDevice.getIcons()[i];
        iconDupes[i] = icon.deepCopy();
    }

    // Yes, we create a completely new immutable graph here
    return currentDevice.newInstance(
            currentDevice.getIdentity().getUdn(),
            currentDevice.getVersion(),
            currentDevice.getType(),
            currentDevice.getDetails(),
            iconDupes,
            currentDevice.toServiceArray(describedServices),
            describedEmbeddedDevices
    );
}
 
Example #14
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 #15
Source File: UPnPService.java    From subsonic with GNU General Public License v3.0 4 votes vote down vote up
private LocalDevice createMediaServerDevice() throws Exception {

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

        // TODO: DLNACaps
        Version version = versionService.getLocalVersion();
        String versionString = version == null ? null : version.toString();
        String licenseEmail = settingsService.getLicenseEmail();
        String licenseString = licenseEmail == null ? "Unlicensed" : ("Licensed to " + licenseEmail);

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

        Icon icon = new Icon("image/png", 512, 512, 32, getClass().getResource("subsonic-512.png"));

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

            @Override
            protected FolderBasedContentDirectory createServiceInstance() throws Exception {
                return folderBasedContentDirectory;
            }
        });

        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() throws Exception {
                return new ConnectionManagerService(protocols, null);
            }
        });

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

        return new LocalDevice(identity, type, details, new Icon[]{icon}, new LocalService[]{contentDirectoryservice, connetionManagerService, receiverService});
    }
 
Example #16
Source File: ZxtMediaRenderer.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public ZxtMediaRenderer(int numberOfPlayers, String name, Context context) {
         mContext = context;

        // This is the backend which manages the actual player instances
        mediaPlayers = new ZxtMediaPlayers(
                numberOfPlayers,
                context,
                avTransportLastChange,
                renderingControlLastChange
        ) {
            // These overrides connect the player instances to the output/display
            @Override
            protected void onPlay(ZxtMediaPlayer player) {
//                getDisplayHandler().onPlay(player);
            }

            @Override
            protected void onStop(ZxtMediaPlayer player) {
//                getDisplayHandler().onStop(player);
            }
        };

        // The connection manager doesn't have to do much, HTTP is stateless
        LocalService connectionManagerService = binder.read(ZxtConnectionManagerService.class);
        connectionManager =
                new DefaultServiceManager(connectionManagerService) {
                    @Override
                    protected Object createServiceInstance() throws Exception {
                        return new ZxtConnectionManagerService();
                    }
                };
        connectionManagerService.setManager(connectionManager);

        // The AVTransport just passes the calls on to the backend players
        LocalService<AVTransportService> avTransportService = binder.read(AVTransportService.class);
        avTransport =
                new LastChangeAwareServiceManager<AVTransportService>(
                        avTransportService,
                        new AVTransportLastChangeParser()
                ) {
                    @Override
                    protected AVTransportService createServiceInstance() throws Exception {
                        return new AVTransportService(avTransportLastChange, mediaPlayers);
                    }
                };
        avTransportService.setManager(avTransport);

        // The Rendering Control just passes the calls on to the backend players
        LocalService<AudioRenderingControl> renderingControlService = binder.read(AudioRenderingControl.class);
        renderingControl =
                new LastChangeAwareServiceManager<AudioRenderingControl>(
                        renderingControlService,
                        new RenderingControlLastChangeParser()
                ) {
                    @Override
                    protected AudioRenderingControl createServiceInstance() throws Exception {
                        return new AudioRenderingControl(renderingControlLastChange, mediaPlayers);
                    }
                };
        renderingControlService.setManager(renderingControl);

        try {
            UDN  udn = UpnpUtil.uniqueSystemIdentifier("msidmr");

            device = new LocalDevice(
                    //TODO zxt

                    new DeviceIdentity(udn),
                    new UDADeviceType("MediaRenderer", 1),
                    new DeviceDetails(
                            name,
                            new ManufacturerDetails(Utils.MANUFACTURER),
                            new ModelDetails(Utils.DMR_NAME, Utils.DMR_DESC, "1", Utils.DMR_MODEL_URL),
                            new DLNADoc[] {
                                new DLNADoc("DMR", DLNADoc.Version.V1_5)
                            }, new DLNACaps(new String[] {
                                 "av-upload"  //, "image-upload", "audio-upload"
                            })
                    ),
                    new Icon[]{createDefaultDeviceIcon()},
                    new LocalService[]{
                            avTransportService,
                            renderingControlService,
                            connectionManagerService
                    }
            );
            Log.i(TAG,  "getType: " +  device.getType().toString());
        } catch (ValidationException ex) {
            throw new RuntimeException(ex);
        }

        runLastChangePushThread();
    }
 
Example #17
Source File: Namespace.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public URI getIconPath(Icon icon) {
    return URI.create(getPath(icon.getDevice()).toString() + "/" + icon.getUri().toString());
}
 
Example #18
Source File: IconResource.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public IconResource(URI localURI, Icon model) {
    super(localURI, model);
}
 
Example #19
Source File: MutableIcon.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Icon build() {
    return new Icon(mimeType, width, height, depth, uri);
}
 
Example #20
Source File: RetrieveRemoteDescriptors.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected RemoteDevice describeServices(RemoteDevice currentDevice)
        throws RouterException, DescriptorBindingException, ValidationException {

    List<RemoteService> describedServices = new ArrayList();
    if (currentDevice.hasServices()) {
        List<RemoteService> filteredServices = filterExclusiveServices(currentDevice.getServices());
        for (RemoteService service : filteredServices) {
            RemoteService svc = describeService(service);
            if (svc == null) { // Something went wrong, bail out
                return null;
            }
            describedServices.add(svc);
        }
    }

    List<RemoteDevice> describedEmbeddedDevices = new ArrayList();
    if (currentDevice.hasEmbeddedDevices()) {
        for (RemoteDevice embeddedDevice : currentDevice.getEmbeddedDevices()) {
            if (embeddedDevice == null) continue;
            RemoteDevice describedEmbeddedDevice = describeServices(embeddedDevice);
            if (describedEmbeddedDevice == null) { // Something was wrong, recursively
                return null;
            }
            describedEmbeddedDevices.add(describedEmbeddedDevice);
        }
    }

    Icon[] iconDupes = new Icon[currentDevice.getIcons().length];
    for (int i = 0; i < currentDevice.getIcons().length; i++) {
        Icon icon = currentDevice.getIcons()[i];
        iconDupes[i] = icon.deepCopy();
    }

    // Yes, we create a completely new immutable graph here
    return currentDevice.newInstance(
            currentDevice.getIdentity().getUdn(),
            currentDevice.getVersion(),
            currentDevice.getType(),
            currentDevice.getDetails(),
            iconDupes,
            currentDevice.toServiceArray(describedServices),
            describedEmbeddedDevices
    );
}