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 File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #4
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #7
Source File: Search.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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 #8
Source File: UDA10ServiceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: PortMappingListener.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source File: UDA10ServiceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
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 #12
Source File: ContentItem.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #13
Source File: PortMappingListener.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@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 #14
Source File: UDA10ServiceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
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 #15
Source File: ContentBrowseActionCallback.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #16
Source File: RegistryImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public Service getService(ServiceReference serviceReference) {
    Device device;
    if ((device = getDevice(serviceReference.getUdn(), false)) != null) {
        return device.findService(serviceReference.getServiceId());
    }
    return null;
}
 
Example #17
Source File: ContentItem.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
public ContentItem(Service service, Container container) {
    this.service = service;
    didlObject = container;
    id = container.getId();
    title = container.getTitle();
    isContainer = true;
}
 
Example #18
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #19
Source File: GetTransportInfoCallback.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public GetTransportInfoCallback(Service paramService, Handler paramHandler,
        boolean paramBoolean, int paramInt) {
    super(paramService);
    this.handler = paramHandler;
    this.isOnlyGetState = paramBoolean;
    this.type = paramInt;
}
 
Example #20
Source File: GetProtocolInfoCallback.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public GetProtocolInfoCallback(Service paramService,
		ControlPoint paramControlPoint, String paramString,
		Handler paramHandler) {
	super(paramService, paramControlPoint);
	this.requestPlayMimeType = paramString;
	this.handler = paramHandler;
}
 
Example #21
Source File: Namespace.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #22
Source File: SetAVTransportURI.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #23
Source File: RegistryImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
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 File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: MutableDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source File: PortMapping.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
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 #27
Source File: GetCurrentTransportActions.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public GetCurrentTransportActions(Service service) {
    this(new UnsignedIntegerFourBytes(0), service);
}
 
Example #28
Source File: GetCurrentTransportActions.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public GetCurrentTransportActions(UnsignedIntegerFourBytes instanceId, Service service) {
    super(new ActionInvocation(service.getAction("GetCurrentTransportActions")));
    getActionInvocation().setInput("InstanceID", instanceId);
}
 
Example #29
Source File: Search.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Search with first result 0 and {@link #getDefaultMaxResults()}, filters with {@link #CAPS_WILDCARD}.
 */
public Search(Service service, String containerId, String searchCriteria) {
    this(service, containerId, searchCriteria, CAPS_WILDCARD, 0, null);
}
 
Example #30
Source File: PortMappingDelete.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PortMappingDelete(Service service, PortMapping portMapping) {
    this(service, null, portMapping);
}