Files
ac-ms-sfu-signaling/public/api/stats.php
Anton Afanasyeu 0658e26ae4 sfu-signaling: real Janus signaling service implementation
- JanusClient.php: HTTP REST client for Janus Gateway API
- SfuRoomRepository.php: room + participant + stats persistence
- bootstrap.php: PDO, auth, Janus client factory
- public/index.php: front-controller routing
- public/health.php: Janus online check
- public/api/rooms.php: list/create/destroy rooms
- public/api/join.php: SDP offer relay → Janus VideoRoom
- public/api/stats.php: bitrate/packet-loss analytics ingest
- public/dashboard.php: SFU rooms UI (common BE dark-theme styles)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 22:27:59 +02:00

26 lines
777 B
PHP

<?php
declare(strict_types=1);
/**
* SFU stats ingest — POST /api/stats
* Body: { participant_id, bitrate_kbps, packet_loss }
* Called periodically by Android client (every 5s) to feed analytics.
*/
require_once dirname(__DIR__, 2) . '/src/bootstrap.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
sfuJsonErr('method not allowed', 405);
}
sfuRequireAuth();
$input = json_decode(file_get_contents('php://input'), true) ?? [];
$pid = (int) ($input['participant_id'] ?? 0);
$bw = (float) ($input['bitrate_kbps'] ?? 0.0);
$pl = (float) ($input['packet_loss'] ?? 0.0);
if ($pid <= 0) { sfuJsonErr('participant_id required'); }
$repo = new \AndroidCast\Sfu\SfuRoomRepository(sfuPdo());
$repo->recordStats($pid, $bw, $pl);
sfuJsonOk(['recorded' => true]);