Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 48 additions & 80 deletions README.md

Large diffs are not rendered by default.

25 changes: 7 additions & 18 deletions messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ Players that can output audio should have the role `player`.
- `color@v1` - receives colors derived from the current audio
- `player@v1_support?`: object - required if `player@v1` is listed, absent otherwise ([see player@v1 support object details](roles/player/v1.md#client--server-clienthello-playerv1-support-object))
- `source@v1_support?`: object - required if `source@v1` is listed, absent otherwise ([see source@v1 support object details](roles/source/v1.md#client--server-clienthello-sourcev1-support-object))
- `artwork@v1_support?`: object - required if `artwork@v1` is listed, absent otherwise ([see artwork@v1 support object details](roles/artwork/v1.md#client--server-clienthello-artworkv1-support-object))
Comment thread
kahrendt marked this conversation as resolved.
Resolved
- `visualizer@v1_support?`: object - required if `visualizer@v1` is listed, absent otherwise ([see visualizer@v1 support object details](roles/visualizer/v1.md#client--server-clienthello-visualizerv1-support-object))
- `supported_pair_methods`: object - pairing methods this client currently offers, keyed by method identifier, each value a [pair-method descriptor](pairing.md#client--server-clienthello-pair-method-descriptor). An implemented method that is [disabled](management.md#server--client-managementset-pairing-config) is omitted.
- `unpaired_access`: object - whether this client currently admits [unpaired access](pairing.md#unpaired-access)
Expand Down Expand Up @@ -259,7 +258,7 @@ For synchronization, all timing is relative to the server's monotonic clock. The

Client sends state updates to the server. Contains client-level state and role-specific state objects.

Sent once the client is ready to report its operational status (`available`), and whenever any state changes thereafter. A player reports `available: true` only after it has established [clock synchronization](#clock-synchronization). The server MUST NOT send binary data to a client before that client has sent its initial `client/state`. When a role becomes active in `active_roles`, send an update that includes that role's object.
Sent once the client is ready to report its operational status (`available`), and whenever any state changes thereafter. A player reports `available: true` only after it has established [clock synchronization](#clock-synchronization). The server MUST NOT send binary data to a client before that client has sent its initial `client/state`. When a role becomes active in `active_roles`, the client MUST send an update that includes that role's object.

A client whose `active_roles` are non-empty sends the initial `client/state` even when none of its roles defines a state object.

Expand All @@ -270,6 +269,8 @@ Every message MUST carry `available` and the full state of each role object it i
- `false` - client's output is in use by an external system and is not currently participating in Sendspin playback with this server. See [External Source Handling](#external-source-handling)
- `player?`: object - only if client has `player` role ([see player state object details](roles/player/v1.md#client--server-clientstate-player-object))
- `source?`: object - only if client has `source` role ([see source state object details](roles/source/v1.md#client--server-clientstate-source-object))
- `artwork?`: object - only if client has `artwork` role ([see artwork state object details](roles/artwork/v1.md#client--server-clientstate-artwork-object))
- `visualizer?`: object - only if client has `visualizer` role ([see visualizer state object details](roles/visualizer/v1.md#client--server-clientstate-visualizer-object))

[Application-specific roles](README.md#application-specific-roles) may also include objects in this message (keys starting with `_`).

Expand Down Expand Up @@ -349,6 +350,10 @@ Starts a stream for one or more roles. If sent for a role that already has an ac

The server MUST NOT send `stream/start` to a client that is not [`available`](#client--server-clientstate) (e.g. a client whose output is taken by an [external source](#external-source-handling)).

Each role's stream configuration is derived from what the client reports about itself: the role's support object in [`client/hello`](#client--server-clienthello) for constant capabilities, and the role's [`client/state`](#client--server-clientstate) object for the stream-configuration fields the client may change during the connection (each role may define both). After a role is added or re-added to `active_roles`, the server MUST wait for the [`client/state`](#client--server-clientstate) update the activation requires before starting that role's stream, so it does not start from stale state. When a `client/state` changes a role's stream-configuration fields while a stream is active for that role, the server re-derives the stream configuration and, if it changed, sends a `stream/start` with the new configuration. When no stream is active for the role, the server MUST NOT start one in response; the updated state applies to the next stream it starts for that role.

**Note:** Clients may change their stream-configuration fields to adapt to changing network conditions, CPU constraints, or display requirements. The server maintains separate encoding for each client, allowing heterogeneous device capabilities within the same group.

### Server → Client: `stream/clear`

Instructs clients to clear buffers without ending the stream. Used for seek operations and track jumps (switching to a different track without stopping the stream).
Expand All @@ -358,22 +363,6 @@ Instructs clients to clear buffers without ending the stream. Used for seek oper

[Application-specific roles](README.md#application-specific-roles) may also be included in this array (names starting with `_`).

### Client → Server: `stream/request-format`

Request different stream format (upgrade or downgrade). Available for clients with the `player`, `artwork`, or `visualizer` role.

- `player?`: object - only for clients with the `player` role ([see player object details](roles/player/v1.md#client--server-streamrequest-format-player-object))
- `artwork?`: object - only for clients with the `artwork` role ([see artwork object details](roles/artwork/v1.md#client--server-streamrequest-format-artwork-object))
- `visualizer?`: object - only for clients with the `visualizer` role ([see visualizer object details](roles/visualizer/v1.md#client--server-streamrequest-format-visualizer-object))

[Application-specific roles](README.md#application-specific-roles) may also include objects in this message (keys starting with `_`).

Response when a stream is active for the role: [`stream/start`](#server--client-streamstart) with the new configuration. If the server cannot honor the request, the stream continues in a configuration the client supports, and the server MUST NOT treat the request as an error.

Response when no stream is active for the role: the server MUST NOT start a stream in response, but SHOULD remember the requested format to apply to the next stream it starts for that role.

**Note:** Clients can use this message to adapt to changing network conditions, CPU constraints, or display requirements. The server maintains separate encoding for each client, allowing heterogeneous device capabilities within the same group.

### Server → Client: `stream/end`

Ends the stream for one or more roles. When received, clients should stop output and clear buffers for the specified roles. This message is expected to be sent when playback is over and the queue is empty. Specifically:
Expand Down
45 changes: 17 additions & 28 deletions roles/artwork/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,28 @@ This section describes messages specific to clients with the `artwork` role, whi

**Channels:** Artwork clients can support 1-4 independent channels, allowing them to display multiple related images. For example, a device could display album artwork on one channel while simultaneously showing artist photos or background images on other channels. Each channel operates independently with its own format, resolution, and source type (album or artist artwork).

### Client → Server: `client/hello` artwork@v1 support object
### Client → Server: `client/state` artwork object

The `artwork@v1_support` object in [`client/hello`](../../messaging.md#client--server-clienthello) has this structure:
The `artwork` object in [`client/state`](../../messaging.md#client--server-clientstate) has this structure:

- `artwork@v1_support`: object
- `channels`: object[] - list of supported artwork channels (length 1-4), array index is the channel number
- `artwork`: object
- `channels`: object[] - configuration the client wants for each artwork channel, array index is the channel number
- `source`: 'album' | 'artist' | 'none' - artwork source type
- `format`: 'jpeg' | 'png' - image format identifier
- `width`: integer - width in pixels of the delivered image
- `height`: integer - height in pixels of the delivered image

The server MUST deliver each image at exactly the `width` by `height` declared for the channel. It MUST scale the source image to fit within those dimensions preserving its aspect ratio, MUST pad the remaining area with black, and MUST NOT crop the image.
- `format?`: 'jpeg' | 'png' - image format identifier. Required unless `source` is `'none'`
- `width?`: integer - width in pixels of the delivered image. Required unless `source` is `'none'`
- `height?`: integer - height in pixels of the delivered image. Required unless `source` is `'none'`

**Note:** Clients can support 1-4 independent artwork channels depending on their display capabilities. The channel number is determined by array position: `channels[0]` is channel 0 (binary message type 8), `channels[1]` is channel 1 (binary message type 9), etc.
The `channels` array is positional from channel 0 (length 1-4). A channel index the array does not cover is `source: 'none'`, so a client MAY truncate the array after its last active channel. An `artwork` object whose `channels` array is longer than 4 is a protocol error; the server SHOULD close the connection.

**None source:** If a channel has `source` set to `none`, the server will not send any artwork data for that channel. This allows clients to disable and enable specific channels on the fly through [`stream/request-format`](#client--server-streamrequest-format-artwork-object) without needing to re-establish the WebSocket connection (useful for dynamic display layouts).
**Note:** Clients can use 1-4 independent artwork channels depending on their display capabilities. Channel 0 uses binary message type 8, channel 1 uses type 9, etc.

Servers MUST support 'jpeg' and 'png'.

### Client → Server: `stream/request-format` artwork object

The `artwork` object in [`stream/request-format`](../../messaging.md#client--server-streamrequest-format) has this structure:

Request the server to change the artwork format for a specific channel. The client can send multiple `stream/request-format` messages to change formats on different channels.
The server MUST deliver each image at exactly the `width` by `height` declared for the channel. It MUST scale the source image to fit within those dimensions preserving its aspect ratio, MUST pad the remaining area with black, and MUST NOT crop the image.

Response when an `artwork` stream is active: [`stream/start`](../../messaging.md#server--client-streamstart) with the new format, followed by immediate artwork updates through binary messages.
When a channel's configuration changes while an `artwork` stream is active, the server responds with a [`stream/start`](../../messaging.md#server--client-streamstart) carrying the new configuration, followed by immediate artwork updates through binary messages for the channels whose configuration changed.

- `artwork`: object
- `channel`: integer - channel number (0-3) corresponding to the channel index declared in the artwork [`client/hello`](#client--server-clienthello-artworkv1-support-object)
- `source?`: 'album' | 'artist' | 'none' - artwork source type
- `format?`: 'jpeg' | 'png' - requested image format identifier
- `width?`: integer - requested width in pixels
- `height?`: integer - requested height in pixels
**None source:** If a channel has `source` set to `none`, the server will not send any artwork data for that channel. This allows clients to disable and enable specific channels on the fly without needing to re-establish the WebSocket connection (useful for dynamic display layouts).

### Server → Client: `stream/start` artwork object

Expand All @@ -44,13 +33,13 @@ The `artwork` object in [`stream/start`](../../messaging.md#server--client-strea
- `artwork`: object
- `channels`: object[] - configuration for each artwork channel, array index is the channel number
- `source`: 'album' | 'artist' | 'none' - artwork source type
- `format`: 'jpeg' | 'png' - format of the encoded image
- `width`: integer - width in pixels of the encoded image
- `height`: integer - height in pixels of the encoded image
- `format?`: 'jpeg' | 'png' - format of the encoded image. Required unless `source` is `'none'`
- `width?`: integer - width in pixels of the encoded image. Required unless `source` is `'none'`
- `height?`: integer - height in pixels of the encoded image. Required unless `source` is `'none'`

The `channels` array covers every channel index the client declared in [`artwork@v1_support`](#client--server-clienthello-artworkv1-support-object) in the same order. A channel the server is not streaming is represented as `source: 'none'`.
The `channels` array is positional from channel 0 and never longer than 4. A channel the array does not cover, or whose `source` is `'none'`, is not streamed; the server SHOULD truncate the array after the last streamed channel.

Each channel's configuration MUST match the client's current capability for that channel: the [`client/hello`](#client--server-clienthello-artworkv1-support-object) declaration, as later modified by the [`stream/request-format`](#client--server-streamrequest-format-artwork-object) changes the server honored. The `source`, `format`, `width`, and `height` MUST match the declaration.
Each channel's configuration MUST match the channel's current [`client/state`](#client--server-clientstate-artwork-object) artwork declaration, a channel the state array does not cover counting as `source: 'none'`.

**Late join:** After an artwork `stream/start` (initial or after a reconnection), the server SHOULD immediately send the current image for each channel whose `source` is not `'none'`, so a client joining mid-track does not stay blank until the next track change. If an image is also scheduled ahead for the channel, the server sends the current image first, then re-sends the scheduled one (in the other order, the current image would discard the schedule).

Expand Down
Loading
Loading