YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.sendspin.session.SourceMessages Class Reference

The messages of the source@v1 role of the Sendspin specification (commit 2cfe197, roles/source/v1.md): a client that feeds audio into a server. More...

Collaboration diagram for de.yaacc.sendspin.session.SourceMessages:
Collaboration graph

Classes

class  Chunk
 A chunk of a source.
 
class  State
 What the source said of itself in a client/state.
 
class  StreamStart
 The format of a source stream, range checked.
 

Static Public Member Functions

static List< String > parseSupportedCodecs (JSONObject serverHello)
 The codecs the server takes, read by a source from the server/hello; empty if the server takes no source.
 
static String serverCommand (boolean start)
 server/command that starts or stops the source.
 
static String parseServerCommand (JSONObject payload)
 
static String clientState (boolean available, String signal)
 client/state of a source: whether it is available and whether it has audio to offer (present or absent).
 
static State parseState (JSONObject payload)
 The availability and the signal of a client/state (an unknown signal counts as none).
 
static String clientStreamStart (String codec, int channels, int sampleRate, int bitDepth, String codecHeader)
 client-stream/start: the format of the stream the source opens (codecHeader: Base64, for FLAC; else null).
 
static StreamStart parseClientStreamStart (JSONObject payload) throws ProtocolException
 
static String clientStreamEnd ()
 client-stream/end for the source stream.
 
static boolean endsSource (JSONObject payload)
 True if a client-stream/end ends the source stream: it names source, or names no roles (all streams of the client).
 
static byte[] chunk (long serverMicros, byte[] audio, int offset, int length)
 The body of a chunk (the type is added by the channel): the capture time in the server clock, big endian, then the audio.
 
static Chunk parseChunk (byte[] body) throws ProtocolException
 

Static Public Attributes

static final String ROLE = "source@v1"
 The role as a client lists it and a server activates it.
 
static final int CHUNK_ID = 12
 The type of the binary message with a chunk of audio from a source to the server.
 
static final int MAX_CHUNK_MILLIS = 150
 A source may not send a chunk longer than this (the specification), and the server does not take one.
 

Detailed Description

The messages of the source@v1 role of the Sendspin specification (commit 2cfe197, roles/source/v1.md): a client that feeds audio into a server.

The server decides: it starts the source with server/command (source.command = start or stop); the source announces its format in client-stream/start, sends binary chunks of type 12 (an int64 timestamp in the server clock, big endian, then the encoded audio) and ends with client-stream/end. The source reports source.signal (present or absent) in client/state. The server lists the codecs it takes in source@v1_support.supported_codecs of its server/hello. The client is untrusted: every number is range checked, a violation is a ProtocolException. Pure.

Member Function Documentation

◆ parseChunk()

static Chunk de.yaacc.sendspin.session.SourceMessages.parseChunk ( byte[] body) throws ProtocolException
static
Exceptions
ProtocolExceptionif the body is shorter than the timestamp (a message shorter than 9 bytes with the type is a violation)

◆ parseClientStreamStart()

static StreamStart de.yaacc.sendspin.session.SourceMessages.parseClientStreamStart ( JSONObject payload) throws ProtocolException
static
Exceptions
ProtocolExceptionif there is no source object, the codec is not one of the specification or a number is out of range

◆ parseServerCommand()

static String de.yaacc.sendspin.session.SourceMessages.parseServerCommand ( JSONObject payload)
static
Returns
start or stop; null if the command is not one of the source role (or not a known one)

The documentation for this class was generated from the following file: