|
YAACC - UPNP Client and Server
|
The use of one FCast receiver by the app (design.md, section 2). More...


Classes | |
| interface | Body |
| Builds the body of a command (may refuse). More... | |
| class | Config |
| Times; injectable so tests do not wait. | |
| interface | Connector |
Makes a connected FCastConnection that reports to the given listener. More... | |
| interface | Listener |
| What happens to the receiver, in order, on the session's thread. More... | |
| interface | V4Body |
Public Member Functions | |
| FCastSession (Connector connector, Listener listener, Config config, MonotonicClock clock, ScheduledExecutorService executor) | |
| FCastReceiverState | getState () |
| The state as of now. | |
| void | acquire () |
| Somebody (a player, an open sheet) uses the receiver: the connection is kept and a lost one is retried once. | |
| void | release () |
| The user is done; the connection closes after the idle time when nobody else is using the receiver. | |
| void | play (final FCastMessages.PlayRequest request) |
Plays the item; sets Pending.PLAY until the receiver reports. | |
| void | pause () |
| void | resume () |
| void | stop () |
| void | seek (final double seconds) |
| void | setVolume (final double volume) |
volume 0 to 1. | |
| void | setSpeed (final double speed) |
| Asks for a speed (a receiver of version 1 refuses: the error says so). | |
| void | connect () |
Makes the connection now (the "check connection" of the settings sheet) without sending anything: the state shows CONNECTING, then CONNECTED with the version, or FAILED with the reason. | |
| void | changeTrack (final FCastTrack.Type type, final Long id) |
| Selects an audio or subtitle track of the item (version 4 only; the error says so otherwise). | |
| void | addSubtitle (final String url, final boolean select, final String name) |
Gives the receiver a subtitle file by its address (version 4 only), and selects it if select. | |
| void | subscribe (final int eventType) |
| Subscribes to an event type, e.g. | |
| void | close () |
Closes the connection and ends the session; the state becomes IDLE. | |
Static Public Member Functions | |
| static Connector | connectorFor (final InetSocketAddress target, final FCastConnection.Config config, final MonotonicClock clock, final String senderName, final String appName, final String appVersion) |
| The connector of the app: one TCP connection to the receiver with these settings. | |
The use of one FCast receiver by the app (design.md, section 2).
It owns the connection, makes it when a command needs it, and keeps FCastReceiverState: the state is what the receiver reported. A command (play, pause ...) never changes the playback fields; it sets a FCastReceiverState.Pending marker that the receiver's answer, or pendingTimeoutMillis, clears. What another sender does with the same receiver shows through the same messages (an item that this session did not start is flagged itemFromElsewhere); the session never fights it.
Who uses it. acquire() and release() count the users (a player, an open settings sheet). The connection is made on the first command and is closed idleCloseMillis after the last user left and the last command (decision D11: an idle card has no connection). While somebody uses the receiver and the connection is lost for any reason but our own close, the session retries once after reconnectDelayMillis; a retry that fails, or a second loss before the connection was stable for stableMillis, ends in FAILED with the reason as text and no further attempt (the player reports the error and stops). A connection lost with nobody using it just goes IDLE.
Threads. Everything runs on the single-thread executor that is passed in (also the listener calls, which must not block); the methods may be called from any thread. getState() is a volatile read.
| void de.yaacc.fcast.protocol.FCastSession.changeTrack | ( | final FCastTrack.Type | type, |
| final Long | id ) |
Selects an audio or subtitle track of the item (version 4 only; the error says so otherwise).
id null switches the subtitles off. The state shows the selection when the receiver confirms it.
| void de.yaacc.fcast.protocol.FCastSession.close | ( | ) |
Closes the connection and ends the session; the state becomes IDLE.
The executor is not shut down (it is the caller's).
| void de.yaacc.fcast.protocol.FCastSession.play | ( | final FCastMessages.PlayRequest | request | ) |
Plays the item; sets Pending.PLAY until the receiver reports.
The URL is sent as given.
| void de.yaacc.fcast.protocol.FCastSession.setVolume | ( | final double | volume | ) |
volume 0 to 1.
The volume field of the state changes when the receiver says so. Volume commands that are still queued are coalesced: only the latest value is sent (a slider that is dragged gives many, and the session's thread can be busy for seconds with a connection that does not come up).

| void de.yaacc.fcast.protocol.FCastSession.subscribe | ( | final int | eventType | ) |
Subscribes to an event type, e.g.
FCastMessages#EVENT_MEDIA_ITEM_END (version 3 receivers only).
