org.fourthline.cling.model.gena.GENASubscription Java Examples
The following examples show how to use
org.fourthline.cling.model.gena.GENASubscription.
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: OutgoingEventRequestMessage.java From DroidDLNA with GNU General Public License v3.0 | 6 votes |
public OutgoingEventRequestMessage(GENASubscription subscription, URL callbackURL, UnsignedIntegerFourBytes sequence, Collection<StateVariableValue> values) { super(new UpnpRequest(UpnpRequest.Method.NOTIFY, callbackURL)); getHeaders().add(UpnpHeader.Type.CONTENT_TYPE, new ContentTypeHeader()); getHeaders().add(UpnpHeader.Type.NT, new NTEventHeader()); getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(NotificationSubtype.PROPCHANGE)); getHeaders().add(UpnpHeader.Type.SID, new SubscriptionIdHeader(subscription.getSubscriptionId())); // Important! Pass by value so that we can safely increment it afterwards and before this is send! getHeaders().add(UpnpHeader.Type.SEQ, new EventSequenceHeader(sequence.getValue())); this.stateVariableValues = values; }
Example #2
Source File: OutgoingEventRequestMessage.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
public OutgoingEventRequestMessage(GENASubscription subscription, URL callbackURL, UnsignedIntegerFourBytes sequence, Collection<StateVariableValue> values) { super(new UpnpRequest(UpnpRequest.Method.NOTIFY, callbackURL)); getHeaders().add(UpnpHeader.Type.CONTENT_TYPE, new ContentTypeHeader()); getHeaders().add(UpnpHeader.Type.NT, new NTEventHeader()); getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(NotificationSubtype.PROPCHANGE)); getHeaders().add(UpnpHeader.Type.SID, new SubscriptionIdHeader(subscription.getSubscriptionId())); // Important! Pass by value so that we can safely increment it afterwards and before this is send! getHeaders().add(UpnpHeader.Type.SEQ, new EventSequenceHeader(sequence.getValue())); this.stateVariableValues = values; }
Example #3
Source File: SystemService.java From BeyondUPnP with Apache License 2.0 | 4 votes |
@Override protected void ended(GENASubscription subscription, CancelReason reason, UpnpResponse responseStatus) { Log.i(TAG, "AVTransportSubscriptionCallback ended."); }
Example #4
Source File: DLNAController.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
@Override public void create(final boolean playing, final int seconds) { downloadService.setPlayerState(PlayerState.PREPARING); callback = new SubscriptionCallback(getTransportService(), 600) { @Override protected void failed(GENASubscription genaSubscription, UpnpResponse upnpResponse, Exception e, String msg) { Log.w(TAG, "Register subscription callback failed: " + msg, e); } @Override protected void established(GENASubscription genaSubscription) { Action seekAction = genaSubscription.getService().getAction("Seek"); if(seekAction != null) { StateVariable seekMode = genaSubscription.getService().getStateVariable("A_ARG_TYPE_SeekMode"); for(String allowedValue: seekMode.getTypeDetails().getAllowedValues()) { if("REL_TIME".equals(allowedValue)) { supportsSeek = true; } } } Action setupNextAction = genaSubscription.getService().getAction("SetNextAVTransportURI"); if(setupNextAction != null) { supportsSetupNext = true; } startSong(downloadService.getCurrentPlaying(), playing, seconds); downloadService.postDelayed(searchDLNA, SEARCH_UPDATE_INTERVAL_SECONDS); } @Override protected void ended(GENASubscription genaSubscription, CancelReason cancelReason, UpnpResponse upnpResponse) { Log.i(TAG, "Ended subscription"); if(cancelReason != null) { Log.i(TAG, "Cancel Reason: " + cancelReason.toString()); } if(upnpResponse != null) { Log.i(TAG, "Reponse Message: " + upnpResponse.getStatusMessage()); Log.i(TAG, "Response Details: " + upnpResponse.getResponseDetails()); } } @Override protected void eventReceived(GENASubscription genaSubscription) { Map<String, StateVariableValue> m = genaSubscription.getCurrentValues(); try { String lastChangeText = m.get("LastChange").toString(); lastChangeText = lastChangeText.replace(",X_DLNA_SeekTime","").replace(",X_DLNA_SeekByte", ""); LastChange lastChange = new LastChange(new AVTransportLastChangeParser(), lastChangeText); if (lastChange.getEventedValue(0, AVTransportVariable.TransportState.class) == null) { return; } switch (lastChange.getEventedValue(0, AVTransportVariable.TransportState.class).getValue()) { case PLAYING: downloadService.setPlayerState(PlayerState.STARTED); break; case PAUSED_PLAYBACK: downloadService.setPlayerState(PlayerState.PAUSED); break; case STOPPED: boolean failed = false; for(StateVariableValue val: m.values()) { if(val.toString().indexOf("TransportStatus val=\"ERROR_OCCURRED\"") != -1) { Log.w(TAG, "Failed to load with event: " + val.toString()); failed = true; } } if(failed) { failedLoad(); } else if(downloadService.getPlayerState() == PlayerState.STARTED) { // Played until the end downloadService.onSongCompleted(); } else { downloadService.setPlayerState(PlayerState.STOPPED); } break; case TRANSITIONING: downloadService.setPlayerState(PlayerState.PREPARING); break; case NO_MEDIA_PRESENT: downloadService.setPlayerState(PlayerState.IDLE); break; default: } } catch (Exception e) { Log.w(TAG, "Failed to parse UPNP event", e); } } @Override protected void eventsMissed(GENASubscription genaSubscription, int i) { Log.w(TAG, "Event missed: " + i); } }; controlPoint.execute(callback); }
Example #5
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
protected void failed(GENASubscription subscription, UpnpResponse responseStatus, Exception exception) { failed(subscription, responseStatus, exception, createDefaultFailureMessage(responseStatus, exception)); }
Example #6
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
synchronized public void setSubscription(GENASubscription subscription) { this.subscription = subscription; }
Example #7
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
synchronized public GENASubscription getSubscription() { return subscription; }
Example #8
Source File: OutgoingEventRequestMessage.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public OutgoingEventRequestMessage(GENASubscription subscription, URL callbackURL) { this(subscription, callbackURL, subscription.getCurrentSequence(), subscription.getCurrentValues().values()); }
Example #9
Source File: SystemService.java From BeyondUPnP with Apache License 2.0 | 4 votes |
@Override protected void eventsMissed(GENASubscription subscription, int numberOfMissedEvents) { }
Example #10
Source File: SystemService.java From BeyondUPnP with Apache License 2.0 | 4 votes |
@Override protected void established(GENASubscription subscription) { }
Example #11
Source File: SystemService.java From BeyondUPnP with Apache License 2.0 | 4 votes |
@Override protected void failed(GENASubscription subscription, UpnpResponse responseStatus, Exception exception, String defaultMsg) { Log.e(TAG, "AVTransportSubscriptionCallback failed."); }
Example #12
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
protected void failed(GENASubscription subscription, UpnpResponse responseStatus, Exception exception) { failed(subscription, responseStatus, exception, createDefaultFailureMessage(responseStatus, exception)); }
Example #13
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
synchronized public void setSubscription(GENASubscription subscription) { this.subscription = subscription; }
Example #14
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
synchronized public GENASubscription getSubscription() { return subscription; }
Example #15
Source File: OutgoingEventRequestMessage.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public OutgoingEventRequestMessage(GENASubscription subscription, URL callbackURL) { this(subscription, callbackURL, subscription.getCurrentSequence(), subscription.getCurrentValues().values()); }
Example #16
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 2 votes |
/** * Called when a received event was out of sequence, indicating that events have been missed. * <p> * It's up to you if you want to react to missed events or if you (can) silently ignore them. * </p> * @param subscription The established subscription. * @param numberOfMissedEvents The number of missed events. */ protected abstract void eventsMissed(GENASubscription subscription, int numberOfMissedEvents);
Example #17
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 2 votes |
/** * Called when an event for an established subscription has been received. * <p> * Use the {@link org.fourthline.cling.model.gena.GENASubscription#getCurrentValues()} method to obtain * the evented state variable values. * </p> * * @param subscription The established subscription with fresh state variable values. */ protected abstract void eventReceived(GENASubscription subscription);
Example #18
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 2 votes |
/** * Called when a local or remote subscription ended, either on user request or because of a failure. * * @param subscription The ended subscription instance. * @param reason If the subscription ended regularly (through <tt>end()</tt>), this is <tt>null</tt>. * @param responseStatus For a remote subscription, if the cause implies a remopte response and it was * received, this is it (e.g. renewal failure response). */ protected abstract void ended(GENASubscription subscription, CancelReason reason, UpnpResponse responseStatus);
Example #19
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 2 votes |
/** * Called when a local or remote subscription was successfully established. * * @param subscription The successful subscription. */ protected abstract void established(GENASubscription subscription);
Example #20
Source File: SubscriptionCallback.java From TVRemoteIME with GNU General Public License v2.0 | 2 votes |
/** * Called when establishing a local or remote subscription failed. To get a nice error message that * transparently detects local or remote errors use <tt>createDefaultFailureMessage()</tt>. * * @param subscription The failed subscription object, not very useful at this point. * @param responseStatus For a remote subscription, if a response was received at all, this is it, otherwise <tt>null</tt>. * @param exception For a local subscription and failed creation of a remote subscription protocol (before * sending the subscribe request), any exception that caused the failure, otherwise <tt>null</tt>. * @param defaultMsg A user-friendly error message. * @see #createDefaultFailureMessage */ protected abstract void failed(GENASubscription subscription, UpnpResponse responseStatus, Exception exception, String defaultMsg);
Example #21
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 2 votes |
/** * Called when establishing a local or remote subscription failed. To get a nice error message that * transparently detects local or remote errors use <tt>createDefaultFailureMessage()</tt>. * * @param subscription The failed subscription object, not very useful at this point. * @param responseStatus For a remote subscription, if a response was received at all, this is it, otherwise <tt>null</tt>. * @param exception For a local subscription and failed creation of a remote subscription protocol (before * sending the subscribe request), any exception that caused the failure, otherwise <tt>null</tt>. * @param defaultMsg A user-friendly error message. * @see #createDefaultFailureMessage */ protected abstract void failed(GENASubscription subscription, UpnpResponse responseStatus, Exception exception, String defaultMsg);
Example #22
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 2 votes |
/** * Called when a local or remote subscription was successfully established. * * @param subscription The successful subscription. */ protected abstract void established(GENASubscription subscription);
Example #23
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 2 votes |
/** * Called when a local or remote subscription ended, either on user request or because of a failure. * * @param subscription The ended subscription instance. * @param reason If the subscription ended regularly (through <tt>end()</tt>), this is <tt>null</tt>. * @param responseStatus For a remote subscription, if the cause implies a remopte response and it was * received, this is it (e.g. renewal failure response). */ protected abstract void ended(GENASubscription subscription, CancelReason reason, UpnpResponse responseStatus);
Example #24
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 2 votes |
/** * Called when an event for an established subscription has been received. * <p> * Use the {@link org.fourthline.cling.model.gena.GENASubscription#getCurrentValues()} method to obtain * the evented state variable values. * </p> * * @param subscription The established subscription with fresh state variable values. */ protected abstract void eventReceived(GENASubscription subscription);
Example #25
Source File: SubscriptionCallback.java From DroidDLNA with GNU General Public License v3.0 | 2 votes |
/** * Called when a received event was out of sequence, indicating that events have been missed. * <p> * It's up to you if you want to react to missed events or if you (can) silently ignore them. * </p> * @param subscription The established subscription. * @param numberOfMissedEvents The number of missed events. */ protected abstract void eventsMissed(GENASubscription subscription, int numberOfMissedEvents);