Struct CallHandle

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

A handle to a SIP call (specific type of dialog) for call-related operations

Provides call-specific convenience methods on top of the basic dialog operations. CallHandle extends DialogHandle with operations that are specifically relevant to voice/video calls, such as hold/resume, transfer, and media management.

§Key Features

  • Call Lifecycle: Answer, reject, and hang up calls
  • Call Control: Hold, resume, transfer, and mute operations
  • Media Management: Update media parameters and handle media events
  • Call Information: Access to call-specific metadata and state
  • Dialog Access: Full access to underlying dialog operations

§Examples

§Basic Call Operations

use rvoip_dialog_core::api::common::CallHandle;
use rvoip_sip_core::StatusCode;

// Get call information
let info = call.info().await?;
println!("Call {} from {} to {}", info.call_id, info.local_uri, info.remote_uri);
println!("State: {:?}", info.state);

// Answer an incoming call
call.answer(Some("SDP answer with media info".to_string())).await?;

// Or reject a call
// call.reject(StatusCode::Busy, Some("Busy right now".to_string())).await?;

§Call Control Operations

use rvoip_dialog_core::api::common::CallHandle;

// Put call on hold
let hold_sdp = "v=0\r\no=- 123 456 IN IP4 0.0.0.0\r\n...";
call.hold(Some(hold_sdp.to_string())).await?;
println!("Call on hold");

// Resume from hold
let resume_sdp = "v=0\r\no=- 123 457 IN IP4 192.168.1.100\r\n...";
call.resume(Some(resume_sdp.to_string())).await?;
println!("Call resumed");

// Transfer to another party
call.transfer("sip:alice@example.com".to_string()).await?;
println!("Call transferred");

§Advanced Call Management

use rvoip_dialog_core::api::common::CallHandle;

// Update media parameters
let new_sdp = "v=0\r\no=- 123 458 IN IP4 192.168.1.100\r\n...";
call.update_media(Some(new_sdp.to_string())).await?;

// Send call-related information
call.send_info("DTMF: 1".to_string()).await?;

// Send call event notification
call.notify("call-status".to_string(), Some("ringing".to_string())).await?;

// Advanced transfer with custom REFER
let refer_body = "Refer-To: sip:bob@example.com\r\nReplaces: abc123";
call.transfer_with_body("sip:bob@example.com".to_string(), refer_body.to_string()).await?;

§Call State Monitoring

use rvoip_dialog_core::api::common::CallHandle;
use rvoip_dialog_core::dialog::DialogState;

// Monitor call state
while call.is_active().await {
    let state = call.dialog_state().await?;
    match state {
        DialogState::Early => println!("Call ringing..."),
        DialogState::Confirmed => {
            println!("Call answered and active");
            break;
        },
        DialogState::Terminated => {
            println!("Call ended");
            break;
        },
        _ => {}
    }
    tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
}

§Integration with Dialog Operations

use rvoip_dialog_core::api::common::CallHandle;
use rvoip_sip_core::Method;

// Access underlying dialog handle
let dialog = call.dialog();
 
// Use dialog operations directly
let tx_key = dialog.send_request(Method::Options, None).await?;
println!("Sent OPTIONS via dialog: {}", tx_key);

// Or use call-specific shortcuts
let tx_key = call.send_request(Method::Info, Some("Call info".to_string())).await?;
println!("Sent INFO via call: {}", tx_key);

Implementations§

Source§

impl CallHandle

Source

pub fn dialog(&self) -> &DialogHandle

Get the underlying dialog handle

Source

pub fn call_id(&self) -> &DialogId

Get the call ID (same as dialog ID)

Source

pub async fn info(&self) -> ApiResult<CallInfo>

Get call information

Source

pub async fn answer(&self, sdp_answer: Option<String>) -> ApiResult<()>

Answer the call (send 200 OK)

§Arguments
  • sdp_answer - Optional SDP answer for media negotiation
§Returns

Success or error

Source

pub async fn reject( &self, status_code: StatusCode, reason: Option<String>, ) -> ApiResult<()>

Reject the call

§Arguments
  • status_code - SIP status code for rejection
  • reason - Optional reason phrase
§Returns

Success or error

Source

pub async fn hangup(&self) -> ApiResult<()>

Hang up the call (send BYE)

Source

pub async fn hold(&self, hold_sdp: Option<String>) -> ApiResult<()>

Put the call on hold

§Arguments
  • hold_sdp - SDP with hold attributes
§Returns

Success or error

Source

pub async fn resume(&self, resume_sdp: Option<String>) -> ApiResult<()>

Resume the call from hold

§Arguments
  • resume_sdp - SDP with active media attributes
§Returns

Success or error

Source

pub async fn transfer(&self, transfer_target: String) -> ApiResult<()>

Transfer the call

§Arguments
  • transfer_target - URI to transfer the call to
§Returns

Success or error

Source

pub async fn transfer_with_body( &self, transfer_target: String, refer_body: String, ) -> ApiResult<TransactionKey>

NEW: Advanced transfer with custom REFER body

Allows sending custom REFER bodies for advanced transfer scenarios.

§Arguments
  • transfer_target - URI to transfer the call to
  • refer_body - Custom REFER body with additional headers
§Returns

Transaction key for the REFER request

Source

pub async fn notify( &self, event: String, body: Option<String>, ) -> ApiResult<TransactionKey>

NEW: Send call-related notifications

Send NOTIFY requests for call-related events.

§Arguments
  • event - Event type being notified
  • body - Optional notification body
§Returns

Transaction key for the NOTIFY request

Source

pub async fn update_media( &self, sdp: Option<String>, ) -> ApiResult<TransactionKey>

NEW: Update call media parameters

Send UPDATE request to modify media parameters without re-INVITE.

§Arguments
  • sdp - Optional SDP body with new media parameters
§Returns

Transaction key for the UPDATE request

Source

pub async fn send_info(&self, info_body: String) -> ApiResult<TransactionKey>

NEW: Send call information

Send INFO request with call-related information.

§Arguments
  • info_body - Information to send
§Returns

Transaction key for the INFO request

Source

pub async fn dialog_state(&self) -> ApiResult<DialogState>

NEW: Direct dialog operations for advanced use cases Get dialog state

Source

pub async fn send_request( &self, method: Method, body: Option<String>, ) -> ApiResult<TransactionKey>

Send custom request in dialog

Source

pub async fn send_response( &self, transaction_id: &TransactionKey, response: Response, ) -> ApiResult<()>

Send response for transaction

Source

pub async fn is_active(&self) -> bool

Check if the call is still active

Trait Implementations§

Source§

impl Clone for CallHandle

Source§

fn clone(&self) -> CallHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CallHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,