protected void checkChannel(String channelName) throws RenderingControlException { if (!getChannel(channelName).equals(Channel.Master)) { throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName); } }
@Override public Map.Entry<String, String>[] getAttributes() { return new Map.Entry[]{ new AbstractMap.SimpleEntry<>( "val", new BooleanDatatype().getString(getValue().getMute()) ), new AbstractMap.SimpleEntry<>( "channel", getValue().getChannel().name() ) }; }
public GetMute(UnsignedIntegerFourBytes instanceId, Service service) { super(new ActionInvocation(service.getAction("GetMute"))); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("Channel", Channel.Master.toString()); }
protected Channel getChannel(String channelName) throws RenderingControlException { try { return Channel.valueOf(channelName); } catch (IllegalArgumentException ex) { throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName); } }
@Override protected ChannelMute valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException { Channel channel = null; Boolean mute = null; for (Map.Entry<String, String> attribute : attributes) { if (attribute.getKey().equals("channel")) channel = Channel.valueOf(attribute.getValue()); if (attribute.getKey().equals("val")) mute = new BooleanDatatype().valueOf(attribute.getValue()); } return channel != null && mute != null ? new ChannelMute(channel, mute) : null; }
public void run() { for (UnsignedIntegerFourBytes instanceId : lastChange.getInstanceIDs()) { RenderingControlPoint.LOGGER.fine( "Processing LastChange event values for instance: " + instanceId ); RenderingControlVariable.Volume volume = lastChange.getEventedValue( instanceId, RenderingControlVariable.Volume.class ); if (volume != null && volume.getValue().getChannel().equals(Channel.Master)) { RenderingControlPoint.LOGGER.fine( "Received new volume value for 'Master' channel: " + volume.getValue() ); onMasterVolumeChanged( new Long(instanceId.getValue()).intValue(), volume.getValue().getVolume() ); } } } });
@Override protected ChannelLoudness valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException { Channel channel = null; Boolean loudness = null; for (Map.Entry<String, String> attribute : attributes) { if (attribute.getKey().equals("channel")) channel = Channel.valueOf(attribute.getValue()); if (attribute.getKey().equals("val")) loudness = new BooleanDatatype().valueOf(attribute.getValue()); } return channel != null && loudness != null ? new ChannelLoudness(channel, loudness) : null; }
@Override public Map.Entry<String, String>[] getAttributes() { return new Map.Entry[]{ new AbstractMap.SimpleEntry<>( "val", new BooleanDatatype().getString(getValue().getLoudness()) ), new AbstractMap.SimpleEntry<>( "channel", getValue().getChannel().name() ) }; }
public GetVolume(UnsignedIntegerFourBytes instanceId, Service service) { super(new ActionInvocation(service.getAction("GetVolume"))); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("Channel", Channel.Master.toString()); }
protected void checkChannel(String channelName) throws RenderingControlException { if (!getChannel(channelName).equals(Channel.Master)) { throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName); } }
@Override protected ChannelVolumeDB valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException { Channel channel = null; Integer volumeDB = null; for (Map.Entry<String, String> attribute : attributes) { if (attribute.getKey().equals("channel")) channel = Channel.valueOf(attribute.getValue()); if (attribute.getKey().equals("val")) volumeDB = (new UnsignedIntegerTwoBytesDatatype() .valueOf(attribute.getValue())) .getValue().intValue(); // Java is fun! } return channel != null && volumeDB != null ? new ChannelVolumeDB(channel, volumeDB) : null; }
@Override public Map.Entry<String, String>[] getAttributes() { return new Map.Entry[]{ new AbstractMap.SimpleEntry<>( "val", new UnsignedIntegerTwoBytesDatatype().getString( new UnsignedIntegerTwoBytes(getValue().getVolume()) ) ), new AbstractMap.SimpleEntry<>( "channel", getValue().getChannel().name() ) }; }
public SetMute(UnsignedIntegerFourBytes instanceId, Service service, boolean desiredMute) { super(new ActionInvocation(service.getAction("SetMute"))); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("Channel", Channel.Master.toString()); getActionInvocation().setInput("DesiredMute", desiredMute); }
@Override public void onReceive(List<EventedValue> values) { RenderingControlInfo controlInfo = new RenderingControlInfo(); for (EventedValue entry : values) { if (RenderingControlInfo.MUTE.equals(entry.getName())) { Object v = entry.getValue(); if (v instanceof ChannelMute) { ChannelMute cm = (ChannelMute) v; if (Channel.Master.equals(cm.getChannel())) { controlInfo.setMute(cm.getMute()); } } } if (RenderingControlInfo.VOLUME.equals(entry.getName())) { Object v = entry.getValue(); if (v instanceof ChannelVolume) { ChannelVolume cv = (ChannelVolume) v; if (Channel.Master.equals(cv.getChannel())) { controlInfo.setVolume(cv.getVolume()); } } } if (RenderingControlInfo.PRESET_NAME_LIST.equals(entry.getName())) { Object v = entry.getValue(); controlInfo.setPresetNameList(v.toString()); } } received(controlInfo); }
@Override protected ChannelVolume valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException { Channel channel = null; Integer volume = null; for (Map.Entry<String, String> attribute : attributes) { if (attribute.getKey().equals("channel")) channel = Channel.valueOf(attribute.getValue()); if (attribute.getKey().equals("val")) volume = (new UnsignedIntegerTwoBytesDatatype() .valueOf(attribute.getValue())) .getValue().intValue(); // Java is fun! } return channel != null && volume != null ? new ChannelVolume(channel, volume) : null; }
@Override public Map.Entry<String, String>[] getAttributes() { return new Map.Entry[]{ new AbstractMap.SimpleEntry<>( "val", new UnsignedIntegerTwoBytesDatatype().getString( new UnsignedIntegerTwoBytes(getValue().getVolumeDB()) ) ), new AbstractMap.SimpleEntry<>( "channel", getValue().getChannel().name() ) }; }
public SetVolume(UnsignedIntegerFourBytes instanceId, Service service, long newVolume) { super(new ActionInvocation(service.getAction("SetVolume"))); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("Channel", Channel.Master.toString()); getActionInvocation().setInput("DesiredVolume", new UnsignedIntegerTwoBytes(newVolume)); }
protected Channel getChannel(String channelName) throws RenderingControlException { try { return Channel.valueOf(channelName); } catch (IllegalArgumentException ex) { throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName); } }
@Override public void appendCurrentState(LastChange lc, UnsignedIntegerFourBytes instanceId) throws Exception { for (Channel channel : getCurrentChannels()) { String channelString = channel.name(); lc.setEventedValue( instanceId, new RenderingControlVariable.Mute(new ChannelMute(channel, getMute(instanceId, channelString))), new RenderingControlVariable.Loudness(new ChannelLoudness(channel, getLoudness(instanceId, channelString))), new RenderingControlVariable.Volume(new ChannelVolume(channel, getVolume(instanceId, channelString).getValue().intValue())), new RenderingControlVariable.VolumeDB(new ChannelVolumeDB(channel, getVolumeDB(instanceId, channelString))), new RenderingControlVariable.PresetNameList(PresetName.FactoryDefaults.name()) ); } }
public GetVolume(UnsignedIntegerFourBytes instanceId, Service service) { super(new ActionInvocation(service.getAction("GetVolume"))); getActionInvocation().setInput("InstanceID", instanceId); getActionInvocation().setInput("Channel", Channel.Master.toString()); }