pjsipua-win 0.1.4

Rust library PJSUA2
// src/ffi.rs - Enhanced FFI bindings
use libc::{c_char, c_int};

// FFI function declarations
extern "C" {
    // Endpoint management
    pub fn pjsua2_create_endpoint() -> c_int;
    pub fn pjsua2_init_endpoint(log_level: c_int) -> c_int;
    pub fn pjsua2_create_transport(port: c_int) -> c_int;
    pub fn pjsua2_start() -> c_int;
    pub fn pjsua2_destroy();

    // Account management
    pub fn pjsua2_create_account(
        id_uri: *const c_char,
        registrar_uri: *const c_char,
        username: *const c_char,
        password: *const c_char,
        on_reg_state: Option<extern "C" fn(is_registered: c_int)>,
        on_incoming_call: Option<extern "C" fn(call_id: c_int, remote_uri: *const c_char)>,
    ) -> c_int;

    pub fn pjsua2_create_account_simple(
        id_uri: *const c_char,
        registrar_uri: *const c_char,
        username: *const c_char,
        password: *const c_char,
    ) -> c_int;

    // Call management
    pub fn pjsua2_make_call(
        acc_id: c_int,
        dst_uri: *const c_char,
    ) -> c_int;

    pub fn pjsua2_answer_call(call_id: c_int, code: c_int) -> c_int;
    pub fn pjsua2_hangup_call(call_id: c_int) -> c_int;

    // Audio device management
    pub fn pjsua2_get_audio_device_count() -> c_int;
    pub fn pjsua2_get_audio_device_info(
        index: c_int,
        name: *mut c_char,
        name_size: c_int,
        is_capture: *mut c_int,
        is_playback: *mut c_int,
    ) -> c_int;
    pub fn pjsua2_set_audio_devices(capture_dev: c_int, playback_dev: c_int) -> c_int;

    // Callbacks
    pub fn pjsua2_set_callbacks(
        on_reg_state: Option<extern "C" fn(acc_id: c_int, is_registered: c_int)>,
        on_incoming_call: Option<extern "C" fn(acc_id: c_int, call_id: c_int, remote_uri: *const c_char)>,
        on_call_state: Option<extern "C" fn(call_id: c_int, state: c_int)>,
        on_call_media_state: Option<extern "C" fn(call_id: c_int, state: c_int)>,
    );

    // Test functions
    pub fn pjsua2_test_basic() -> c_int;
    pub fn pjsua2_test_object_creation() -> c_int;
    pub fn pjsua2_test_account_config() -> c_int;
    pub fn pjsua2_test_create_account() -> c_int;
    pub fn pjsua2_test_endpoint_state() -> c_int;
}

// Call state constants
pub const PJSIP_INV_STATE_NULL: c_int = 0;
pub const PJSIP_INV_STATE_CALLING: c_int = 1;
pub const PJSIP_INV_STATE_INCOMING: c_int = 2;
pub const PJSIP_INV_STATE_EARLY: c_int = 3;
pub const PJSIP_INV_STATE_CONNECTING: c_int = 4;
pub const PJSIP_INV_STATE_CONFIRMED: c_int = 5;
pub const PJSIP_INV_STATE_DISCONNECTED: c_int = 6;

// PJSUA states
pub const PJSUA_STATE_NULL: c_int = 0;
pub const PJSUA_STATE_CREATED: c_int = 1;
pub const PJSUA_STATE_INIT: c_int = 2;
pub const PJSUA_STATE_STARTING: c_int = 3;
pub const PJSUA_STATE_RUNNING: c_int = 4;
pub const PJSUA_STATE_CLOSING: c_int = 5;

// SIP response codes
pub const PJSIP_SC_TRYING: c_int = 100;
pub const PJSIP_SC_RINGING: c_int = 180;
pub const PJSIP_SC_OK: c_int = 200;
pub const PJSIP_SC_BUSY_HERE: c_int = 486;
pub const PJSIP_SC_DECLINE: c_int = 603;