| Crates.io | rvoip-sip-client |
| lib.rs | rvoip-sip-client |
| version | 0.1.26 |
| created_at | 2025-08-01 08:17:57.691856+00 |
| updated_at | 2025-08-15 17:52:49.178821+00 |
| description | Unified SIP client library orchestrating client-core, audio-core, and codec-core for production-ready VoIP applications |
| homepage | https://github.com/eisenzopf/rvoip |
| repository | https://github.com/eisenzopf/rvoip |
| max_upload_size | |
| id | 1776252 |
| size | 385,398 |
A simple, batteries-included SIP client library for making and receiving VoIP calls in Rust.
Cargo.toml:[dependencies]
rvoip-sip-client = "0.1"
tokio = { version = "1.0", features = ["full"] }
use rvoip_sip_client::SipClient;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a SIP client with your SIP address
let client = SipClient::new("sip:alice@example.com").await?;
// Start the client
client.start().await?;
// Make a call
let call = client.call("sip:bob@example.com").await?;
// Wait for the other person to answer
call.wait_for_answer().await?;
println!("🎉 Call connected!");
// Let them talk for 30 seconds
tokio::time::sleep(Duration::from_secs(30)).await;
// Hang up
client.hangup(&call.id).await?;
println!("📞 Call ended");
Ok(())
}
use rvoip_sip_client::{SipClient, SipClientEvent};
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SipClient::new("sip:alice@example.com").await?;
client.start().await?;
// Subscribe to events
let mut events = client.events();
println!("📞 Waiting for calls...");
while let Some(event) = events.next().await {
match event {
SipClientEvent::IncomingCall { call, from, .. } => {
println!("📞 Incoming call from {}", from);
// Answer the call
client.answer(&call.id).await?;
println!("✅ Call answered!");
}
SipClientEvent::CallEnded { call } => {
println!("📞 Call ended: {}", call.id);
}
_ => {}
}
}
Ok(())
}
use rvoip_sip_client::SipClientBuilder;
// Connect to your company's PBX
let client = SipClientBuilder::new()
.sip_identity("sip:alice@company.com")
.sip_server("pbx.company.com:5060")
.build()
.await?;
// Call someone directly by IP address (no server needed!)
let call = client.call("sip:bob@192.168.1.100:5060").await?;
// Mute your microphone
client.set_mute(&call.id, true).await?;
// Unmute
client.set_mute(&call.id, false).await?;
use rvoip_audio_core::AudioDirection;
// List available microphones
let mics = client.list_audio_devices(AudioDirection::Input).await?;
for mic in mics {
println!("🎤 {}", mic.name);
}
// List available speakers
let speakers = client.list_audio_devices(AudioDirection::Output).await?;
for speaker in speakers {
println!("🔊 {}", speaker.name);
}
The library provides user-friendly error messages:
match client.call("sip:invalid@nowhere").await {
Ok(call) => println!("Call started"),
Err(e) => {
// You'll get helpful messages like:
// "Network connectivity issue detected"
// "Check your internet connection"
// "Verify firewall settings allow SIP traffic"
eprintln!("Call failed: {}", e);
}
}
use rvoip_sip_client::SipClientEvent;
match event {
SipClientEvent::IncomingCall { call, from, .. } => {
// Someone is calling you
}
SipClientEvent::CallConnected { call_id, .. } => {
// Call was answered
}
SipClientEvent::CallEnded { call } => {
// Call finished
}
SipClientEvent::AudioLevelChanged { level, .. } => {
// Audio volume changed (useful for UI meters)
}
_ => {}
}
✅ What Works Now:
⏳ Coming Soon:
The sip-client crate includes comprehensive tests, including integration tests that simulate full audio roundtrips between SIP clients.
Some tests require the test-audio feature to be enabled. To run all tests including the full roundtrip test:
# Using cargo alias (recommended)
cargo test-all
# Or explicitly with features
cargo test --features test-audio
# Or use the provided script
./run-all-tests.sh
# Run just the full roundtrip test
cargo test-roundtrip
# Run tests with all features
cargo test-everything
The full roundtrip test (tests/full_roundtrip.rs) creates two SIP clients that exchange audio through WAV files, providing end-to-end validation of the audio pipeline.
This project is licensed under either of:
at your option.