org.fourthline.cling.model.meta.Service Java Examples
The following examples show how to use
org.fourthline.cling.model.meta.Service.
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 Project: TVRemoteIME Author: kingthy File: UDA10DeviceDescriptorBinderImpl.java License: GNU General Public License v2.0 | 6 votes |
protected void generateServiceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) { if (!deviceModel.hasServices()) return; Element serviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.serviceList); for (Service service : deviceModel.getServices()) { Element serviceElement = appendNewElement(descriptor, serviceListElement, ELEMENT.service); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceType, service.getServiceType()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceId, service.getServiceId()); if (service instanceof RemoteService) { RemoteService rs = (RemoteService) service; appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, rs.getDescriptorURI()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, rs.getControlURI()); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, rs.getEventSubscriptionURI()); } else if (service instanceof LocalService) { LocalService ls = (LocalService) service; appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, namespace.getDescriptorPath(ls)); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, namespace.getControlPath(ls)); appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, namespace.getEventSubscriptionPath(ls)); } } }
Example #2
Source Project: DroidDLNA Author: offbye File: UDA10ServiceDescriptorBinderImpl.java License: GNU General Public License v3.0 | 6 votes |
public Document buildDOM(Service service) throws DescriptorBindingException { try { log.fine("Generting XML descriptor from service model: " + service); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().newDocument(); generateScpd(service, d); return d; } catch (Exception ex) { throw new DescriptorBindingException("Could not generate service descriptor: " + ex.getMessage(), ex); } }
Example #3
Source Project: TVRemoteIME Author: kingthy File: UDA10ServiceDescriptorBinderImpl.java License: GNU General Public License v2.0 | 6 votes |
public Document buildDOM(Service service) throws DescriptorBindingException { try { log.fine("Generting XML descriptor from service model: " + service); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().newDocument(); generateScpd(service, d); return d; } catch (Exception ex) { throw new DescriptorBindingException("Could not generate service descriptor: " + ex.getMessage(), ex); } }
Example #4
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 6 votes |
public void setMute(boolean paramBoolean) { try { Service localService = this.executeDeviceItem.getDevice() .findService(new UDAServiceType("RenderingControl")); if (localService != null) { ControlPoint localControlPoint = this.upnpService .getControlPoint(); localControlPoint.execute(new SetMuteCalllback(localService, paramBoolean, mHandle)); } else { Log.e("null", "null"); } } catch (Exception localException) { localException.printStackTrace(); } }
Example #5
Source Project: BeyondUPnP Author: kevinshine File: PlaybackCommand.java License: Apache License 2.0 | 6 votes |
public static void play() { Device device = SystemManager.getInstance().getSelectedDevice(); //Check selected device if (device == null) return; Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE); if (avtService != null) { ControlPoint cp = SystemManager.getInstance().getControlPoint(); cp.execute(new Play(avtService) { @Override public void success(ActionInvocation invocation) { Log.i(TAG, "Play success."); } @Override public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) { Log.e(TAG, "Play failed"); } }); } }
Example #6
Source Project: DroidDLNA Author: offbye File: PortMappingListener.java License: GNU General Public License v3.0 | 6 votes |
protected Service discoverConnectionService(Device device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { return null; } Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { log.fine("IGD doesn't support '" + CONNECTION_DEVICE_TYPE + "': " + device); return null; } Device connectionDevice = connectionDevices[0]; log.fine("Using first discovered WAN connection device: " + connectionDevice); Service ipConnectionService = connectionDevice.findService(IP_SERVICE_TYPE); Service pppConnectionService = connectionDevice.findService(PPP_SERVICE_TYPE); if (ipConnectionService == null && pppConnectionService == null) { log.fine("IGD doesn't support IP or PPP WAN connection service: " + device); } return ipConnectionService != null ? ipConnectionService : pppConnectionService; }
Example #7
Source Project: BeyondUPnP Author: kevinshine File: PlaybackCommand.java License: Apache License 2.0 | 6 votes |
public static void getVolume(final Handler handler) { Device device = SystemManager.getInstance().getSelectedDevice(); //Check selected device if (device == null) return; Service rcService = device.findService(SystemManager.RENDERING_CONTROL_SERVICE); if (rcService != null) { ControlPoint cp = SystemManager.getInstance().getControlPoint(); cp.execute(new GetVolume(rcService) { @Override public void received(ActionInvocation actionInvocation, int currentVolume) { //Send currentVolume to handler. Log.i(TAG, "GetVolume:" + currentVolume); Message msg = Message.obtain(handler, NowplayingFragment.GET_VOLUME_ACTION, currentVolume, 0); msg.sendToTarget(); } @Override public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) { Log.e(TAG, "GetVolume failed"); } }); } }
Example #8
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 6 votes |
public void getVolume(int paramInt) { try { Service localService = this.executeDeviceItem.getDevice() .findService(new UDAServiceType("RenderingControl")); if (localService != null) { Log.e("get volume", "get volume"); this.upnpService.getControlPoint().execute( new GetVolumeCallback(this.activity, mHandle, paramInt, localService, this.controlType)); } else { Log.e("null", "null"); } } catch (Exception localException) { localException.printStackTrace(); } }
Example #9
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 6 votes |
public void seekBarPosition(String paramString) { try { Device localDevice = this.executeDeviceItem.getDevice(); Log.e("control action", "seekBarPosition"); Service localService = localDevice.findService(new UDAServiceType( "AVTransport")); if (localService != null) { Log.e("get seekBarPosition info", "get seekBarPosition info"); this.upnpService.getControlPoint().execute( new SeekCallback(activity, localService, paramString, mHandle)); } else { Log.e("null", "null"); } } catch (Exception localException) { localException.printStackTrace(); } }
Example #10
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 6 votes |
public void setVolume(long paramLong, int paramInt) { if (paramInt == 0) { } Service localService = null; try { localService = this.executeDeviceItem.getDevice().findService( new UDAServiceType("RenderingControl")); if (localService != null) { if (paramInt == CUT_VOC) { if (paramLong >= 0L) { paramLong -= 1L; } else { Toast.makeText(activity, R.string.min_voc, Toast.LENGTH_SHORT).show(); } } else { paramLong += 1L; } this.upnpService.getControlPoint().execute( new SetVolumeCallback(localService, paramLong)); } } catch (Exception localException) { localException.printStackTrace(); } }
Example #11
Source Project: TVRemoteIME Author: kingthy File: Search.java License: GNU General Public License v2.0 | 6 votes |
/** * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used. */ public Search(Service service, String containerId, String searchCriteria, String filter, long firstResult, Long maxResults, SortCriterion... orderBy) { super(new ActionInvocation(service.getAction("Search"))); log.fine("Creating browse action for container ID: " + containerId); getActionInvocation().setInput("ContainerID", containerId); getActionInvocation().setInput("SearchCriteria", searchCriteria); getActionInvocation().setInput("Filter", filter); getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult)); getActionInvocation().setInput( "RequestedCount", new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults) ); getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy)); }
Example #12
Source Project: TVRemoteIME Author: kingthy File: MutableDevice.java License: GNU General Public License v2.0 | 5 votes |
public Service[] createServices(Device prototype) throws ValidationException { Service[] services = prototype.newServiceArray(this.services.size()); int i = 0; for (MutableService service : this.services) { services[i++] = service.build(prototype); } return services; }
Example #13
Source Project: DroidDLNA Author: offbye File: RegistryImpl.java License: GNU General Public License v3.0 | 5 votes |
synchronized public Service getService(ServiceReference serviceReference) { Device device; if ((device = getDevice(serviceReference.getUdn(), false)) != null) { return device.findService(serviceReference.getServiceId()); } return null; }
Example #14
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 5 votes |
public void stop(Boolean paramBoolean) { try { Service localService = this.executeDeviceItem.getDevice() .findService(new UDAServiceType("AVTransport")); if (localService != null) { this.upnpService.getControlPoint().execute( new StopCallback(localService, mHandle, paramBoolean, this.controlType)); } else { Log.e("null", "null"); } } catch (Exception localException) { localException.printStackTrace(); } }
Example #15
Source Project: HPlayer Author: hezhubo File: ContentItem.java License: Apache License 2.0 | 5 votes |
public ContentItem(Service service, Container container) { this.service = service; didlObject = container; id = container.getId(); title = container.getTitle(); isContainer = true; }
Example #16
Source Project: TVRemoteIME Author: kingthy File: UDA10ServiceDescriptorBinderImpl.java License: GNU General Public License v2.0 | 5 votes |
private void generateServiceStateTable(Service serviceModel, Document descriptor, Element scpdElement) { Element serviceStateTableElement = appendNewElement(descriptor, scpdElement, ELEMENT.serviceStateTable); for (StateVariable stateVariable : serviceModel.getStateVariables()) { generateStateVariable(stateVariable, descriptor, serviceStateTableElement); } }
Example #17
Source Project: DroidDLNA Author: offbye File: GetTransportInfoCallback.java License: GNU General Public License v3.0 | 5 votes |
public GetTransportInfoCallback(Service paramService, Handler paramHandler, boolean paramBoolean, int paramInt) { super(paramService); this.handler = paramHandler; this.isOnlyGetState = paramBoolean; this.type = paramInt; }
Example #18
Source Project: DroidDLNA Author: offbye File: PortMappingListener.java License: GNU General Public License v3.0 | 5 votes |
@Override synchronized public void deviceRemoved(Registry registry, Device device) { for (Service service : device.findServices()) { Iterator<Map.Entry<Service, List<PortMapping>>> it = activePortMappings.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Service, List<PortMapping>> activeEntry = it.next(); if (!activeEntry.getKey().equals(service)) continue; if (activeEntry.getValue().size() > 0) handleFailureMessage("Device disappeared, couldn't delete port mappings: " + activeEntry.getValue().size()); it.remove(); } } }
Example #19
Source Project: DroidDLNA Author: offbye File: ContentItem.java License: GNU General Public License v3.0 | 5 votes |
public ContentItem(Container container, Service service) { // TODO Auto-generated constructor stub this.service = service; this.content = container; this.id = container.getId(); this.isContainer = true; }
Example #20
Source Project: DroidDLNA Author: offbye File: SetAVTransportURI.java License: GNU General Public License v3.0 | 5 votes |
public SetAVTransportURI(UnsignedIntegerFourBytes instanceId, Service service, String uri, String metadata) { super(new ActionInvocation(service.getAction("SetAVTransportURI"))); log.fine("Creating SetAVTransportURI action for URI: " + uri); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("CurrentURI", uri); getActionInvocation().setInput("CurrentURIMetaData", metadata); }
Example #21
Source Project: TVRemoteIME Author: kingthy File: PortMapping.java License: GNU General Public License v2.0 | 5 votes |
public PortMapping(Map<String, ActionArgumentValue<Service>> map) { this( (Boolean) map.get("NewEnabled").getValue(), (UnsignedIntegerFourBytes) map.get("NewLeaseDuration").getValue(), (String) map.get("NewRemoteHost").getValue(), (UnsignedIntegerTwoBytes) map.get("NewExternalPort").getValue(), (UnsignedIntegerTwoBytes) map.get("NewInternalPort").getValue(), (String) map.get("NewInternalClient").getValue(), Protocol.valueOf(map.get("NewProtocol").toString()), (String) map.get("NewPortMappingDescription").getValue() ); }
Example #22
Source Project: DroidDLNA Author: offbye File: DMCControl.java License: GNU General Public License v3.0 | 5 votes |
public void getMute() { try { Service localService = this.executeDeviceItem.getDevice() .findService(new UDAServiceType("RenderingControl")); if (localService != null) { this.upnpService.getControlPoint().execute( new GetMuteCallback(localService, mHandle)); } else { } } catch (Exception localException) { localException.printStackTrace(); } }
Example #23
Source Project: TVRemoteIME Author: kingthy File: RegistryImpl.java License: GNU General Public License v2.0 | 5 votes |
synchronized public Service getService(ServiceReference serviceReference) { Device device; if ((device = getDevice(serviceReference.getUdn(), false)) != null) { return device.findService(serviceReference.getServiceId()); } return null; }
Example #24
Source Project: DroidDLNA Author: offbye File: GetProtocolInfoCallback.java License: GNU General Public License v3.0 | 5 votes |
public GetProtocolInfoCallback(Service paramService, ControlPoint paramControlPoint, String paramString, Handler paramHandler) { super(paramService, paramControlPoint); this.requestPlayMimeType = paramString; this.handler = paramHandler; }
Example #25
Source Project: DroidDLNA Author: offbye File: Namespace.java License: GNU General Public License v3.0 | 5 votes |
public URI getPath(Service service) { if (service.getServiceId() == null) { throw new IllegalStateException("Can't generate local URI prefix without service ID"); } StringBuilder s = new StringBuilder(); s.append(SERVICE); s.append("/"); s.append(service.getServiceId().getNamespace()); s.append("/"); s.append(service.getServiceId().getId()); return URI.create(getPath(service.getDevice()).toString() + s.toString()); }
Example #26
Source Project: DroidDLNA Author: offbye File: ContentBrowseActionCallback.java License: GNU General Public License v3.0 | 5 votes |
public ContentBrowseActionCallback(Activity activity, Service service, Container container, ArrayList<ContentItem> list, Handler handler) { super(service, container.getId(), BrowseFlag.DIRECT_CHILDREN, "*", 0, null, new SortCriterion(true, "dc:title")); this.activity = activity; this.service = service; this.container = container; this.list = list; this.handler = handler; }
Example #27
Source Project: TVRemoteIME Author: kingthy File: ActionCallback.java License: GNU General Public License v2.0 | 4 votes |
public void run() { Service service = actionInvocation.getAction().getService(); // Local execution if (service instanceof LocalService) { LocalService localService = (LocalService)service; // Executor validates input inside the execute() call immediately localService.getExecutor(actionInvocation.getAction()).execute(actionInvocation); if (actionInvocation.getFailure() != null) { failure(actionInvocation, null); } else { success(actionInvocation); } // Remote execution } else if (service instanceof RemoteService){ if (getControlPoint() == null) { throw new IllegalStateException("Callback must be executed through ControlPoint"); } RemoteService remoteService = (RemoteService)service; // Figure out the remote URL where we'd like to send the action request to URL controLURL = remoteService.getDevice().normalizeURI(remoteService.getControlURI()); // Do it SendingAction prot = getControlPoint().getProtocolFactory().createSendingAction(actionInvocation, controLURL); prot.run(); IncomingActionResponseMessage response = prot.getOutputMessage(); if (response == null) { failure(actionInvocation, null); } else if (response.getOperation().isFailed()) { failure(actionInvocation, response.getOperation()); } else { success(actionInvocation); } } }
Example #28
Source Project: DroidDLNA Author: offbye File: Stop.java License: GNU General Public License v3.0 | 4 votes |
public Stop(UnsignedIntegerFourBytes instanceId, Service service) { super(new ActionInvocation(service.getAction("Stop"))); getActionInvocation().setInput("InstanceID", instanceId); }
Example #29
Source Project: portmapper Author: kaklakariada File: ClingRouter.java License: GNU General Public License v3.0 | 4 votes |
private static String getName(final Service<?, ?> service) { return service.getDevice().getDisplayString(); }
Example #30
Source Project: DroidDLNA Author: offbye File: Seek.java License: GNU General Public License v3.0 | 4 votes |
public Seek(UnsignedIntegerFourBytes instanceId, Service service, String relativeTimeTarget) { this(instanceId, service, SeekMode.REL_TIME, relativeTimeTarget); }