org.fourthline.cling.model.types.UnsignedIntegerFourBytes Java Examples

The following examples show how to use org.fourthline.cling.model.types.UnsignedIntegerFourBytes. 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: EventSequenceHeader.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {

        // Cut off leading zeros
        if (!"0".equals(s)) {
            while(s.startsWith("0")) {
                s = s.substring(1);
            }
        }

        try {
            setValue(new UnsignedIntegerFourBytes(s));
        } catch (NumberFormatException ex) {
            throw new InvalidHeaderException("Invalid event sequence, " + ex.getMessage());
        }

    }
 
Example #2
Source Project: TVRemoteIME   Author: kingthy   File: GetStatusInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void success(ActionInvocation invocation) {

    try {
        Connection.Status status =
                Connection.Status.valueOf(invocation.getOutput("NewConnectionStatus").getValue().toString());

        Connection.Error lastError =
                Connection.Error.valueOf(invocation.getOutput("NewLastConnectionError").getValue().toString());

        success(new Connection.StatusInfo(status, (UnsignedIntegerFourBytes) invocation.getOutput("NewUptime").getValue(), lastError));

    } catch (Exception ex) {
        invocation.setFailure(
                new ActionException(
                        ErrorCode.ARGUMENT_VALUE_INVALID,
                        "Invalid status or last error string: " + ex,
                        ex
                )
        );
        failure(invocation, null);
    }
}
 
