backend: Updated recording status when a starting timeout occurs
This commit is contained in:
parent
b7b9f9b1c0
commit
9d42242ba0
@ -1,6 +1,7 @@
|
||||
import { EgressInfo } from 'livekit-server-sdk';
|
||||
import { MeetRecordingInfo, MeetRecordingStatus } from '@typings-ce';
|
||||
import { EgressStatus } from '@livekit/protocol';
|
||||
import INTERNAL_CONFIG from '../config/internal-config.js';
|
||||
|
||||
export class RecordingHelper {
|
||||
private constructor() {
|
||||
@ -29,7 +30,7 @@ export class RecordingHelper {
|
||||
size,
|
||||
errorCode: errorCode ? Number(errorCode) : undefined,
|
||||
error: error ? String(error) : undefined,
|
||||
details: details ? String(details) : undefined,
|
||||
details: details ? String(details) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
@ -174,6 +175,12 @@ export class RecordingHelper {
|
||||
return size !== 0 ? size : undefined;
|
||||
}
|
||||
|
||||
static buildMetadataFilePath(recordingId: string): string {
|
||||
const { roomId, egressId, uid } = RecordingHelper.extractInfoFromRecordingId(recordingId);
|
||||
|
||||
return `${INTERNAL_CONFIG.S3_RECORDINGS_PREFIX}/.metadata/${roomId}/${egressId}/${uid}.json`;
|
||||
}
|
||||
|
||||
private static toSeconds(nanoseconds: number): number {
|
||||
const nanosecondsToSeconds = 1 / 1_000_000_000;
|
||||
return nanoseconds * nanosecondsToSeconds;
|
||||
|
||||
@ -184,7 +184,7 @@ export class LivekitWebhookService {
|
||||
|
||||
const recordingInfo: MeetRecordingInfo = RecordingHelper.toRecordingInfo(egressInfo);
|
||||
const { roomId, recordingId, status } = recordingInfo;
|
||||
const metadataPath = this.buildMetadataFilePath(recordingId);
|
||||
const metadataPath = RecordingHelper.buildMetadataFilePath(recordingId);
|
||||
|
||||
this.logger.debug(`Recording '${recordingId}' status: '${status}'`);
|
||||
|
||||
@ -267,10 +267,4 @@ export class LivekitWebhookService {
|
||||
this.logger.error(`Error saving room secrets for room ${roomId}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
protected buildMetadataFilePath(recordingId: string): string {
|
||||
const { roomId, egressId, uid } = RecordingHelper.extractInfoFromRecordingId(recordingId);
|
||||
|
||||
return `${INTERNAL_CONFIG.S3_RECORDINGS_PREFIX}/.metadata/${roomId}/${egressId}/${uid}.json`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,6 +498,7 @@ export class RecordingService {
|
||||
let shouldReleaseLock = false;
|
||||
|
||||
try {
|
||||
await this.updateRecordingStatus(recordingId, MeetRecordingStatus.FAILED);
|
||||
await this.stopRecording(recordingId);
|
||||
// The recording was stopped successfully
|
||||
// the cleanup timer will be cancelled when the egress_ended event is received.
|
||||
@ -598,6 +599,13 @@ export class RecordingService {
|
||||
}
|
||||
}
|
||||
|
||||
protected async updateRecordingStatus(recordingId: string, status: MeetRecordingStatus): Promise<void> {
|
||||
const metadataPath = RecordingHelper.buildMetadataFilePath(recordingId);
|
||||
const recordingInfo = await this.getRecording(recordingId);
|
||||
recordingInfo.status = status;
|
||||
await this.s3Service.saveObject(metadataPath, recordingInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up orphaned recording locks in the system.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user