protected Res createResource(Attributes attributes) { Res res = new Res(); res.setImportUri(URI.create(attributes.getValue("importUri"))); res.setProtocolInfo( new ProtocolInfo(attributes.getValue("protocolInfo")) ); res.setSize(toLongOrNull(attributes.getValue("size"))); res.setDuration(attributes.getValue("duration")); res.setBitrate(toLongOrNull(attributes.getValue("bitrate"))); res.setSampleFrequency(toLongOrNull(attributes.getValue("sampleFrequency"))); res.setBitsPerSample(toLongOrNull(attributes.getValue("bitsPerSample"))); res.setNrAudioChannels(toLongOrNull(attributes.getValue("nrAudioChannels"))); res.setColorDepth(toLongOrNull(attributes.getValue("colorDepth"))); res.setProtection(attributes.getValue("protection")); res.setResolution(attributes.getValue("resolution"));
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()); }
String resolution = cur.getString(cur.getColumnIndex(Video.Media.RESOLUTION)); Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')), mimeType.substring(mimeType.indexOf('/') + 1)), size, resAddress + id); res.setDuration(DurationUtil.toMilliTimeString(duration)); res.setResolution(resolution); VideoItem videoItem = new VideoItem(id, ContentTree.VIDEO_ID, title, creator, filePath, res); items.add(videoItem);
@Nonnull private Res audioResourceOf (final @Nonnull AudioFile audioFile) { final ProtocolInfo protocolInfo = new DLNAProtocolInfo(Protocol.HTTP_GET, "*", "audio/mpeg", "*"); // FIXME: MIME final Metadata audioFileMetadata = audioFile.getMetadata(); final Res resource = new Res(protocolInfo, audioFileMetadata.get(FILE_SIZE).orElse(null), server.absoluteUrl(String.format("rest/audiofile/%s/content", audioFile.getId().stringValue()))); audioFileMetadata.get(DURATION).ifPresent(duration -> resource.setDuration(durationToString(duration))); audioFileMetadata.get(BIT_RATE).ifPresent(bitRate -> resource.setBitrate((long)(int)bitRate)); audioFileMetadata.get(BITS_PER_SAMPLE).ifPresent(bitPerSample -> resource.setBitsPerSample((long)(int)bitPerSample)); audioFileMetadata.get(CHANNELS).ifPresent(channels -> resource.setNrAudioChannels((long)(int)channels)); audioFileMetadata.get(SAMPLE_RATE).ifPresent(sampleRate -> resource.setSampleFrequency((long)(int)sampleRate)); return resource; }
originalResource.setValue( originalUri.toString() ); new DLNAFlagsAttribute( DLNAFlags.STREAMING_TRANSFER_MODE, DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15 ) ); originalResource.setProtocolInfo( new DLNAProtocolInfo( Protocol.HTTP_GET, ProtocolInfo.WILDCARD, mime, dlnaAttributes ) ); originalResource.setResolution( image.getWidth(), image.getHeight() ); originalResource.setColorDepth( (long) image.getColorDepth() ); originalResource.setSize( image.getSize() ); transcodedResource.setValue( transcodedUri.toString() ); new DLNAFlagsAttribute( DLNAFlags.STREAMING_TRANSFER_MODE, DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15 ) ); transcodedResource.setProtocolInfo( new DLNAProtocolInfo( Protocol.HTTP_GET, ProtocolInfo.WILDCARD, mime, dlnaAttributes ) ); transcodedResource.setResolution( image.getWidth(), image.getHeight() ); transcodedResource.setColorDepth( (long) image.getColorDepth() );
public void actionPerformed(ActionEvent e) { Application.copyToClipboard(resource.getValue()); } });
String album = cur.getString(cur.getColumnIndex(Audio.Media.ALBUM)); Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')), mimeType.substring(mimeType.indexOf('/') + 1)), size, resAddress + id); res.setDuration(DurationUtil.toMilliTimeString(duration)); MusicTrack musicTrack = new MusicTrack(id, ContentTree.AUDIO_ID, title, creator, album, new PersonWithRole(creator, "Performer"), filePath, res);
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private Res createResource (final @Nonnull ProtocolInfo protocolInfo, final int size) { final Res resource = new Res(protocolInfo, null, computeUrl(size)); resource.setResolution(size, size); return resource; }
@Override public Res getResource() { return new Res(); }
String token = loginDLNA( user.getLogin(), user.getPassword() ); Res resource = new Res(); EnumMap<DLNAAttribute.Type, DLNAAttribute> dlnaAttributes = new EnumMap<DLNAAttribute.Type, DLNAAttribute>( DLNAAttribute.Type.class ); resource.setValue( originalUri.toString() ); DLNAProfiles originalProfile = DLNAProfiles.MP3; dlnaAttributes.put( DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute( originalProfile ) ); DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15 ) ); resource.setProtocolInfo( new DLNAProtocolInfo( Protocol.HTTP_GET, ProtocolInfo.WILDCARD, "audio/mp3", dlnaAttributes ) );
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(); } }
public int getResolutionX() { return getResolution() != null && getResolution().split("x").length == 2 ? Integer.valueOf(getResolution().split("x")[0]) : 0; }
@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 String getCount() { List<Res> res = item.getResources(); if(res!=null && res.size()>0) return "" + ((res.get(0).getDuration()!=null) ? res.get(0).getDuration().split("\\.")[0] : ""); return ""; }
public void actionPerformed(ActionEvent e) { Application.copyToClipboard(resource.getProtocolInfo().toString()); } });
extension = filePath.substring(dot).toLowerCase(); Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')), mimeType.substring(mimeType.indexOf('/') + 1)), size, "http://" + baseURL + "/" + id + extension); res.setDuration(duration / (1000 * 60 * 60) + ":" + (duration % (1000 * 60 * 60)) / (1000 * 60) + ":" + (duration % (1000 * 60)) / 1000); res.setResolution((int) width, (int) height);
originalResource.setValue( originalUri.toString() ); new DLNAFlagsAttribute( DLNAFlags.STREAMING_TRANSFER_MODE, DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15 ) ); originalResource.setProtocolInfo( new DLNAProtocolInfo( Protocol.HTTP_GET, ProtocolInfo.WILDCARD, mime, dlnaAttributes ) ); originalResource.setResolution( image.getWidth(), image.getHeight() ); originalResource.setColorDepth( (long) image.getColorDepth() ); originalResource.setSize( image.getSize() ); transcodedResource.setValue( transcodedUri.toString() ); new DLNAFlagsAttribute( DLNAFlags.STREAMING_TRANSFER_MODE, DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15 ) ); transcodedResource.setProtocolInfo( new DLNAProtocolInfo( Protocol.HTTP_GET, ProtocolInfo.WILDCARD, mime, dlnaAttributes ) ); transcodedResource.setResolution( image.getWidth(), image.getHeight() ); transcodedResource.setColorDepth( (long) image.getColorDepth() );
extension = filePath.substring(dot).toLowerCase(); Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')), mimeType.substring(mimeType.indexOf('/') + 1)), size, "http://" + baseURL + "/" + id + extension); res.setDuration(duration / (1000 * 60 * 60) + ":" + (duration % (1000 * 60 * 60)) / (1000 * 60) + ":" + (duration % (1000 * 60)) / 1000);
extension = filePath.substring(dot).toLowerCase(); Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')), mimeType.substring(mimeType.indexOf('/') + 1)), size, "http://" + baseURL + "/" + id + extension); res.setResolution((int) width, (int) height);