Expand description
In-process SIP — answer raw SIP calls with no carrier service in the path.
(feature sip) Where super::twilio relies on a carrier
service to terminate the phone network and hand audio over a WebSocket,
this module terminates the call itself: SIP signalling via
rsipstack (the stack underneath the
rustpbx PBX), and G.711-over-RTP media built from this crate’s own pure
layers (super::rtp, super::sdp, super::g711).
Any SIP endpoint — a softphone, an Asterisk/FreeSWITCH PBX, a provider’s
SIP trunk — dials the agent directly, and each call attaches to a Live
session through the same voice::pump as every
other audio surface.
// `ignore`: `SipAgent` needs the `sip` feature and a bound UDP socket.
let mut agent = SipAgent::bind("0.0.0.0:5060".parse()?).await?;
while let Some(incoming) = agent.next_call().await {
let session = Live::builder()
.instruction("Answer the phone politely.")
.greeting("Greet the caller.")
.connect_from_env().await?;
let call = incoming.answer(&session).await?;
tokio::spawn(async move { call.ended().await; });
}RFC 4733 telephone events (DTMF) are negotiated in the SDP answer when
the offer proposes them; keypresses land in session state under the
shared super::bridge keys, where flow guards read them —
identical to the Twilio path. An RTP/SAVP offer with SDES keys is
answered with SRTP (super::srtp), and SipAgent::register registers
the agent with a PBX or trunk so it can be reached by address. Media is
symmetric RTP: the agent sends to the offer’s address but re-latches onto
the source of the first arriving packet, which keeps NATted softphones
working.
Structs§
- Incoming
Call - A ringing inbound call: answer it onto a session, or reject it.
- SipAccount
- A SIP account on a registrar (a PBX or a SIP trunk provider).
- SipAgent
- A SIP user agent server: binds a UDP SIP port and yields incoming calls.
- SipCall
- An answered SIP call with media flowing.
- SipRegistration
- A live registration, kept fresh in the background. See
SipAgent::register.
Enums§
- Registration
State - Where a
SipRegistrationstands. - SipError
- Errors from the SIP agent.