Skip to main content

Crate ringo_agent

Crate ringo_agent 

Source
Expand description

Run a SIP user agent as its own process, driven over a framed stdio protocol (length-prefixed JSON control frames interleaved with raw PCM audio frames).

A consumer drives an agent via ProcessClient (spawned with ProcessClient::spawn), which forks a child that re-execs the host binary’s agent subcommand — the host wires that subcommand to worker::run. Each agent is its own process, with its own SIP socket and media stack, so several can run side by side without sharing the SIP stack’s process-global state — which a single shared process can’t do once incoming calls must each be routed to the right agent.

Public surface: ProcessClient + AgentConfig to drive an agent, worker::run (the worker entry the host re-execs), and audio (tone analysis / WAV helpers). The framed wire protocol is an internal detail.

Modules§

audio
Tone detection on received call audio (for verify-audio) and WAV output (for --save-audio).
worker
The agent worker: one process, one registered UA (with catchall), driven over stdio with the proto framed protocol. Because each worker is its own process it binds its own SIP socket, so the provider routes incoming calls to this registration by contact address — which in-process multi-UA cannot do (one shared socket, and the request-URI user need not identify the UA, so there’s no way to demux).

Structs§

AgentConfig
The full agent configuration the parent sends as the worker’s first stdin line (before any command/query). Carrying it on stdin rather than argv keeps credentials out of the process table. The Account/BackendOptions are embedded verbatim (they are Serialize/Deserialize in ringo-core), so the worker rebuilds the exact account the in-process path would — adding a field to either struct can’t silently drift out of sync.
AudioFrame
Re-exported so a consumer of ProcessClient::start_rx_audio can name the streamed frame type without also depending on ringo-core. A mono PCM audio frame plus its sample rate — the unit streamed into a call via push_audio / out of one via subscribe_received_audio. A mono PCM (s16) audio frame plus its sample rate — the unit fed into a call via push_audio and handed out of one via subscribe_received_audio.
ProcessClient
Handle to one agent worker process. Spawn it with ProcessClient::spawn, then drive it: fire-and-forget call-control commands, blocking queries (media stats, received DTMF, tone analysis, …), and an AppEvent stream (returned by spawn). Dropping it deregisters and reaps the worker.
SavedAudio
One WAV written by ProcessClient::save_audio_detailed: which side of the call it holds, how much audio it contains, and whether the recording hit the retention cap (only the newest ringo_core::RECORDING_MAX_SECS seconds are kept).