Fix auto-record egress failing before LiveKit room exists.
Deploy Ladill Meet / deploy (push) Successful in 51s
Deploy Ladill Meet / deploy (push) Successful in 51s
Create rooms via the LiveKit API, retry egress when the room is missing, and resume server egress after the host connects when auto-record fell back to browser capture. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -26,14 +26,7 @@ class LiveKitEgressService
|
||||
|
||||
public function apiHost(): string
|
||||
{
|
||||
$override = (string) config('meet.media.livekit.api_url', '');
|
||||
if ($override !== '') {
|
||||
return rtrim($override, '/');
|
||||
}
|
||||
|
||||
$url = (string) config('meet.media.livekit.url', '');
|
||||
|
||||
return (string) preg_replace('#^wss:#', 'https:', (string) preg_replace('#^ws:#', 'http:', $url));
|
||||
return app(LiveKitProvider::class)->apiHost();
|
||||
}
|
||||
|
||||
public function startRoomRecording(Session $session, Recording $recording, bool $audioOnly = false): EgressInfo
|
||||
@@ -54,6 +47,33 @@ class LiveKitEgressService
|
||||
);
|
||||
}
|
||||
|
||||
protected function startRoomRecordingWithRetry(Session $session, Recording $recording, bool $audioOnly): EgressInfo
|
||||
{
|
||||
$attempts = max(1, (int) config('meet.recordings.egress.start_attempts', 5));
|
||||
$lastError = null;
|
||||
|
||||
for ($attempt = 1; $attempt <= $attempts; $attempt++) {
|
||||
try {
|
||||
return $this->startRoomRecording($session, $recording, $audioOnly);
|
||||
} catch (\Throwable $e) {
|
||||
$lastError = $e;
|
||||
if (! $this->isMissingRoomError($e) || $attempt === $attempts) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
app(LiveKitProvider::class)->createRoom($session->media_room_name);
|
||||
usleep(500_000);
|
||||
}
|
||||
}
|
||||
|
||||
throw $lastError ?? new RuntimeException('LiveKit egress could not start.');
|
||||
}
|
||||
|
||||
protected function isMissingRoomError(\Throwable $e): bool
|
||||
{
|
||||
return str_contains(strtolower($e->getMessage()), 'room does not exist');
|
||||
}
|
||||
|
||||
public function stopEgress(string $egressId): EgressInfo
|
||||
{
|
||||
return $this->client()->stopEgress($egressId);
|
||||
@@ -146,7 +166,7 @@ class LiveKitEgressService
|
||||
|
||||
try {
|
||||
$audioOnly = $session->room->isAudioOnly();
|
||||
$info = $this->startRoomRecording($session, $recording, $audioOnly);
|
||||
$info = $this->startRoomRecordingWithRetry($session, $recording, $audioOnly);
|
||||
$egressId = $info->getEgressId();
|
||||
|
||||
if ($egressId === '') {
|
||||
|
||||
Reference in New Issue
Block a user