SFU M0: browser lab E2E client for Janus VideoRoom.

Add lab page with screen-share publisher and subscriber viewer, join API
feed support, shared session auth, static assets route, and lab docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-08-07 22:15:42 +02:00
parent 61248e6c8b
commit 0c5c079179
7 changed files with 374 additions and 14 deletions

View File

@@ -21,9 +21,11 @@ $janusRoomId = (int) ($input['room_id'] ?? 0);
$jsep = $input['jsep'] ?? null;
$role = in_array($input['role'] ?? '', ['publisher', 'subscriber'], true)
? $input['role'] : 'publisher';
$feedId = (int) ($input['feed_id'] ?? 0);
if (!$janusRoomId) { sfuJsonErr('room_id required'); }
if (!$jsep || empty($jsep['sdp'])) { sfuJsonErr('jsep.sdp required'); }
if ($role === 'subscriber' && $feedId <= 0) { sfuJsonErr('feed_id required for subscriber'); }
$repo = new \AndroidCast\Sfu\SfuRoomRepository(sfuPdo());
$janus = janusClient();
@@ -44,6 +46,9 @@ $joinBody = [
'ptype' => $role === 'publisher' ? 'publisher' : 'subscriber',
'display' => $user['email'] ?? 'anon',
];
if ($role === 'subscriber') {
$joinBody['streams'] = [['feed' => $feedId]];
}
$resp = $janus->sendJsep($sid, $hid, $joinBody, [
'type' => $jsep['type'],
'sdp' => $jsep['sdp'],
@@ -59,10 +64,13 @@ $participantId = $repo->joinRoom(
/* Return negotiated JSEP answer + WS connection details */
$answer = $resp['jsep'] ?? null;
$plugin = $resp['plugindata']['data'] ?? [];
$publisherId = isset($plugin['id']) ? (int) $plugin['id'] : null;
sfuJsonOk([
'session_id' => $sid,
'handle_id' => $hid,
'participant_id' => $participantId,
'publisher_id' => $publisherId,
'jsep' => $answer,
'ws_url' => '/app/androidcast_project/sfu/ws',
]);