|
YAACC - UPNP Client and Server
|
The server's side of one connection to one Sendspin player, from the connect to the end: handshake, server/hello, the player's client/hello, the decision whether the player may be given the 'playback' activity, the server/activate, the answers to client/time, the player's state, and the commands and the audio that the app sends.
More...


Classes | |
| enum | EndReason |
| Why a connection ended, as far as the server knows. More... | |
| interface | GroupSource |
| Where the group of this player comes from: the hub knows the groups; a connection without a source is a group of its own. More... | |
| interface | LeaveListener |
Told when the player stops taking part in its group: client/leave, or a change to available: false. More... | |
| interface | Listener |
| enum | PairingFailure |
| Why a pairing did not complete. More... | |
| enum | PairingStep |
| enum | Phase |
| Where the connection is; the rows of the app are made from it. More... | |
| class | StreamFormat |
| The format of the stream to this player. | |
Public Member Functions | |
| HubConnection (Endpoint endpoint, Identity identity, ServerPolicy policy, Connector connector, HubClock clock, SecureRandom random, String serverName, Listener listener) | |
| HubConnection (Endpoint endpoint, Identity identity, ServerPolicy policy, Connector connector, HubClock clock, SecureRandom random, String serverName, Listener listener, java.util.function.BooleanSupplier legacyAllowed) | |
| void | setControllerHost (de.yaacc.sendspin.control.ControllerHost host) |
Lets this connection serve a client that is a controller and no player (call before start()). | |
| void | setSourceTarget (SourceIngress.Target target) |
Lets this connection take the audio of a client with the source role into a group (call before start()); null: not offered. | |
| Endpoint | endpoint () |
| Phase | phase () |
| EndReason | endReason () |
| String | clientId () |
| The player's id once the handshake is done, else null. | |
| SendspinMessages.ClientHello | hello () |
| SendspinMessages.ClientState | state () |
The last client/state, or null before the first one. | |
| boolean | isReady () |
| boolean | isLegacy () |
| True if this player speaks the older, unencrypted wire (allowed by the user's switch). | |
| boolean | credentialMismatch () |
| True if the server could not use a PSK the player had referenced earlier (spec: credential mismatch). | |
| boolean | isPaired () |
| PairingFailure | pairingFailure () |
Why the last pairing did not complete, else PairingFailure#NONE. | |
| void | start () |
| Starts the connection on its own thread. | |
| void | close () |
| Ends the connection: stops a running stream, tells the player and closes. | |
| void | approve () |
| The operator approves this player (choosing it in "Play on" is the approval the specification allows). | |
| boolean | startPlayback () |
A YAACC player starts to play to this player: declares the 'playback' activity (and keeps the role). | |
| void | stopPlayback () |
The YAACC player stopped: ends the stream and drops the 'playback' activity; the connection stays as available. | |
| void | setGroupSource (GroupSource source) |
| The group of this player comes from the hub (its leader, or itself); call before the connection starts. | |
| void | setLeaveListener (LeaveListener listener) |
| void | refreshGroup () |
| The group of this player or the state of its group may have changed (it was linked or unlinked, it left): tells the player if something differs from what it was told last. | |
| void | setOpusEncoderFactory (de.yaacc.audio.OpusEncoderFactory factory) |
| The encoder for Opus streams (API 29 and newer); call before the connection starts. | |
| java.util.Set< Integer > | supportedRates () |
| The rates (16 bit, stereo, PCM or FLAC) the player lists and the hub can produce, in the player's own order; empty before its hello. | |
| HubClock | hubClock () |
| The clock of the hub, for a group's streamer. | |
| StreamFormat | streamFormat () |
| The format of the stream to this player (PCM, 16 bit, stereo, the first such entry of the player's list) from the moment its hello is read, else null. | |
| PcmStreamer | streamer () |
| The streamer that sends audio to this player, or null if the player is not ready. | |
| boolean | setVolume (int volume) |
| boolean | setMuted (boolean muted) |
| void | abort () |
| A write is stuck (the player is gone and the socket is full): the socket is closed, so that the write fails and nothing waits for it. | |
| void | streamStart (long serverTransmittedMicros, int sampleRate) throws IOException |
| String | describe () |
| A short text for the stream report (the codec and what its encoding costs), or null. | |
| void | streamClear (long serverTransmittedMicros) throws IOException |
| void | streamEnd () throws IOException |
| void | audio (long timestampMicros, long sendAheadMicros, byte[] pcm, int offset, int length) throws IOException |
| long | leadMicros () |
| How far ahead of its timestamp a chunk is sent, output delay included. | |
| long | outputDelayMicros () |
| The delay beyond the audio port that the player reported; chunks count as in the player's buffer until it has passed. | |
| long | capacityBytes () |
The player's buffer_capacity in bytes. | |
| boolean | hasSource () |
| True while this connection has the source role (a client that can feed audio). | |
| boolean | isSourceStreaming () |
| True while the source's audio is taken (not held back by the operator, and the source has audio to offer). | |
| boolean | isSourceHeld () |
| True while the operator holds the source back (pause or stop of the card of the server). | |
| void | holdSource (final boolean hold) |
| Holds the audio of the source back (the operator paused or stopped), or takes it again: the server stops asking for it, or asks again if the source still has audio to offer. | |
| boolean | startCodePairing (de.yaacc.sendspin.pairing.CodePairingServer.Method method) |
The operator chose a code-based method for this player: the activation is sent and the attempt runs (codePairing()). | |
| de.yaacc.sendspin.pairing.CodePairingServer | codePairing () |
| The code-based pairing that is running, for the operator's dialog (its state, the round, the player's sentence); else null. | |
| boolean | submitCode (final String text) |
| The operator's entry for the running attempt: the typed digits, or the scanned or pasted token of the QR format. | |
| void | cancelCodePairing () |
| The operator gives the attempt up. | |
Public Member Functions inherited from de.yaacc.sendspin.hub.PcmStreamer.Output | |
Public Member Functions inherited from de.yaacc.sendspin.hub.PcmStreamer.Timing | |
The server's side of one connection to one Sendspin player, from the connect to the end: handshake, server/hello, the player's client/hello, the decision whether the player may be given the 'playback' activity, the server/activate, the answers to client/time, the player's state, and the commands and the audio that the app sends.
The rules it keeps (spec, "Unpaired Access", "Pairing", server/activate): a player that is neither paired nor approved by the operator is activated with no activities and no roles and waits for approve(); a player that does not admit unpaired access, or that could not use the PSK that was referenced, is shown as such and not activated; the server declares 'playback' only for a player it can stream to (it needs PCM, 16 bit, stereo in the player's list).
One thread runs the connection (start()); the app calls the other methods from its own threads. The connection does not reconnect: it ends, and says why (endReason()); the directory decides what to do (the guidance of client/goodbye).
| de.yaacc.sendspin.hub.HubConnection.HubConnection | ( | Endpoint | endpoint, |
| Identity | identity, | ||
| ServerPolicy | policy, | ||
| Connector | connector, | ||
| HubClock | clock, | ||
| SecureRandom | random, | ||
| String | serverName, | ||
| Listener | listener, | ||
| java.util.function.BooleanSupplier | legacyAllowed ) |
| legacyAllowed | whether a client of the older, unencrypted wire is accepted (client/hello as the first message); read at each connection: the user's switch, off by default |
| void de.yaacc.sendspin.hub.HubConnection.abort | ( | ) |
A write is stuck (the player is gone and the socket is full): the socket is closed, so that the write fails and nothing waits for it.
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| void de.yaacc.sendspin.hub.HubConnection.approve | ( | ) |
The operator approves this player (choosing it in "Play on" is the approval the specification allows).
Remembered by the policy; if the player waits, it is activated now.
Referenced by de.yaacc.sendspin.SendspinHub.link().


| void de.yaacc.sendspin.hub.HubConnection.audio | ( | long | timestampMicros, |
| long | sendAheadMicros, | ||
| byte[] | pcm, | ||
| int | offset, | ||
| int | length ) throws IOException |
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| long de.yaacc.sendspin.hub.HubConnection.capacityBytes | ( | ) |
The player's buffer_capacity in bytes.
Implements de.yaacc.sendspin.hub.PcmStreamer.Timing.
| void de.yaacc.sendspin.hub.HubConnection.close | ( | ) |
Ends the connection: stops a running stream, tells the player and closes.
Safe to call more than once.
Referenced by de.yaacc.sendspin.SendspinHub.disconnect().


| String de.yaacc.sendspin.hub.HubConnection.describe | ( | ) |
A short text for the stream report (the codec and what its encoding costs), or null.
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| void de.yaacc.sendspin.hub.HubConnection.holdSource | ( | final boolean | hold | ) |
Holds the audio of the source back (the operator paused or stopped), or takes it again: the server stops asking for it, or asks again if the source still has audio to offer.
The source goes on playing on its own phone. Never on the main thread.
Referenced by de.yaacc.sendspin.hub.HubConnection.holdSource().


| long de.yaacc.sendspin.hub.HubConnection.leadMicros | ( | ) |
How far ahead of its timestamp a chunk is sent, output delay included.
Implements de.yaacc.sendspin.hub.PcmStreamer.Timing.
| long de.yaacc.sendspin.hub.HubConnection.outputDelayMicros | ( | ) |
The delay beyond the audio port that the player reported; chunks count as in the player's buffer until it has passed.
Implements de.yaacc.sendspin.hub.PcmStreamer.Timing.
| void de.yaacc.sendspin.hub.HubConnection.refreshGroup | ( | ) |
The group of this player or the state of its group may have changed (it was linked or unlinked, it left): tells the player if something differs from what it was told last.
Any thread.

| void de.yaacc.sendspin.hub.HubConnection.setOpusEncoderFactory | ( | de.yaacc.audio.OpusEncoderFactory | factory | ) |
The encoder for Opus streams (API 29 and newer); call before the connection starts.
Null (the default): Opus is not produced.
Referenced by de.yaacc.sendspin.SendspinHub.acquire().

| boolean de.yaacc.sendspin.hub.HubConnection.setVolume | ( | int | volume | ) |
| boolean de.yaacc.sendspin.hub.HubConnection.startCodePairing | ( | de.yaacc.sendspin.pairing.CodePairingServer.Method | method | ) |
The operator chose a code-based method for this player: the activation is sent and the attempt runs (codePairing()).
Only for a connection under the Sentinel PSK (the specification: the code-based flows start from an unpaired connection), a method the player offered, and one attempt at a time.

| boolean de.yaacc.sendspin.hub.HubConnection.startPlayback | ( | ) |
A YAACC player starts to play to this player: declares the 'playback' activity (and keeps the role).
The specification asks a server to declare it only while it plays, so that other servers can take the player at other times; the connection idles with empty activities until this is called. Another server that plays to the player can displace this connection (then the connection ends with ANOTHER_SERVER).

| void de.yaacc.sendspin.hub.HubConnection.streamClear | ( | long | serverTransmittedMicros | ) | throws IOException |
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| void de.yaacc.sendspin.hub.HubConnection.streamEnd | ( | ) | throws IOException |
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| PcmStreamer de.yaacc.sendspin.hub.HubConnection.streamer | ( | ) |
The streamer that sends audio to this player, or null if the player is not ready.
One per connection: the same object every time.

| StreamFormat de.yaacc.sendspin.hub.HubConnection.streamFormat | ( | ) |
The format of the stream to this player (PCM, 16 bit, stereo, the first such entry of the player's list) from the moment its hello is read, else null.
The audio tap of the app needs the rate before the player is ready.
Referenced by de.yaacc.sendspin.SendspinHub.sampleRateOf().

| void de.yaacc.sendspin.hub.HubConnection.streamStart | ( | long | serverTransmittedMicros, |
| int | sampleRate ) throws IOException |
Implements de.yaacc.sendspin.hub.PcmStreamer.Output.
| boolean de.yaacc.sendspin.hub.HubConnection.submitCode | ( | final String | text | ) |
The operator's entry for the running attempt: the typed digits, or the scanned or pasted token of the QR format.
