# blax_webrtc — Rust media core The timing-critical WebRTC media path for `blax-software/laravel-webrtc`, so that PHP never runs per-20ms real-time DSP. ## Why Rust here Handling **connections** concurrently in PHP is a solved problem (Swoole, FrankenPHP, ReactPHP). What is *not* proven is sustained per-packet media DSP (decrypt SRTP + Opus + RTP jitter every 20ms) glitch-free in single-threaded PHP. That work belongs in a language built for it. `str0m` is **sans-IO** (no threads or async of its own — you feed it bytes), which makes it ideal to embed and drive from PHP. - `str0m` owns ICE / DTLS / SRTP / RTP / Opus. - `ext-php-rs` exposes a thin function surface to PHP. - PHP (`Str0mMediaEngine`) forwards SDP/ICE/control across the FFI boundary and calls back into Laravel for persistence (recordings, transmission rows). ## Build ```bash # one-time: cargo + the ext-php-rs helper cargo install cargo-php cd rust cargo php install --release # compiles the cdylib, installs it as the `blax_webrtc` extension php -m | grep blax_webrtc # verify it loaded ``` Then set `WEBRTC_MEDIA_ENGINE=BlaxSoftware\LaravelWebRtc\Media\Str0mMediaEngine`. ## Status Scaffold. `src/lib.rs` documents the intended FFI functions (`blax_webrtc_offer`, `..._add_ice_candidate`, `..._start_recording`, `..._connect_peers`, `..._bridge`, `..._close`) that `Str0mMediaEngine` forwards to. Implement them against `str0m`'s RTP/Frame API, then flip the PHP engine off `NullMediaEngine`.