pub struct Call {
pub remote_media: RemoteMedia,
pub rtp_socket: Arc<UdpSocket>,
pub local_rtp_addr: SocketAddr,
/* private fields */
}Expand description
An established call: negotiated remote media plus the local RTP socket.
The same handle is produced by Caller::dial (outbound) and
crate::IncomingCall::accept (inbound), so call control is uniform.
Fields§
§remote_media: RemoteMediaWhere the remote endpoint expects RTP (from the negotiated SDP).
rtp_socket: Arc<UdpSocket>Local RTP socket; share via Arc to send and receive concurrently.
local_rtp_addr: SocketAddrLocal RTP address advertised in our SDP.
Implementations§
Source§impl Call
impl Call
Sourcepub async fn set_hold(
&mut self,
on: bool,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn set_hold( &mut self, on: bool, ) -> Result<(), Box<dyn Error + Send + Sync>>
Put the peer on hold (on = true, a=sendonly) or resume the call
(on = false, a=sendrecv) by sending an in-dialog re-INVITE with a
fresh SDP re-offer (RFC 3264 §8.4).
The local hold state only flips once the peer accepts the re-INVITE with
a 2xx; a non-2xx final surfaces the server’s reason and leaves the call
unchanged. The o= version is bumped for each re-offer regardless, as
RFC 3264 requires.
Sourcepub fn is_held(&self) -> bool
pub fn is_held(&self) -> bool
true if the call is currently on hold (we sent a sendonly re-INVITE
the peer accepted).
Sourcepub fn session_timer(&self) -> Option<SessionTimer>
pub fn session_timer(&self) -> Option<SessionTimer>
The RFC 4028 session timer negotiated when the call was set up, or
None if neither side asked for one. Drive it with
crate::session_timer_loop against Call::session_handle.
Sourcepub fn session_handle(&self) -> CallSession
pub fn session_handle(&self) -> CallSession
A cloneable handle that sends refresh re-INVITEs / BYE on this call’s
dialog, for running crate::session_timer_loop in a background task
alongside the audio path. Shares the dialog with the Call, so their
in-dialog requests serialize correctly.
Sourcepub fn inbound_requests(&self) -> InboundRequests
pub fn inbound_requests(&self) -> InboundRequests
Opt in to handle this call’s inbound in-dialog requests — the peer’s
re-INVITEs (e.g. an RFC 4028 session refresh, or a peer-initiated
hold) and INFOs (e.g. SIP-INFO DTMF) — instead of having the endpoint
auto-answer them 200 OK.
Returns a stream; each InboundRequest must be answered (with
InboundRequest::respond / InboundRequest::ok). While the returned
InboundRequests is alive, those requests route here; drop it to
revert to auto-answering. BYE / OPTIONS are always auto-answered.
Call this once per Call.
Sourcepub fn terminated(&self) -> CancellationToken
pub fn terminated(&self) -> CancellationToken
A token that fires when the peer ends the call by sending an in-dialog
BYE. The endpoint auto-answers the BYE 200 OK; this is purely the
notification. Clone it and await CancellationToken::cancelled in a
task to drive call teardown (stop audio, finalize a recording). It does
not fire for a local Call::hangup — the caller already knows.
Sourcepub async fn send_dtmf_info(
&mut self,
digit: DtmfDigit,
duration_ms: u32,
) -> InfoOutcome
pub async fn send_dtmf_info( &mut self, digit: DtmfDigit, duration_ms: u32, ) -> InfoOutcome
Send one DTMF press via SIP INFO (application/dtmf-relay).
Use this only when the remote did not negotiate RFC 4733 — i.e.
RemoteMedia::dtmf_payload_type is None. When telephone-event is
available, prefer crate::send_dtmf_burst over RTP. A
InfoOutcome::UnsupportedMedia result means the remote rejects this
transport too; stop sending further presses on this dialog.
Sourcepub async fn blind_transfer(
&mut self,
target: Uri,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn blind_transfer( &mut self, target: Uri, ) -> Result<(), Box<dyn Error + Send + Sync>>
Blind-transfer the call: ask the peer to place a fresh call to target
by sending an in-dialog REFER with a Refer-To (RFC 3515).
Returns Ok(()) once the peer accepts the REFER with a 2xx
(202 Accepted) — at which point the transfer is in progress, not yet
complete. The peer then reports the outcome as a series of in-dialog
NOTIFYs (a message/sipfrag status line) that arrive on
Call::inbound_requests; the consumer watches those (parsing each with
crate::parse_sipfrag_status) and tears its own leg down once the
target answers. A non-2xx final to the REFER surfaces the peer’s reason
and leaves the call unchanged — the peer won’t honour the transfer, so
the consumer should keep the call up.
This is blind (unattended) transfer: we do not first call target
ourselves. Attended transfer (consult target, then REFER with
Replaces) is a separate method, not yet implemented.