2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.upnpcontrol.internal.services;
15 import java.util.Arrays;
16 import java.util.Collections;
17 import java.util.HashSet;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.jupnp.model.meta.RemoteDevice;
23 import org.jupnp.model.meta.RemoteService;
24 import org.jupnp.model.types.ServiceId;
27 * Class representing the configuration of the renderer. Instantiation will get configuration parameters from UPnP
28 * {@link RemoteDevice}.
30 * @author Mark Herwege - Initial contribution
33 public class UpnpRenderingControlConfiguration {
34 protected static final String UPNP_RENDERING_CONTROL_SCHEMA = "urn:schemas-upnp-org:service:RenderingControl";
36 public Set<String> audioChannels = Collections.emptySet();
38 public boolean volume;
40 public boolean loudness;
42 public long maxvolume = 100;
44 public UpnpRenderingControlConfiguration() {
47 public UpnpRenderingControlConfiguration(@Nullable RemoteDevice device) {
52 RemoteService rcService = device.findService(ServiceId.valueOf(UPNP_RENDERING_CONTROL_SCHEMA));
53 if (rcService != null) {
54 volume = (rcService.getStateVariable("Volume") != null);
56 maxvolume = rcService.getStateVariable("Volume").getTypeDetails().getAllowedValueRange().getMaximum();
58 mute = (rcService.getStateVariable("Mute") != null);
59 loudness = (rcService.getStateVariable("Loudness") != null);
60 if (rcService.getStateVariable("A_ARG_TYPE_Channel") != null) {
61 audioChannels = new HashSet<String>(Arrays
62 .asList(rcService.getStateVariable("A_ARG_TYPE_Channel").getTypeDetails().getAllowedValues()));