# Changelog

All notable changes to `blax-software/laravel-webrtc` are documented here. This
project adheres to [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
Blax Software's backward-compatibility guarantee.

## [Unreleased]

### Added

- **Backend-hosted rooms — the Rust SFU sidecar** (`rust/`, binary
  `blax-webrtc-sfu`): str0m terminates ICE/DTLS/SRTP server-side and forwards
  Opus between room peers without decoding; per-peer **Ogg/Opus recording**
  written from the decrypted stream; server-side **mute/kick**, `stats`
  (connected/muted/usage seconds) and pushed `peer_connected`/`peer_left`
  events. Driven over a JSON-lines Unix control socket. Renegotiation rides
  each browser's data channel (str0m `chat` model) — signaling only carries the
  initial offer/answer.
- **`Media\RustMediaEngine`** — implements `MediaEngine` (composite
  `room/peer` ids) plus the room-aware API (`addPeer`/`removePeer`/`mutePeer`/
  `stats`/`drainEvents`). **Plug-and-play**: first use auto-downloads the
  sha256-verified prebuilt static binary (`Rust\BinaryManager`, RoadRunner
  pattern) and spawns it detached + flock-guarded (`Rust\SidecarSupervisor`).
- Commands `webrtc:install` (pre-fetch the binary) and `webrtc:sidecar`
  (foreground runner for docker/supervisord; disable `auto_spawn` there).
- `config/webrtc.php` gained the `sfu` block (socket, udp/public ip+port,
  auto_install/auto_spawn, download/checksum URLs, versioned install path).
- `rust/build-release.sh` builds the static-musl release binary + `.sha256`.
- Tests: 61 PHP (control protocol framing, event buffering, checksum
  install/mismatch, supervisor args + a REAL PHP↔Rust E2E that spawns the
  sidecar from PHPUnit) and 7 Rust (proto round-trips, Ogg/Opus writer
  [ffprobe-verified], end-to-end control-socket integration).

### Removed

- `Media\Str0mMediaEngine` (the ext-php-rs extension seam) — replaced by
  `RustMediaEngine` + the sidecar: no PHP-version-bound extension, no crash
  sharing a process with PHP, works with the prebuilt-base-image deploy model.

- **Typed rooms** (`Rooms\RoomType`, derived from the room name prefix like
  laravel-websockets channels): `public`, `private-*` (authorized),
  `presence-*` (authorized + member list), `open-presence-*` (public + member
  list). `Contracts\RoomAuthorizer` (+ secure `DefaultRoomAuthorizer` that denies
  private/presence) gates the join; presence rooms broadcast the member list +
  per-member `info`.
- **Full call recording**: `Contracts\RecordingStore` + `Recording\FileRecordingStore`.
  The browser streams its mic to the server as binary WS frames; the relay appends
  them per participant (`<room>/<peer>.webm`) and finalizes on leave/disconnect.
  `welcome`/`joined` carry a `record` flag telling the client to stream.
- **Call-event log seam**: `Contracts\CallEventListener` (+ `NullCallEventListener`)
  receives peer-connected / room-joined / room-left / recording-finalized /
  peer-disconnected events, so calls can be logged/audited even when not recorded.
- `RelaySignalingHandler` now takes an authorizer, recorder and event listener;
  `webrtc:serve` wires them from `config/webrtc.php` (`recording`, `authorizer`,
  `events`).
- Suite grew to 35 / 99 assertions (room types, auth, presence, recording via the
  in-memory + on-disk stores, events).

### Added (earlier)

- **Working browser-to-browser (P2P) MVP.** `Signaling\RelaySignalingHandler` (a
  `blax-software/laravel-ws` `MessageHandler`) relays SDP/ICE between browsers so
  they connect peer-to-peer — no server-side media engine required. Protocol:
  `welcome` on connect, `join` → `joined` + `peer-joined`, targeted `relay`, room
  `broadcast`, `leave`/disconnect → `peer-left`. Peers tracked in the kernel
  `ConnectionRegistry`, membership in `RoomManager`.
- `webrtc:serve` now runs this relay over a `laravel-ws` WebSocketServer, so it is
  browser-usable out of the box (`ws://host:port`).
- `require blax-software/laravel-ws`.
- Tests grew to 26 / 60 assertions, including a real WebSocket `welcome`
  round-trip (browser → laravel-ws → relay).

### Added (earlier)

- `WebRtcServiceProvider` + `config/webrtc.php` + the `webrtc:serve` command
  (boots signaling on the shared `blax-software/reactphp-kernel`).
- `Contracts\MediaEngine` — the pluggable media backend
  (`offer`/`addIceCandidate`/`startRecording`/`stopRecording`/`connectPeers`/`bridge`/`close`).
- `Media\NullMediaEngine` — signaling-only engine for dev/tests.
- `Media\Str0mMediaEngine` — seam for the Rust media core (str0m via ext-php-rs);
  throws until the `blax_webrtc` extension is built (see `rust/`).
- `Signaling\SignalingHandler` — transport-agnostic router from a signaling
  message to the media engine.
- `Server\SignalingServer` — a minimal kernel-attached (newline-JSON) signaling
  transport; browsers ride the `laravel-websockets` WS transport into the same
  handler.
- `rust/` — the `blax_webrtc` crate scaffold (str0m + ext-php-rs) documenting the
  media plan.
- `Rooms\Room` + `Rooms\RoomManager` and `join`/`leave` signaling for
  party-to-party / group calls: a new joiner is auto-meshed with everyone already
  in the room; `close` also leaves. Empty rooms are dropped.
- `SignalingServer::address()` — the bound listen address (for integration).
- A real socket round-trip test (offer→answer over a live TCP connection on the
  kernel loop), plus RoomManager + join/leave coverage. Suite: 17 tests / 42
  assertions.
