pjsipua-win 0.1.26

Rust library PJSUA2
docs.rs failed to build pjsipua-win-0.1.26
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

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_ROOT set to your PJSIP installation (default: C:\pjsip)

Setup Instructions

  1. Create a new directory for the project:

    mkdir pjsua2-test
    
    cd pjsua2-test
    
    
  2. 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
    
  3. Copy all the artifact files to their respective locations

  4. Ensure PJSIP is properly installed:

    • PJSIP should be built with /MD flag
    • Libraries should be in %PJSIP_ROOT%/pjproject/lib/

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:

  1. Basic tests - Always run:

    cargo test
    
    
  2. Integration tests - Run serially:

    cargo test --test integration_tests
    
    
  3. Account creation tests - Marked as ignored, run explicitly:

    cargo test -- --ignored
    
    

Debugging

If account creation fails:

  1. Check the build output:

    cargo build --release -vv
    
    
  2. Run diagnostics:

    let results = pjsua2_test::run_diagnostics();
    println!("{:?}", results);
    
  3. Check PJSIP build:

    • Ensure PJSIP was built with /MD (not /MT)
    • Verify all dependencies are present
  4. Enable verbose logging:

    let endpoint = Pjsua2Endpoint::init(5)?; // Max log level
    

Troubleshooting

Access Violation (0xC0000005)

This usually indicates:

  • Runtime library mismatch (check /MD vs /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