15 releases
| 0.1.15 | Jul 19, 2025 |
|---|---|
| 0.1.14 | Jul 18, 2025 |
#328 in Audio
509 downloads per month
315KB
2.5K
SLoC
PJSUA2 Test Library
A Rust library for testing PJSUA2 account creation functionality. This library provides a minimal wrapper around PJSUA2 to help diagnose and test account creation issues.
Prerequisites
- Windows with Visual Studio 2019 or 2022
- PJSIP/PJSUA2 built with
/MD(dynamic runtime) - Environment variable
PJSIP_ROOTset to your PJSIP installation (default:C:\pjsip)
Setup Instructions
-
Create a new directory for the project:
mkdir pjsua2-test cd pjsua2-test -
Create the project structure:
pjsua2-test/ ├── Cargo.toml ├── build.rs ├── README.md ├── src/ │ ├── lib.rs │ ├── ffi.rs │ ├── pjsua2_wrapper.cpp │ └── pjsua2_wrapper.h ├── tests/ │ └── integration_tests.rs └── examples/ └── basic_usage.rs -
Copy all the artifact files to their respective locations
-
Ensure PJSIP is properly installed:
- PJSIP should be built with
/MDflag - Libraries should be in
%PJSIP_ROOT%/pjproject/lib/
- PJSIP should be built with
Building the Library
# Build the library
cargo build --release
# Run tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run ignored tests (includes account creation)
cargo test -- --ignored --nocapture
# Run example
cargo run --example basic_usage
Usage
use pjsua2_test::*;
// Initialize PJSUA2
let endpoint = Pjsua2Endpoint::init(4)?;
// Create an account
let config = AccountConfig::new("username", "domain.com", "password");
let account_id = endpoint.create_account(&config)?;
println!("Account created with ID: {}", account_id);
Running Tests
The library includes several test levels:
-
Basic tests - Always run:
cargo test -
Integration tests - Run serially:
cargo test --test integration_tests -
Account creation tests - Marked as ignored, run explicitly:
cargo test -- --ignored
Debugging
If account creation fails:
-
Check the build output:
cargo build --release -vv -
Run diagnostics:
let results = pjsua2_test::run_diagnostics(); println!("{:?}", results); -
Check PJSIP build:
- Ensure PJSIP was built with
/MD(not/MT) - Verify all dependencies are present
- Ensure PJSIP was built with
-
Enable verbose logging:
let endpoint = Pjsua2Endpoint::init(5)?; // Max log level
Troubleshooting
Access Violation (0xC0000005)
This usually indicates:
- Runtime library mismatch (check
/MDvs/MT) - ABI incompatibility
- Corrupted virtual function table
Missing DLLs
Ensure Visual C++ redistributables are installed.
Account Creation Fails
Try the simple account creation function first:
// Uses pjsua2_create_account_simple internally
let account_id = endpoint.create_account(&config)?;
License
MIT
Dependencies
~0.3–1.2MB
~25K SLoC