get_input_devices
Retrieves a list of available audio input devices on the system.Parameters
Whether to include loopback devices (Windows only). When
true, output devices are also listed with a [Loopback] prefix for capturing system audio.Returns
An array of device names available for audio capture. On Windows, loopback devices are prefixed with
[Loopback].Error Cases
Returns an error string if:- No audio host is available
- Unable to enumerate devices
Platform Notes
- Linux: Filters out ALSA virtual devices (
default,sysdefault,null,hw:*) that may not work reliably - Windows: Supports WASAPI loopback for system audio capture when
include_loopbackis true - macOS: Standard CoreAudio devices only
start_stream
Initiates an audio streaming session to a remote TCP server.Parameters
Name of the audio input device to capture from. Must match a device name returned by
get_input_devices().Target server IP address (IPv4).
Target server port number (1-65535).
Audio sample rate in Hz (e.g., 44100, 48000).
Hardware buffer size in frames. Used for standard input devices only. Loopback devices use system default.
Duration of the internal ring buffer in milliseconds. Automatically adjusted to minimum 5000ms for standard input and 8000ms for WASAPI loopback.
Enable automatic reconnection on connection loss. Uses exponential backoff (2s minimum, 60s maximum) with jitter.
Set network thread to maximum priority for reduced latency.
DSCP/QoS strategy for network packets. Valid values:
"voip"- Expedited Forwarding (EF, 0xB8)"lowdelay"- Low Delay (IPTOS_LOWDELAY, 0x10)"throughput"- Throughput (IPTOS_THROUGHPUT, 0x08)"besteffort"- Best Effort (0x00)
"voip" if invalid value provided.Number of samples per network transmission chunk.
Whether the selected device is a loopback device (for system audio capture).
Enable dynamic buffer resizing based on network jitter. Adjusts buffer size between
min_buffer_ms and max_buffer_ms.Minimum buffer size in milliseconds for adaptive buffering. Automatically adjusted to 2000ms (standard) or 4000ms (loopback) minimum.
Maximum buffer size in milliseconds for adaptive buffering. Automatically adjusted to 6000ms (standard) or 12000ms (loopback) maximum.
Returns
Returns
Ok(()) on successful stream initiation. The stream starts asynchronously; status updates are sent via events.Error Cases
Returns an error string if:- Device not found or inaccessible
- Unsupported audio format
- Unable to configure audio stream
- State lock acquisition fails
Behavior
- Stops any existing stream before starting a new one
- Automatically prefills buffer with 1000ms of audio before transmission
- Uses strict clock-based pacing to maintain constant bitrate
- Sends audio as 16-bit little-endian PCM over TCP
- Emits
log-event,stats-event,quality-event, andbuffer-resize-eventduring operation
stop_stream
Stops the currently active audio streaming session.Parameters
No user-provided parameters (state is managed internally).Returns
Returns
Ok(()) when the stop command is successfully sent. The stream stops asynchronously.Error Cases
Returns an error string if:- State lock acquisition fails
- Unable to send stop command
Behavior
- Gracefully closes TCP connection with FIN packets
- Disables auto-reconnect if enabled
- Clears internal stream state
- Safe to call even if no stream is active
get_os_type
Returns the current operating system platform.Parameters
None.Returns
Operating system identifier. Possible values:
"windows"- Windows"linux"- Linux"macos"- macOS- Other platform-specific values from Rust’s
std::env::consts::OS