Example #3
Source Project: TVRemoteIME   Author: kingthy   File: Browse.java    License: 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 Browse(Service service, String objectID, BrowseFlag flag,
                            String filter, long firstResult, Long maxResults, SortCriterion... orderBy) {

    super(new ActionInvocation(service.getAction("Browse")));

    log.fine("Creating browse action for object ID: " + objectID);

    getActionInvocation().setInput("ObjectID", objectID);
    getActionInvocation().setInput("BrowseFlag", flag.toString());
    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 #4
Source Project: DroidDLNA   Author: offbye   File: EventSequenceHeader.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setString(String s) throws InvalidHeaderException {

        // Cut off leading zeros
        if (!"0".equals(s)) {
            while(s.startsWith("0")) {
                s = s.substring(1);
            }
        }

        try {
            setValue(new UnsignedIntegerFourBytes(s));
        } catch (NumberFormatException ex) {
            throw new InvalidHeaderException("Invalid event sequence, " + ex.getMessage());
        }

    }
 
Example #5
Source Project: TVRemoteIME   Author: kingthy   File: Event.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void setEventedValue(UnsignedIntegerFourBytes id, EventedValue ev) {
    InstanceID instanceID = null;
    for (InstanceID i : getInstanceIDs()) {
        if (i.getId().equals(id)) {
            instanceID = i;
        }
    }
    if (instanceID == null) {
        instanceID = new InstanceID(id);
        getInstanceIDs().add(instanceID);
    }

    Iterator<EventedValue> it = instanceID.getValues().iterator();
    while (it.hasNext()) {
        EventedValue existingEv = it.next();
        if (existingEv.getClass().equals(ev.getClass())) {
            it.remove();
        }
    }
    instanceID.getValues().add(ev);
}
 
Example #6
Source Project: DroidDLNA   Author: offbye   File: AudioRenderingControl.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected ZxtMediaPlayer getInstance(UnsignedIntegerFourBytes instanceId) throws RenderingControlException {
    ZxtMediaPlayer player = getPlayers().get(instanceId);
    if (player == null) {
        throw new RenderingControlException(RenderingControlErrorCode.INVALID_INSTANCE_ID);
    }
    return player;
}
 
Example #7
Source Project: DroidDLNA   Author: offbye   File: LocalGENASubscription.java    License: GNU General Public License v3.0 5 votes vote down vote up
public LocalGENASubscription(LocalService service,
                             Integer requestedDurationSeconds, List<URL> callbackURLs) throws Exception {
    super(service);

    setSubscriptionDuration(requestedDurationSeconds);

    log.fine("Reading initial state of local service at subscription time");
    long currentTime = new Date().getTime();
    this.currentValues.clear();

    Collection<StateVariableValue> values = getService().getManager().getCurrentState();

    log.finer("Got evented state variable values: " + values.size());

    for (StateVariableValue value : values) {
        this.currentValues.put(value.getStateVariable().getName(), value);

        if (log.isLoggable(Level.FINEST)) {
            log.finer("Read state variable value '" + value.getStateVariable().getName() + "': " + value.toString());
        }

        // Preserve "last sent" state for future moderation
        lastSentTimestamp.put(value.getStateVariable().getName(), currentTime);
        if (value.getStateVariable().isModeratedNumericType()) {
            lastSentNumericValue.put(value.getStateVariable().getName(), Long.valueOf(value.toString()));
        }
    }

    this.subscriptionId = SubscriptionIdHeader.PREFIX + UUID.randomUUID();
    this.currentSequence = new UnsignedIntegerFourBytes(0);
    this.callbackURLs = callbackURLs;
}
 
Example #8
Source Project: DroidDLNA   Author: offbye   File: LastChange.java    License: GNU General Public License v3.0 5 votes vote down vote up
synchronized public UnsignedIntegerFourBytes[] getInstanceIDs() {
    List<UnsignedIntegerFourBytes> list = new ArrayList();
    for (InstanceID instanceID : event.getInstanceIDs()) {
        list.add(instanceID.getId());
    }
    return list.toArray(new UnsignedIntegerFourBytes[list.size()]);
}
 
Example #9
Source Project: DroidDLNA   Author: offbye   File: MediaInfo.java    License: GNU General Public License v3.0 5 votes vote down vote up
public MediaInfo(String currentURI, String currentURIMetaData,
                 UnsignedIntegerFourBytes numberOfTracks, String mediaDuration,
                 StorageMedium playMedium,
                 StorageMedium recordMedium, RecordMediumWriteStatus writeStatus) {
    this.currentURI = currentURI;
    this.currentURIMetaData = currentURIMetaData;
    this.numberOfTracks = numberOfTracks;
    this.mediaDuration = mediaDuration;
    this.playMedium = playMedium;
    this.recordMedium = recordMedium;
    this.writeStatus = writeStatus;
}
 
Example #10
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayers.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ZxtMediaPlayers(int numberOfPlayers,
                       Context context,
                       LastChange avTransportLastChange,
                       LastChange renderingControlLastChange) {
    super(numberOfPlayers);
    this.mContext = context;
    this.avTransportLastChange = avTransportLastChange;
    this.renderingControlLastChange = renderingControlLastChange;

    for (int i = 0; i < numberOfPlayers; i++) {

        ZxtMediaPlayer player =
                new ZxtMediaPlayer(
                        new UnsignedIntegerFourBytes(i),
                        mContext,
                        avTransportLastChange,
                        renderingControlLastChange
                ) {
                    @Override
                    protected void transportStateChanged(TransportState newState) {
                        super.transportStateChanged(newState);
                        if (newState.equals(TransportState.PLAYING)) {
                            onPlay(this);
                        } else if (newState.equals(TransportState.STOPPED)) {
                            onStop(this);
                        }
                    }
                };
        put(player.getInstanceId(), player);
    }
}
 
Example #11
Source Project: TVRemoteIME   Author: kingthy   File: MediaInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public MediaInfo(String currentURI, String currentURIMetaData,
                 String nextURI, String nextURIMetaData,
                 UnsignedIntegerFourBytes numberOfTracks, String mediaDuration,
                 StorageMedium playMedium,
                 StorageMedium recordMedium, RecordMediumWriteStatus writeStatus) {
    this.currentURI = currentURI;
    this.currentURIMetaData = currentURIMetaData;
    this.nextURI = nextURI;
    this.nextURIMetaData = nextURIMetaData;
    this.numberOfTracks = numberOfTracks;
    this.mediaDuration = mediaDuration;
    this.playMedium = playMedium;
    this.recordMedium = recordMedium;
    this.writeStatus = writeStatus;
}
 
Example #12
Source Project: TVRemoteIME   Author: kingthy   File: PortMapping.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PortMapping(int port, String internalClient, Protocol protocol, String description) {
    this(
            true,
            new UnsignedIntegerFourBytes(0),
            null,
            new UnsignedIntegerTwoBytes(port),
            new UnsignedIntegerTwoBytes(port),
            internalClient,
            protocol,
            description
    );
}
 
Example #13
Source Project: DroidDLNA   Author: offbye   File: AbstractAudioRenderingControl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@UpnpAction(out = {
        @UpnpOutputArgument(name = "MinValue", stateVariable = "VolumeDB", getterName = "getMinValue"),
        @UpnpOutputArgument(name = "MaxValue", stateVariable = "VolumeDB", getterName = "getMaxValue")
})
public VolumeDBRange getVolumeDBRange(@UpnpInputArgument(name = "InstanceID") UnsignedIntegerFourBytes instanceId,
                                      @UpnpInputArgument(name = "Channel") String channelName) throws RenderingControlException {
    return new VolumeDBRange(0, 0);
}
 
Example #14
Source Project: TVRemoteIME   Author: kingthy   File: Search.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void success(ActionInvocation actionInvocation) {
    log.fine("Successful search action, reading output argument values");

    SearchResult result = new SearchResult(
            actionInvocation.getOutput("Result").getValue().toString(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("NumberReturned").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("TotalMatches").getValue(),
            (UnsignedIntegerFourBytes) actionInvocation.getOutput("UpdateID").getValue());

    boolean proceed = receivedRaw(actionInvocation, result);

    if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) {
        try {
            DIDLParser didlParser = new DIDLParser();
            DIDLContent didl = didlParser.parse(result.getResult());
            received(actionInvocation, didl);
            updateStatus(Status.OK);
        } catch (Exception ex) {
            actionInvocation.setFailure(
                    new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex)
            );
            failure(actionInvocation, null);
        }
    } else {
        received(actionInvocation, new DIDLContent());
        updateStatus(Status.NO_CONTENT);
    }
}
 
