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; }
public DLNAProtocolInfo(ProtocolInfo template) { this(template.getProtocol(), template.getNetwork(), template.getContentFormat(), template.getAdditionalInfo() ); }
public DLNAProtocolInfo(ProtocolInfo template) { this(template.getProtocol(), template.getNetwork(), template.getContentFormat(), template.getAdditionalInfo() ); }
/** * 判断文件类型 * @param pInfo * @return */ public static int getFiletype(ProtocolInfo pInfo) { String contentFormat = pInfo.getContentFormat(); return getFiletype(contentFormat); }
public DLNAProtocolInfo(ProtocolInfo template) { this(template.getProtocol(), template.getNetwork(), template.getContentFormat(), template.getAdditionalInfo() ); }
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(); } }
@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); } }