laravel-webrtc/config/webrtc.php

101 lines
4.6 KiB
PHP
Raw Normal View History

<?php
feat: full package — typed rooms (public/private/presence/open-presence) + call recording Rooms - Rooms\RoomType derived from the name prefix (like laravel-websockets channels): public, private-* (authorized), presence-* (authorized + member list), open-presence-* (public + member list). Room/RoomManager carry per-member info. - Contracts\RoomAuthorizer + secure DefaultRoomAuthorizer (denies private/presence until the host binds one). Presence rooms broadcast the member list + info. Recording (store the FULL call audio, in PHP, today) - Pure-P2P audio is DTLS-SRTP end-to-end, so the server can't capture it. Instead the browser MediaRecords its mic and streams chunks over the WS as BINARY frames (needs the new laravel-ws onBinary); RelaySignalingHandler appends them per participant via a RecordingStore. Recording\FileRecordingStore -> <room>/<peer>.webm. welcome/joined carry a record flag telling the client to stream. - Contracts\CallEventListener call-log seam (peer/room/recording lifecycle) so calls are auditable even when unrecorded. Wiring - RelaySignalingHandler(authorizer, recorder, events); webrtc:serve + provider + config/webrtc.php (recording enabled/path/format, authorizer, events). Tests 35/99 incl on-disk FileRecordingStore, presence member lists, auth gating, binary recording+finalize+events, RoomType, and the real WS round-trip. README documents room types + the browser MediaRecorder->WS recording flow. rel learn-atc #1060 #1055 #1057 #1051 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 07:01:12 +00:00
use Blax\WebRtc\Authorization\DefaultRoomAuthorizer;
use Blax\WebRtc\Events\NullCallEventListener;
use Blax\WebRtc\Media\NullMediaEngine;
return [
/*
|--------------------------------------------------------------------------
| Signaling bind
|--------------------------------------------------------------------------
| Where the signaling server (on the shared ReactPHP kernel) listens. For
| browser clients you will typically front this with the laravel-websockets
| WS transport instead; this raw endpoint drives + tests the media engine.
*/
'host' => env('WEBRTC_HOST', '127.0.0.1'),
'port' => (int) env('WEBRTC_PORT', 8090),
// ReactPHP TLS context; leave both unset for plain TCP.
'tls' => array_filter([
'local_cert' => env('WEBRTC_TLS_CERT'),
'local_pk' => env('WEBRTC_TLS_KEY'),
]),
/*
|--------------------------------------------------------------------------
| Media engine
|--------------------------------------------------------------------------
| The backend that terminates media (ICE/DTLS/SRTP/RTP/Opus), records, and
| bridges to external realtime providers. NullMediaEngine = signaling only;
| Str0mMediaEngine requires the blax_webrtc Rust extension (see rust/).
*/
'media_engine' => env('WEBRTC_MEDIA_ENGINE', NullMediaEngine::class),
/*
|--------------------------------------------------------------------------
feat: full package — typed rooms (public/private/presence/open-presence) + call recording Rooms - Rooms\RoomType derived from the name prefix (like laravel-websockets channels): public, private-* (authorized), presence-* (authorized + member list), open-presence-* (public + member list). Room/RoomManager carry per-member info. - Contracts\RoomAuthorizer + secure DefaultRoomAuthorizer (denies private/presence until the host binds one). Presence rooms broadcast the member list + info. Recording (store the FULL call audio, in PHP, today) - Pure-P2P audio is DTLS-SRTP end-to-end, so the server can't capture it. Instead the browser MediaRecords its mic and streams chunks over the WS as BINARY frames (needs the new laravel-ws onBinary); RelaySignalingHandler appends them per participant via a RecordingStore. Recording\FileRecordingStore -> <room>/<peer>.webm. welcome/joined carry a record flag telling the client to stream. - Contracts\CallEventListener call-log seam (peer/room/recording lifecycle) so calls are auditable even when unrecorded. Wiring - RelaySignalingHandler(authorizer, recorder, events); webrtc:serve + provider + config/webrtc.php (recording enabled/path/format, authorizer, events). Tests 35/99 incl on-disk FileRecordingStore, presence member lists, auth gating, binary recording+finalize+events, RoomType, and the real WS round-trip. README documents room types + the browser MediaRecorder->WS recording flow. rel learn-atc #1060 #1055 #1057 #1051 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 07:01:12 +00:00
| Recording (store the full call audio)
|--------------------------------------------------------------------------
feat: full package — typed rooms (public/private/presence/open-presence) + call recording Rooms - Rooms\RoomType derived from the name prefix (like laravel-websockets channels): public, private-* (authorized), presence-* (authorized + member list), open-presence-* (public + member list). Room/RoomManager carry per-member info. - Contracts\RoomAuthorizer + secure DefaultRoomAuthorizer (denies private/presence until the host binds one). Presence rooms broadcast the member list + info. Recording (store the FULL call audio, in PHP, today) - Pure-P2P audio is DTLS-SRTP end-to-end, so the server can't capture it. Instead the browser MediaRecords its mic and streams chunks over the WS as BINARY frames (needs the new laravel-ws onBinary); RelaySignalingHandler appends them per participant via a RecordingStore. Recording\FileRecordingStore -> <room>/<peer>.webm. welcome/joined carry a record flag telling the client to stream. - Contracts\CallEventListener call-log seam (peer/room/recording lifecycle) so calls are auditable even when unrecorded. Wiring - RelaySignalingHandler(authorizer, recorder, events); webrtc:serve + provider + config/webrtc.php (recording enabled/path/format, authorizer, events). Tests 35/99 incl on-disk FileRecordingStore, presence member lists, auth gating, binary recording+finalize+events, RoomType, and the real WS round-trip. README documents room types + the browser MediaRecorder->WS recording flow. rel learn-atc #1060 #1055 #1057 #1051 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 07:01:12 +00:00
| When enabled, the browser streams its mic to the server as binary WS frames
| and RelaySignalingHandler appends them per participant via a RecordingStore
| (FileRecordingStore by default: <path>/<room>/<peer>.<format>). See README.
*/
'recording' => [
feat: full package — typed rooms (public/private/presence/open-presence) + call recording Rooms - Rooms\RoomType derived from the name prefix (like laravel-websockets channels): public, private-* (authorized), presence-* (authorized + member list), open-presence-* (public + member list). Room/RoomManager carry per-member info. - Contracts\RoomAuthorizer + secure DefaultRoomAuthorizer (denies private/presence until the host binds one). Presence rooms broadcast the member list + info. Recording (store the FULL call audio, in PHP, today) - Pure-P2P audio is DTLS-SRTP end-to-end, so the server can't capture it. Instead the browser MediaRecords its mic and streams chunks over the WS as BINARY frames (needs the new laravel-ws onBinary); RelaySignalingHandler appends them per participant via a RecordingStore. Recording\FileRecordingStore -> <room>/<peer>.webm. welcome/joined carry a record flag telling the client to stream. - Contracts\CallEventListener call-log seam (peer/room/recording lifecycle) so calls are auditable even when unrecorded. Wiring - RelaySignalingHandler(authorizer, recorder, events); webrtc:serve + provider + config/webrtc.php (recording enabled/path/format, authorizer, events). Tests 35/99 incl on-disk FileRecordingStore, presence member lists, auth gating, binary recording+finalize+events, RoomType, and the real WS round-trip. README documents room types + the browser MediaRecorder->WS recording flow. rel learn-atc #1060 #1055 #1057 #1051 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 07:01:12 +00:00
'enabled' => (bool) env('WEBRTC_RECORDING', false),
'path' => env('WEBRTC_RECORDING_PATH', storage_path('app/webrtc')),
'format' => env('WEBRTC_RECORDING_FORMAT', 'webm'),
],
feat: full package — typed rooms (public/private/presence/open-presence) + call recording Rooms - Rooms\RoomType derived from the name prefix (like laravel-websockets channels): public, private-* (authorized), presence-* (authorized + member list), open-presence-* (public + member list). Room/RoomManager carry per-member info. - Contracts\RoomAuthorizer + secure DefaultRoomAuthorizer (denies private/presence until the host binds one). Presence rooms broadcast the member list + info. Recording (store the FULL call audio, in PHP, today) - Pure-P2P audio is DTLS-SRTP end-to-end, so the server can't capture it. Instead the browser MediaRecords its mic and streams chunks over the WS as BINARY frames (needs the new laravel-ws onBinary); RelaySignalingHandler appends them per participant via a RecordingStore. Recording\FileRecordingStore -> <room>/<peer>.webm. welcome/joined carry a record flag telling the client to stream. - Contracts\CallEventListener call-log seam (peer/room/recording lifecycle) so calls are auditable even when unrecorded. Wiring - RelaySignalingHandler(authorizer, recorder, events); webrtc:serve + provider + config/webrtc.php (recording enabled/path/format, authorizer, events). Tests 35/99 incl on-disk FileRecordingStore, presence member lists, auth gating, binary recording+finalize+events, RoomType, and the real WS round-trip. README documents room types + the browser MediaRecorder->WS recording flow. rel learn-atc #1060 #1055 #1057 #1051 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 07:01:12 +00:00
/*
|--------------------------------------------------------------------------
| Room authorization + call-event log
|--------------------------------------------------------------------------
| `authorizer` gates private-* / presence-* joins (bind your own that checks a
| token / the authenticated user; the default DENIES them). `events` receives
| call-lifecycle events so you can log the call (bind your own to persist).
*/
'authorizer' => env('WEBRTC_AUTHORIZER', DefaultRoomAuthorizer::class),
'events' => env('WEBRTC_EVENTS', NullCallEventListener::class),
/*
|--------------------------------------------------------------------------
| Room membership store
|--------------------------------------------------------------------------
| Where room membership + presence lives. The default ArrayRoomStore keeps it
| in process memory (right for the long-lived bundled server). A fork-per-
| message host (a classic Laravel WebSocket handling each frame in a fresh
| worker) binds a Cache/Redis-backed RoomStore so state survives across
| workers that is how a host runs this relay on its existing WS.
*/
'room_store' => env('WEBRTC_ROOM_STORE', \Blax\WebRtc\Rooms\Stores\ArrayRoomStore::class),
/*
|--------------------------------------------------------------------------
| ICE servers (STUN/TURN) advertised to browsers
|--------------------------------------------------------------------------
*/
'ice_servers' => [
// ['urls' => 'stun:stun.l.google.com:19302'],
// ['urls' => 'turn:turn.example.com:3478', 'username' => '...', 'credential' => '...'],
],
/*
|--------------------------------------------------------------------------
| External realtime bridge (provider hidden from the browser)
|--------------------------------------------------------------------------
| OpenAiRealtimeBridge (or the media engine) dials these; the browser only ever
| talks to us, so the AI provider is invisible and the model is swappable
| server-side. `instructions` is the persona (the host injects its own e.g.
| an ATC prompt) and `voice` the spoken voice.
*/
'bridge' => [
'openai' => [
'endpoint' => env('WEBRTC_OPENAI_ENDPOINT', 'wss://api.openai.com/v1/realtime'),
'model' => env('WEBRTC_OPENAI_MODEL', 'gpt-realtime'),
'api_key' => env('OPENAI_API_KEY'),
'voice' => env('WEBRTC_OPENAI_VOICE', 'alloy'),
'instructions' => null,
],
],
];