Example #15
Source Project: TVRemoteIME   Author: kingthy   File: AbstractAudioRenderingControl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@UpnpAction
    public void setLoudness(@UpnpInputArgument(name = "InstanceID") UnsignedIntegerFourBytes instanceId,
                            @UpnpInputArgument(name = "Channel") String channelName,
                            @UpnpInputArgument(name = "DesiredLoudness", stateVariable = "Loudness") boolean desiredLoudness) throws RenderingControlException {
/*
        Loudness loudness = new Loudness();
        loudness.setChannel(channelName);
        loudness.setVal(desiredLoudness);
*/
    }
 
Example #16
Source Project: DroidDLNA   Author: offbye   File: AVTransportService.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected ZxtMediaPlayer getInstance(UnsignedIntegerFourBytes instanceId) throws AVTransportException {
    ZxtMediaPlayer player = getPlayers().get(instanceId);
    if (player == null) {
        throw new AVTransportException(AVTransportErrorCode.INVALID_INSTANCE_ID);
    }
    return player;
}
 
Example #17
Source Project: DroidDLNA   Author: offbye   File: AVTransportService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setPlayMode(UnsignedIntegerFourBytes instanceId, String newPlayMode) throws AVTransportException {
    AVTransport transport = findStateMachine(instanceId).getCurrentState().getTransport();
    try {
        transport.setTransportSettings(
                new TransportSettings(
                        PlayMode.valueOf(newPlayMode),
                        transport.getTransportSettings().getRecQualityMode()
                )
        );
    } catch (IllegalArgumentException ex) {
        throw new AVTransportException(
                AVTransportErrorCode.PLAYMODE_NOT_SUPPORTED, "Unsupported play mode: " + newPlayMode
        );
    }
}
 
Example #18
Source Project: TVRemoteIME   Author: kingthy   File: PortMapping.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PortMapping(boolean enabled, UnsignedIntegerFourBytes leaseDurationSeconds, String remoteHost, UnsignedIntegerTwoBytes externalPort,
                   UnsignedIntegerTwoBytes internalPort, String internalClient, Protocol protocol, String description) {
    this.enabled = enabled;
    this.leaseDurationSeconds = leaseDurationSeconds;
    this.remoteHost = remoteHost;
    this.externalPort = externalPort;
    this.internalPort = internalPort;
    this.internalClient = internalClient;
    this.protocol = protocol;
    this.description = description;
}
 
Example #19
Source Project: TVRemoteIME   Author: kingthy   File: AVTransportService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setNextAVTransportURI(UnsignedIntegerFourBytes instanceId,
                                  String nextURI,
                                  String nextURIMetaData) throws AVTransportException {
    log.info("### TODO: Not implemented: SetNextAVTransportURI");
    // Not implemented
}
 
Example #20
Source Project: DroidDLNA   Author: offbye   File: BrowseResult.java    License: GNU General Public License v3.0 5 votes vote down vote up
public BrowseResult(String result, long count, long totalMatches, long updatedId) {
    this(
            result,
            new UnsignedIntegerFourBytes(count),
            new UnsignedIntegerFourBytes(totalMatches),
            new UnsignedIntegerFourBytes(updatedId)
    );
}
 
Example #21
Source Project: DroidDLNA   Author: offbye   File: AudioRenderingControl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public UnsignedIntegerTwoBytes getVolume(UnsignedIntegerFourBytes instanceId, String channelName) throws RenderingControlException {
    checkChannel(channelName);
    int vol = (int) (getInstance(instanceId).getVolume() * 100);
    log.fine("Getting backend volume: " + vol);
    return new UnsignedIntegerTwoBytes(vol);
}
 
Example #22
Source Project: DroidDLNA   Author: offbye   File: PortMapping.java    License: GNU General Public License v3.0 5 votes vote down vote up
public PortMapping(String remoteHost, UnsignedIntegerTwoBytes externalPort, Protocol protocol) {
    this(
            true,
            new UnsignedIntegerFourBytes(0),
            remoteHost,
            externalPort,
            null,
            null,
            protocol,
            null
    );
}
 
