//! Rust-side integration test: two PeerConnections exchange SDP/ICE and
//! send messages over a DataChannel.
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void};
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};
use std::sync::Arc;
use std::time::Duration;
// Use the crate's C API functions directly (rlib link)
use datachannel::*;
// Re-declare the #[repr(C)] types for test use (must match types.rs layout)
#[repr(C)]
struct TestConfiguration {
ice_servers: *const *const c_char,
ice_servers_count: c_int,
proxy_server: *const c_char,
bind_address: *const c_char,
certificate_type: c_int,
ice_transport_policy: c_int,
enable_ice_tcp: bool,
enable_ice_udp_mux: bool,
disable_auto_negotiation: bool,
force_media_transport: bool,
port_range_begin: u16,
port_range_end: u16,
mtu: c_int,
max_message_size: c_int,
}
#[repr(C)]
struct TestReliability {
unordered: bool,
unreliable: bool,
max_packet_life_time: u32,
max_retransmits: u32,
}
#[repr(C)]
struct TestDataChannelInit {
reliability: TestReliability,
protocol: *const c_char,
negotiated: bool,
manual_stream: bool,
stream: u16,
}
impl Default for TestConfiguration {
fn default() -> Self {
Self {
ice_servers: std::ptr::null(),
ice_servers_count: 0,
proxy_server: std::ptr::null(),
bind_address: std::ptr::null(),
certificate_type: 0,
ice_transport_policy: 0,
enable_ice_tcp: false,
enable_ice_udp_mux: false,
disable_auto_negotiation: false,
force_media_transport: false,
port_range_begin: 0,
port_range_end: 0,
mtu: 0,
max_message_size: 0,
}
}
}
// ---------------------------------------------------------------------------
// Shared test state
// ---------------------------------------------------------------------------
struct TestState {
sdp: parking_lot::Mutex