Skip to main content

Call

Struct Call 

Source
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: RemoteMedia

Where 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: SocketAddr

Local RTP address advertised in our SDP.

Implementations§

Source§

impl Call

Source

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.

Source

pub fn is_held(&self) -> bool

true if the call is currently on hold (we sent a sendonly re-INVITE the peer accepted).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn peer_uri(&self) -> &Uri

The peer’s remote-target URI (its Contact) — the address a third party should INVITE to reach this exact peer. Used as the Refer-To target of an attended transfer (read off the consultation call), paired with Call::dialog_triplet for the Replaces.

Source

pub fn dialog_triplet(&self) -> DialogTriplet

This call’s dialog identity (Call-ID + our/remote tags), for naming it in an attended transfer’s Replaces (RFC 3891). Read it off the consultation call (the leg we built to the transfer target) and pass it to Call::attended_transfer on the call being transferred.

Source

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.

Source

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.

Source

pub async fn attended_transfer( &mut self, target: Uri, replaces: &DialogTriplet, ) -> Result<(), Box<dyn Error + Send + Sync>>

Attended-transfer the call: ask the peer (the party we hold) to take over the consultation dialog named by replaces by sending an in-dialog REFER whose Refer-To carries target plus a Replaces header (RFC 3515 + RFC 3891).

replaces is the dialog identity of the consultation call — the leg we already established to target ourselves — read via Call::dialog_triplet. When the peer accepts (202), it INVITEs target with that Replaces, so target replaces the consultation leg rather than ringing afresh. The outcome arrives exactly as for a blind transfer — NOTIFY/sipfrag on Call::inbound_requests — so the consumer drives both the same way. A non-2xx final to the REFER surfaces the peer’s reason and leaves the call unchanged.

Source

pub async fn hangup(&mut self) -> Result<(), Box<dyn Error + Send + Sync>>

Hang up by sending an in-dialog BYE. Returns once the peer 2xxs it (or the transaction gives up).

Trait Implementations§

Source§

impl Drop for Call

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§

§

impl !RefUnwindSafe for Call

§

impl !UnwindSafe for Call

§

impl Freeze for Call

§

impl Send for Call

§

impl Sync for Call

§

impl Unpin for Call

§

impl UnsafeUnpin for Call

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more