Streaming AudioFlow over Ktor
The Ktor extension adds tiny adapters between Kodio's AudioFlow and Ktor's WebSocket / Server-Sent-Events plumbing so you can stream live mic capture to a backend (or pull a remote stream into a Player) without reinventing the framing.
Wire format
The protocol is intentionally minimal:
Format header — the
AudioFormatis encoded withAudioFormat.encodeToByteArray(), prefixed with the four ASCII bytesKDIO, and sent as the first binary frame.Chunks — every subsequent binary frame is one raw PCM byte chunk in the declared format.
The constants live in AudioFlowWireFormat.
Send a recorder over WebSocket
Stream a live recording from a mobile/desktop client to a server endpoint:
AudioFlow.sendOverWebSocket opens the socket, sends the format header, forwards every chunk as a binary frame, and closes cleanly.
Receive an AudioFlow on the server
A Ktor server can read the same protocol with one call:
Or call WebSocketSession.receiveAudioFlow() from any custom handler that already manages the session lifecycle.
Pull an AudioFlow from a server
Symmetrically, fetch a server-pushed AudioFlow into a Kodio Player:
SSE fallback
The current release ships WebSocket support only. SSE-based delivery (for environments where WebSockets are blocked) is planned as a follow-up and will re-use the same KDIO-prefixed header — track GitHub issue #6 for status.
Maven coordinates
This module declares kodio-core, ktor-client-core, and ktor-client-websockets as api dependencies — bring your own engine (ktor-client-cio, ktor-client-darwin, ktor-client-js, …).