public void actionPerformed(ActionEvent e) { Application.copyToClipboard(resource.getProtocolInfo().toString()); } });
protected void generateResource(Res resource, Document descriptor, Element parent) { if (resource.getValue() == null) { throw new RuntimeException("Missing resource URI value" + resource); } if (resource.getProtocolInfo() == null) { throw new RuntimeException("Missing resource protocol info: " + resource); } Element resourceElement = appendNewElement(descriptor, parent, "res", resource.getValue()); resourceElement.setAttribute("protocolInfo", resource.getProtocolInfo().toString()); if (resource.getImportUri() != null) resourceElement.setAttribute("importUri", resource.getImportUri().toString()); if (resource.getSize() != null) resourceElement.setAttribute("size", resource.getSize().toString()); if (resource.getDuration() != null) resourceElement.setAttribute("duration", resource.getDuration()); if (resource.getBitrate() != null) resourceElement.setAttribute("bitrate", resource.getBitrate().toString()); if (resource.getSampleFrequency() != null) resourceElement.setAttribute("sampleFrequency", resource.getSampleFrequency().toString()); if (resource.getBitsPerSample() != null) resourceElement.setAttribute("bitsPerSample", resource.getBitsPerSample().toString()); if (resource.getNrAudioChannels() != null) resourceElement.setAttribute("nrAudioChannels", resource.getNrAudioChannels().toString()); if (resource.getColorDepth() != null) resourceElement.setAttribute("colorDepth", resource.getColorDepth().toString()); if (resource.getProtection() != null) resourceElement.setAttribute("protection", resource.getProtection()); if (resource.getResolution() != null) resourceElement.setAttribute("resolution", resource.getResolution()); }
protected boolean isProtocolInfoMatch(List<ProtocolInfo> supportedProtocols, Res resource) { ProtocolInfo resourceProtocolInfo = resource.getProtocolInfo(); if (!resourceProtocolInfo.getProtocol().equals(Protocol.HTTP_GET)) return false; MimeType resourceMimeType; try { resourceMimeType = resourceProtocolInfo.getContentFormatMimeType(); } catch (IllegalArgumentException ex) { ContentDirectoryControlPoint.LOGGER.warning( "Illegal resource mime type: " + resourceProtocolInfo.getContentFormat() ); return false; } for (ProtocolInfo supportedProtocol : supportedProtocols) { // We currently only support HTTP-GET if (!Protocol.HTTP_GET.equals(supportedProtocol.getProtocol())) continue; try { if (supportedProtocol.getContentFormatMimeType().equals(resourceMimeType)) { return true; } else if (supportedProtocol.getContentFormatMimeType().isCompatible(resourceMimeType)) { return true; } } catch (IllegalArgumentException ex) { ContentDirectoryControlPoint.LOGGER.warning( "Illegal MediaRenderer supported mime type: " + supportedProtocol.getContentFormat() ); } } return false; }
form.addLabelAndSelectableLastField("Import URI:", resource.getImportUri().toString(), this); form.addLabelAndSelectableLastField("Protocol Info:", resource.getProtocolInfo().toString(), this);
protected void generateResource(Res resource, Document descriptor, Element parent) { if (resource.getValue() == null) { throw new RuntimeException("Missing resource URI value" + resource); } if (resource.getProtocolInfo() == null) { throw new RuntimeException("Missing resource protocol info: " + resource); } Element resourceElement = appendNewElement(descriptor, parent, "res", resource.getValue()); resourceElement.setAttribute("protocolInfo", resource.getProtocolInfo().toString()); if (resource.getImportUri() != null) resourceElement.setAttribute("importUri", resource.getImportUri().toString()); if (resource.getSize() != null) resourceElement.setAttribute("size", resource.getSize().toString()); if (resource.getDuration() != null) resourceElement.setAttribute("duration", resource.getDuration()); if (resource.getBitrate() != null) resourceElement.setAttribute("bitrate", resource.getBitrate().toString()); if (resource.getSampleFrequency() != null) resourceElement.setAttribute("sampleFrequency", resource.getSampleFrequency().toString()); if (resource.getBitsPerSample() != null) resourceElement.setAttribute("bitsPerSample", resource.getBitsPerSample().toString()); if (resource.getNrAudioChannels() != null) resourceElement.setAttribute("nrAudioChannels", resource.getNrAudioChannels().toString()); if (resource.getColorDepth() != null) resourceElement.setAttribute("colorDepth", resource.getColorDepth().toString()); if (resource.getProtection() != null) resourceElement.setAttribute("protection", resource.getProtection()); if (resource.getResolution() != null) resourceElement.setAttribute("resolution", resource.getResolution()); }
public ContentItem(Service service, Item item) { this.service = service; didlObject = item; id = item.getId(); title = item.getTitle(); isContainer = false; try { format = item.getFirstResource().getProtocolInfo().getContentFormat(); } catch (Exception e) { e.printStackTrace(); } try { url = item.getFirstResource().getValue(); } catch (Exception e) { e.printStackTrace(); } }
protected void generateResource(Res resource, Document descriptor, Element parent) { if (resource.getValue() == null) { throw new RuntimeException("Missing resource URI value" + resource); } if (resource.getProtocolInfo() == null) { throw new RuntimeException("Missing resource protocol info: " + resource); } Element resourceElement = appendNewElement(descriptor, parent, "res", resource.getValue()); resourceElement.setAttribute("protocolInfo", resource.getProtocolInfo().toString()); if (resource.getImportUri() != null) resourceElement.setAttribute("importUri", resource.getImportUri().toString()); if (resource.getSize() != null) resourceElement.setAttribute("size", resource.getSize().toString()); if (resource.getDuration() != null) resourceElement.setAttribute("duration", resource.getDuration()); if (resource.getBitrate() != null) resourceElement.setAttribute("bitrate", resource.getBitrate().toString()); if (resource.getSampleFrequency() != null) resourceElement.setAttribute("sampleFrequency", resource.getSampleFrequency().toString()); if (resource.getBitsPerSample() != null) resourceElement.setAttribute("bitsPerSample", resource.getBitsPerSample().toString()); if (resource.getNrAudioChannels() != null) resourceElement.setAttribute("nrAudioChannels", resource.getNrAudioChannels().toString()); if (resource.getColorDepth() != null) resourceElement.setAttribute("colorDepth", resource.getColorDepth().toString()); if (resource.getProtection() != null) resourceElement.setAttribute("protection", resource.getProtection()); if (resource.getResolution() != null) resourceElement.setAttribute("resolution", resource.getResolution()); }
throw new RuntimeException("Missing resource URI value" + resource); if (resource.getProtocolInfo() == null) { throw new RuntimeException("Missing resource protocol info: " + resource); resourceElement.setAttribute("protocolInfo", resource.getProtocolInfo().toString()); if (resource.getImportUri() != null) resourceElement.setAttribute("importUri", resource.getImportUri().toString());
@Override public Response serve(IHTTPSession session) { String itemId = session.getUri().replaceFirst("/", ""); itemId = URLDecoder.decode(itemId); if (itemId != null && ContentTree.hasNode(itemId)) { ContentNode node = ContentTree.getNode(itemId); if (node.isItem()) { String localPath = node.getFullPath(); Long fileSize = node.getItem().getFirstResource().getSize(); String mimeType = node.getItem().getFirstResource() .getProtocolInfo().getContentFormatMimeType().toString(); return responseFile(mimeType, localPath, fileSize); } } Log.d(TAG, " response error!"); String msg = "<html><body><h1>Error</h1>\n" + "</body></html>\n"; return newFixedLengthResponse(msg); }
@Override public void received(ActionInvocation actionInvocation, DIDLContent didl) { LogUtil.d(TAG, "Received browse action DIDL descriptor, creating tree nodes"); try { handler.sendEmptyMessage(HandlerWhat.CLEAR_ALL); for (Container container : didl.getContainers()) { ContentItem ct = new ContentItem(container, service); sendMsg(ct); } for (Item item : didl.getItems()) { String contentFormat = item.getFirstResource().getProtocolInfo().getContentFormat(); ContentItem ct = new ContentItem(item, service, FiletypeUtil .getFiletype(contentFormat)); sendMsg(ct); } } catch (Exception e) { LogUtil.e(TAG, "Creating DIDL tree nodes failed: " + e); actionInvocation.setFailure(new ActionException( ErrorCode.ACTION_FAILED, "Can't create list childs: " + e, e)); failure(actionInvocation, null); } }