Example #23
Source Project: TVRemoteIME   Author: kingthy   File: AudioRenderingControl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public UnsignedIntegerFourBytes[] getCurrentInstanceIds() {
    UnsignedIntegerFourBytes[] ids = new UnsignedIntegerFourBytes[getPlayers().size()];
    int i = 0;
    for (UnsignedIntegerFourBytes id : getPlayers().keySet()) {
        ids[i] = id;
        i++;
    }
    return ids;
}
 
Example #24
Source Project: DroidDLNA   Author: offbye   File: AbstractAVTransportService.java    License: GNU General Public License v3.0 5 votes vote down vote up
@UpnpAction(out = {
        @UpnpOutputArgument(name = "Track", stateVariable = "CurrentTrack", getterName = "getTrack"),
        @UpnpOutputArgument(name = "TrackDuration", stateVariable = "CurrentTrackDuration", getterName = "getTrackDuration"),
        @UpnpOutputArgument(name = "TrackMetaData", stateVariable = "CurrentTrackMetaData", getterName = "getTrackMetaData"),
        @UpnpOutputArgument(name = "TrackURI", stateVariable = "CurrentTrackURI", getterName = "getTrackURI"),
        @UpnpOutputArgument(name = "RelTime", stateVariable = "RelativeTimePosition", getterName = "getRelTime"),
        @UpnpOutputArgument(name = "AbsTime", stateVariable = "AbsoluteTimePosition", getterName = "getAbsTime"),
        @UpnpOutputArgument(name = "RelCount", stateVariable = "RelativeCounterPosition", getterName = "getRelCount"),
        @UpnpOutputArgument(name = "AbsCount", stateVariable = "AbsoluteCounterPosition", getterName = "getAbsCount")
})
public abstract PositionInfo getPositionInfo(@UpnpInputArgument(name = "InstanceID") UnsignedIntegerFourBytes instanceId)
        throws AVTransportException;
 
Example #25
synchronized protected void storeConnection(ConnectionInfo info) {
    CSV<UnsignedIntegerFourBytes> oldConnectionIDs = getCurrentConnectionIDs();
    activeConnections.put(info.getConnectionID(), info);
    log.fine("Connection stored, firing event: " + info.getConnectionID());
    CSV<UnsignedIntegerFourBytes> newConnectionIDs = getCurrentConnectionIDs();
    getPropertyChangeSupport().firePropertyChange("CurrentConnectionIDs", oldConnectionIDs, newConnectionIDs);
}
 
Example #26
Source Project: DroidDLNA   Author: offbye   File: BufferBytesHeader.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setString(String s) throws InvalidHeaderException {
    try {
        setValue(new UnsignedIntegerFourBytes(s));
        return;
    } catch (NumberFormatException numberFormatException) {
    }
    throw new InvalidHeaderException("Invalid header value: " + s);
}
 
Example #27
Source Project: DroidDLNA   Author: offbye   File: AbstractAudioRenderingControl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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())
        );
    }
}
 
Example #28
Source Project: DroidDLNA   Author: offbye   File: LastChangeParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    if (CONSTANTS.InstanceID.equals(localName)) {
        String valAttr = attributes.getValue(CONSTANTS.val.name());
        if (valAttr != null) {
            InstanceID instanceID = new InstanceID(new UnsignedIntegerFourBytes(valAttr));
            getInstance().getInstanceIDs().add(instanceID);
            new InstanceIDHandler(instanceID, this);
        }
    }
}
 
Example #29
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ZxtMediaPlayer(UnsignedIntegerFourBytes instanceId,Context context,
                          LastChange avTransportLastChange,
                          LastChange renderingControlLastChange) {
        super();
        this.instanceId = instanceId;
        this.mContext = context;
        this.avTransportLastChange = avTransportLastChange;
        this.renderingControlLastChange = renderingControlLastChange;

        try {
            // Disconnect the old bus listener
            /* TODO: That doesn't work for some reason...
            getPipeline().getBus().disconnect(
                    (Bus.STATE_CHANGED) Reflections.getField(getClass(), "stateChanged").get(this)
            );
            */

            // Connect a fixed bus state listener
//            getPipeline().getBus().connect(busStateChanged);

            // Connect a bus tag listener
//            getPipeline().getBus().connect(busTag);

        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }

//        addMediaListener(new GstMediaListener());

//        setVideoSink(videoComponent.getElement());
    }
 
Example #30
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void durationChanged(int duration) {
    log.fine("Duration Changed event received: " + duration);
    synchronized (ZxtMediaPlayer.this) {
        String newValue = ModelUtil.toTimeString(duration/1000);
        currentMediaInfo = new MediaInfo(currentMediaInfo.getCurrentURI(), "",
                new UnsignedIntegerFourBytes(1), newValue, StorageMedium.NETWORK);

        getAvTransportLastChange().setEventedValue(getInstanceId(),
                new AVTransportVariable.CurrentTrackDuration(newValue),
                new AVTransportVariable.CurrentMediaDuration(newValue));
    }
}