|
YAACC - UPNP Client and Server
|
Turns the PCM that the player of YAACC produces (16 bit stereo, little endian, at the rate the Sendspin player listed) into the timestamped chunks of a Sendspin stream and sends them with a fixed lead: a chunk goes out when it is lead ahead of the moment it must play, so the player holds about lead of audio.
More...


Classes | |
| interface | Call |
| One call to an output, which may throw. More... | |
| interface | Lane |
| Where the calls to the output of one member run. More... | |
| class | Member |
| One player of the group: its output, its timing and the buffer it holds. | |
| class | MemberStats |
| What the writes to one member took (encoding and the socket together). | |
| interface | Output |
| What the streamer sends; the connection implements it. More... | |
| class | Statistics |
| Numbers for a log and the stream report; no content. | |
| interface | Tap |
| Sees every chunk of the stream once, before it is sent (the analysis of the audio for the colour role). More... | |
| interface | Timing |
| What the player asked for, read at every chunk (it may change while a stream runs). More... | |
Public Member Functions | |
| void | setTap (Tap tap) |
Sets or removes (null) the tap. | |
| PcmStreamer (Output out, HubClock clock, Timing timing, int sampleRate) | |
| The stream to one player. | |
| PcmStreamer (HubClock clock, int sampleRate) | |
A group without members; addMember adds the players. | |
| void | useBackgroundWrites () |
| Every member gets a thread of its own that writes to it (call this before the first member is added). | |
| void | awaitWrites (long millis) |
Waits (at most millis) until what was posted to the members so far has been written. | |
| Statistics | statistics () |
| void | setLabel (Member member, String label) |
| A name for a member in the stream report. | |
| void | setLabelOfOutput (Output output, String label) |
| A name for the member that writes to this output in the stream report (nothing happens if there is none). | |
| MemberStats | statsOf (Member member) |
| What the writes to this member took so far (a copy). | |
| java.util.List< MemberStats > | memberStats () |
| What the writes to each member took so far (copies), in the order of the members. | |
| Member | addMember (Output out, Timing timing) |
| Adds a player to the group. | |
| void | removeMember (Member member) |
Takes a player out of the group and sends it stream/end if its stream was started. | |
| boolean | hasFailed (Member member) |
| True if this member's output failed (it has left the group by itself). | |
| boolean | isStreaming () |
| True while a stream is open at the players. | |
| boolean | write (byte[] data, int offset, int length) |
| Hands over PCM. | |
| void | discard () |
| The audio handed over so far is stale (a seek, a stop, a flush of the player): drop what is waiting. | |
| void | end () |
Pause or stop: stream/end to every member; audio is refused until begin(). | |
| void | begin () |
| Play or resume: audio is accepted again; the stream starts with the next write. | |
| boolean | hasFailed () |
| True when no member is left that can be sent to (with one member: its output failed). | |
Public Member Functions inherited from de.yaacc.multiroom.feed.PcmSink | |
Static Public Attributes | |
| static final int | CHUNK_MILLIS = 20 |
Turns the PCM that the player of YAACC produces (16 bit stereo, little endian, at the rate the Sendspin player listed) into the timestamped chunks of a Sendspin stream and sends them with a fixed lead: a chunk goes out when it is lead ahead of the moment it must play, so the player holds about lead of audio.
That is the pacing the server owes the player: ExoPlayer decodes faster than real time, and write therefore waits (back pressure) until the chunk is due.
The timeline is continuous across tracks. It restarts at now + lead when a stream starts, after a discard() (a seek or a skip: stream/clear) and when the producer fell behind and the next chunk would be late (a gap in the sound, no stream message). end() sends stream/end (pause, stop) and refuses audio until begin(); the stream starts again with the next write. The audio a player may hold is bounded by its buffer_capacity: the bytes of the chunks that have not finished playing, as the specification counts them (13 bytes of header and the payload of each chunk).
write is for one thread (the audio thread); discard, end and begin may come from another and interrupt a wait in progress.
A group (linking, groups.md) is the same streamer with several members: one timeline (the same timestamps for every member, which is what keeps them in sync), one chunk cut once, and for every member its own output and its own buffer accounting. The lead of the group is the largest lead of its members, so that no member gets a chunk later than it asks for; a member that comes in while the group plays is started by the audio thread with the next chunk and plays in sync from there (the timestamps are absolute); a member whose output fails leaves the group and the others go on. With one member this is exactly the stream of one player.
Adds a player to the group.
It never writes to the network itself: while a stream runs, the audio thread starts the member with the next chunk (so this may be called from any thread).
Referenced by de.yaacc.sendspin.hub.PcmStreamer.PcmStreamer(), and de.yaacc.sendspin.hub.HubConnection.streamer().

| void de.yaacc.sendspin.hub.PcmStreamer.awaitWrites | ( | long | millis | ) |
Waits (at most millis) until what was posted to the members so far has been written.
For a caller that sends something else to the same socket right after, such as the close frame after stream/end. Must not be called with the lock held.
Referenced by de.yaacc.sendspin.hub.HubConnection.close(), and de.yaacc.sendspin.hub.HubConnection.stopPlayback().

| void de.yaacc.sendspin.hub.PcmStreamer.discard | ( | ) |
The audio handed over so far is stale (a seek, a stop, a flush of the player): drop what is waiting.
Implements de.yaacc.multiroom.feed.PcmSink.
| void de.yaacc.sendspin.hub.PcmStreamer.removeMember | ( | Member | member | ) |
Takes a player out of the group and sends it stream/end if its stream was started.
This writes to the network: call it from a thread that may.

| void de.yaacc.sendspin.hub.PcmStreamer.setTap | ( | Tap | tap | ) |
Sets or removes (null) the tap.
It runs on the streaming thread and must be quick; its failure changes nothing.
| void de.yaacc.sendspin.hub.PcmStreamer.useBackgroundWrites | ( | ) |
Every member gets a thread of its own that writes to it (call this before the first member is added).
A player whose socket does not take data then holds back only itself: the audio thread and the other players go on. A chunk that is past its playing time when the player's turn comes is not written, and what waits for a member is dropped by a clear or an end.
Referenced by de.yaacc.sendspin.hub.HubConnection.streamer().

| boolean de.yaacc.sendspin.hub.PcmStreamer.write | ( | byte[] | data, |
| int | offset, | ||
| int | length ) |
Hands over PCM.
May wait for a short, bounded time when the sink is full (back pressure); never grows without limit. The data is copied before this returns.
Implements de.yaacc.multiroom.feed.PcmSink.