Add support for the source role for audio input clients newly added to Sendspin spec?
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- cpp
- Domain
- audio-video-rtc
Research direction
Start with the Sendspin specification's Source messages section and review the linked aiosendspin and sendspin-cli draft pull requests for implementation context. Confirm the library's source@v1 behavior against the specification, including pairing, handshake support, source state and commands, stream start/end, and timestamped audio chunks.
Written by the indexing model from the issue text.
Description
Tracking the adding of initial basic support for the source role v1 to this specific library (i.e. first version of source role for audio input clients) that were recently added as a new role to the Sendspin specification? Please close this tracker issue when implemented is this library.
Note that https://github.com/Sendspin/spec/pull/113 removed supported_formats from source@v1_support after the above linked PR was opened.
For reference see ongoing developer discussions of source role implementations in these draft PR to the aiosendspin and sendspin-cli repos:
For suggested real world use-cases for this new source with the combination of Music Assistant and ESPHome please see these related discussions:
Source - captures audio from a local input and streams it to the server. A client captures audio from a local input (line-in, turntable, Bluetooth, microphone) and streams it to the server, which decodes, mixes, and distributes it to players like any other audio.
Note that this first version of the new source is heavily based on https://github.com/Sendspin/spec/pull/52 by rudyberends but simplified to the core and thus removed functions and features that might be added to a future version of the Sendspin specification where the source role could maybe get extended.
For reference, this "also rebases it onto the encryption work (https://github.com/Sendspin/spec/pull/84), and now requires source clients to be paired since an unpaired source could otherwise inject malformed audio into the server."
Source messages
This section describes messages specific to clients with the source role, which capture audio from a local input (e.g., AUX/line-in, turntable preamp, Bluetooth receiver, or microphone) and stream it to the server. Unlike other roles, a source sends audio to the server; the server remains the single place that resamples, transcodes, mixes, buffers, and distributes audio to output players. Sources stay simple: they capture and encode audio, optionally report basic signal presence (line sensing), and stream timestamped audio frames.
A device MAY implement both the source and player roles (e.g., a speaker with a local AUX input forwarded into Sendspin).
Note: The source role (capturing input into Sendspin) is distinct from a client reporting available: false, which marks a client whose output has been taken over by a non-Sendspin system.
A source client uses the same clock synchronization mechanism as all clients. Binary source audio messages are timestamped in the server time domain by converting the local capture time with the offset the time filter tracks.
Pairing required: A source streams captured audio (potentially from a microphone or line-in) to the server, so it MUST only run on a paired connection (trust level user). Servers MUST NOT activate source@v1 over unpaired access, and a source client MUST refuse to stream when the connection's trust level is none.
Client → Server: client/hello source@v1 support object
The source@v1_support object in client/hello has this structure:
source@v1_support: objectfeatures?: object - optional feature hintsline_sense?: boolean - true if source reportssignal
Note: Servers MUST support all audio codecs: 'opus', 'flac', and 'pcm'.
Client → Server: client/state source object
The source object in client/state has this structure:
source: objectsignal?: 'present' | 'absent' - optional line sensing/signal presence, only if 'line_sense' is supported
Server → Client: server/command source object
The source object in server/command has this structure:
source: objectcommand: 'start' | 'stop'
Source command semantics
commandcontrols whether this source streams to the server:start: server requests the source to begin streaming. The client SHOULD sendclient_stream/startand then send source audio chunks.stop: server requests the source to stop streaming. The client SHOULD sendclient_stream/endand stop sending source audio chunks.
Default streaming behavior
The default after the handshake is stop: a source MUST NOT stream until the server sends command: "start". The server is the only party that initiates streaming.
A source that supports line sensing reports signal in client/state. The server MAY use it as a hint for when to send command: "start" or command: "stop", but the decision is server policy.
When the server removes source from active_roles, the client sends client_stream/end and stops sending chunks.
Client → Server: client_stream/start
The client_stream/start message announces the active input stream format and provides any required codec header data.
source: objectcodec: 'opus' | 'flac' | 'pcm'channels: integersample_rate: integerbit_depth: integercodec_header?: string - codec header encoded as standard Base64, if necessary (e.g., FLAC)
Client → Server: client_stream/end
The client ends the current input stream. After this message, no more source audio chunks SHOULD be sent until a new client_stream/start.
Client → Server: Source Audio Chunks (Binary)
Binary messages SHOULD be rejected by the server if there is no open input stream (i.e., received before a client_stream/start or after a client_stream/end) or the client is not available.
Clients MUST send client_stream/start before the first audio chunk.
- Byte 0: message type
12(uint8) - Bytes 1-8: timestamp (big-endian int64) - server clock time in microseconds when the first sample was captured
- Rest of bytes: encoded audio frame
The timestamp indicates when the first audio sample in this chunk was captured (in server time domain). The server MAY resample/transcode and then distribute the audio to players with its normal buffering and synchronization strategy.
A device that implements both source and player MUST NOT play its captured input locally. Like every player, it outputs only the stream the server distributes, so its output stays in sync with the rest of the group.
Note: Source timestamps are derived from the client's clock offset, which the time filter keeps re-estimating, so they may show discontinuities or drift (e.g., ADC clock variance). Server implementations SHOULD NOT assume perfectly continuous timestamps; the audio sample stream itself SHOULD remain continuous.
- Dominant language
- C++
- Stars
- 29
- Forks
- 12
- Avg merge
- 12h 35m
- Merged PRs (30d)
- 67
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Sendspin/sendspin-cpp
-
Check to see if the input/output are the same device and if the input can be renamed seperatelyOpen
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Sendspin/sendspin-cpp#134 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Sendspin/sendspin-cpp#82 ·
Maintainers usually reply within 1 day
-
Support clearing external buffersMay be free again @kahrendt claimed this 92 days ago, and no pull request is open. Openenhancement
Sendspin/sendspin-cpp#55 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in Sendspin/sendspin-cpp
Similar issues
-
refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
compiler-explorer/compiler-explorer#9272 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day