Skip to main content

ProcessClient

Struct ProcessClient 

Source
pub struct ProcessClient { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl ProcessClient

Source

pub fn spawn(config: AgentConfig) -> Result<(Self, Receiver<AppEvent>)>

Spawn a worker for config, returning the client and the agent’s event stream (already converted to backend-neutral AppEvents).

Source

pub fn pid(&self) -> u32

The worker’s OS process id — the <pid> in its per-agent log and SIP trace file names (see crate::worker::per_agent_path).

Source

pub fn headers_handle(&self) -> Arc<Mutex<Option<InviteHeaders>>> ⓘ

A clone of the inbound-header buffer, for building a header_poll closure.

Source

pub fn request_shutdown(&self)

Tell the worker to shut down (deregister + exit) without blocking. Sent at most once; call this on all agents before dropping them so their de-REGISTERs run concurrently instead of one-at-a-time on each drop.

Source

pub fn register(&self, aor: &str, regint: u32)

Register the account at aor with the given re-register interval (s).

Source

pub fn dial(&self, number: &str)

Place an outgoing call to number (a SIP URI or a bare number/extension).

Source

pub fn hangup(&self)

Hang up the active call.

Source

pub fn hangup_all(&self)

Hang up all calls.

Source

pub fn accept(&self)

Answer the incoming call.

Source

pub fn hold(&self)

Put the active call on hold.

Source

pub fn resume(&self)

Resume the held call.

Source

pub fn mute(&self)

Mute the active call’s outgoing audio.

Source

pub fn send_dtmf(&self, digit: char)

Send a single DTMF digit on the active call.

Source

pub fn switch_line(&self, line: usize)

Not yet exposed by a scenario verb (line switching is planned).

Source

pub fn transfer(&self, uri: &str)

Blind-transfer the active call to uri.

Source

pub fn attended_transfer_start(&self, uri: &str)

Start an attended transfer: call uri as a consultation call.

Source

pub fn attended_transfer_exec(&self)

Complete the attended transfer (connect the two parties).

Source

pub fn attended_transfer_abort(&self)

Abort the attended transfer (hang up the consultation call).

Source

pub fn add_header(&self, key: &str, value: &str)

Add a custom SIP header sent on subsequent requests.

Source

pub fn rm_header(&self, key: &str)

Remove ALL custom headers with this name (the worker’s uarmheader semantics). Used by ringo-mcp for replace-on-add and by the phone’s per-call header re-rendering.

Source

pub fn set_audio_source(&self, spec: &str)

Switch the active call’s audio source (e.g. a tone, a file, or silence).

Source

pub fn set_recording(&self, on: bool)

Arm or disarm full-call recording for the agent’s UA: arming starts a fresh recording (a previous one is cleared); disarming keeps what was recorded until the next arm/call. Fire-and-forget like the worker’s other recording-free commands.

Source

pub fn arm_invite_response( &self, scode: u16, reason: &str, headers: Vec<String>, )

Arm a fixed response (status scode/reason + extra headers) for the next inbound INVITE instead of accepting it.

Source

pub fn disarm_invite_response(&self)

Clear a previously armed invite response (accept incoming calls again).

Source

pub fn deflect_incoming(&self, contact: &str, diversion: Option<&str>)

Mirror of the Phone::deflect_incoming default: arm a 302 with Contact (and optional RFC 5806 Diversion).

Source

pub fn media_stats(&self) -> Option<MediaStats>

RTP media stats for the active/last call, or None if unavailable.

Source

pub fn received_dtmf(&self) -> String

DTMF digits received on the active/last call so far, in order.

Source

pub fn save_audio(&self, prefix: &str) -> Vec<String>

Ask the worker to write its captured audio to <prefix>-sent.wav / <prefix>-recv.wav; returns the paths written.

Source

pub fn save_audio_detailed(&self, prefix: &str) -> Vec<SavedAudio>

Like Self::save_audio, but returns what each written WAV contains (side, duration, whether the retention cap truncated it) — the honest form for callers that report recordings.

Source

pub fn call_count(&self) -> u32

Number of active calls in the worker (0 if the worker is gone).

Source

pub fn start_tx_audio(&self, rate: u32)

Switch the agent’s audio source to live-streamed mono s16 PCM at rate Hz; feed it with Self::push_tx_audio (e.g. TTS output). Call this and feed push_tx_audio from the same thread: the worker requires the StartTxAudio control frame to arrive before any audio frame (it drops audio that arrives first), and the stdin lock is not FIFO across threads.

Source

pub fn push_tx_audio(&self, samples: &[i16])

Stream mono s16 PCM into the call as a raw audio frame (after Self::start_tx_audio, from the same thread).

Source

pub fn start_rx_audio(&self) -> Receiver<AudioFrame>

Start streaming the agent’s received audio; returns a receiver of mono AudioFrames (e.g. to feed STT or a parent-side tone analysis). One subscription per client.

Trait Implementations§

Source§

impl Drop for ProcessClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.