backend: Refactor recording schema and remove outputMode references

This commit is contained in:
Carlos Santos 2025-03-28 11:46:26 +01:00
parent 195b56a4b4
commit 578a3fec50
3 changed files with 86 additions and 87 deletions

View File

@ -428,7 +428,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/MeetRecording' $ref: '#/components/schemas/MeetRecordingStart'
'401': '401':
description: Unauthorized — The API key is missing or invalid description: Unauthorized — The API key is missing or invalid
content: content:
@ -558,7 +558,7 @@ paths:
recordings: recordings:
type: array type: array
items: items:
$ref: '#/components/schemas/MeetRecording' $ref: '#/components/schemas/MeetRecording'
pagination: pagination:
type: object type: object
properties: properties:
@ -1210,79 +1210,76 @@ components:
description: > description: >
The URL for the viewer to join the room. The viewer has read-only permissions to watch the room The URL for the viewer to join the room. The viewer has read-only permissions to watch the room
and participants. and participants.
MeetRecordingBase:
type: object
properties:
recordingId:
type: string
example: 'room-123--EG_XYZ--XX445'
description: The unique identifier of the recording.
roomId:
type: string
example: 'room-123'
description: The ID of the room where the recording was made.
# outputMode:
# type: string
# example: 'COMPOSED'
# description: >
# The output mode of the recording. Possible value: "COMPOSED".
status:
type: string
example: 'ACTIVE'
description: >
The status of the recording.
Possible values:
- STARTING
- ACTIVE
- ENDING
- COMPLETE
- FAILED
- ABORTED
- LIMITED_REACHED
filename:
type: string
example: 'room-123--XX445.mp4'
description: The name of the recording file.
startDate:
type: number
example: 1620000000000
description: The date when the recording was started (milliseconds since the Unix epoch).
MeetRecording: MeetRecording:
type: object allOf:
properties: - $ref: '#/components/schemas/MeetRecordingBase'
recordingId: - type: object
type: string properties:
example: 'room-123--EG_XYZ--XX445'
description: >
The unique identifier of the recording.
roomId:
type: string
example: 'room-123'
description: >
The ID of the room where the recording was made.
outputMode:
type: string
example: 'COMPOSED'
description: >
The output mode of the recording. Possible values are "COMPOSED".
status:
type: string
example: 'ACTIVE'
description: >
The status of the recording.
Possible values:
- `STARTING`
- `ACTIVE`
- `ENDING`
- `COMPLETE`
- `FAILED`
- `ABORTED`
- `LIMITED_REACHED`
filename:
type: string
example: 'room-123--XX445.mp4'
description: >
The name of the recording file.
startDate:
type: number
example: 1620000000000
description: >
The date when the recording was started in milliseconds since the Unix epoch.
endDate: endDate:
type: number type: number
example: 1620000000000 example: 1620000000000
description: > description: The date when the recording was stopped (milliseconds since the Unix epoch).
The date when the recording was stopped in milliseconds since the Unix epoch.
duration: duration:
type: number type: number
example: 3600 example: 3600
description: > description: The duration of the recording in seconds.
The duration of the recording in seconds.
size: size:
type: number type: number
example: 1024 example: 1024
description: > description: The size of the recording file in bytes.
The size of the recording file in bytes.
errorCode: errorCode:
type: number type: number
example: 100 example: 100
description: > description: The error code of the recording.
The error code of the recording.
error: error:
type: string type: string
example: 'error' description: The error message of the recording.
description: > nullable: true
The error message of the recording.
details: details:
type: string type: string
example: 'Stopped using API' example: 'Stopped using API'
description: > description: Additional details about the recording.
Additional details about the recording.
MeetRecordingStart:
$ref: '#/components/schemas/MeetRecordingBase'
Error: Error:
type: object type: object
required: required:

View File

@ -47,7 +47,7 @@ export class OpenViduComponentsAdapterHelper {
id: info.recordingId, id: info.recordingId,
roomName: info.details ?? '', roomName: info.details ?? '',
roomId: info.roomId, roomId: info.roomId,
outputMode: info.outputMode, // outputMode: info.outputMode,
status: this.mapRecordingStatus(info.status), status: this.mapRecordingStatus(info.status),
filename: info.filename, filename: info.filename,
startedAt: info.startDate, startedAt: info.startDate,

View File

@ -1,5 +1,5 @@
import { EgressInfo } from 'livekit-server-sdk'; import { EgressInfo } from 'livekit-server-sdk';
import { MeetRecordingInfo, MeetRecordingOutputMode, MeetRecordingStatus } from '@typings-ce'; import { MeetRecordingInfo, MeetRecordingStatus } from '@typings-ce';
import { EgressStatus } from '@livekit/protocol'; import { EgressStatus } from '@livekit/protocol';
export class RecordingHelper { export class RecordingHelper {
@ -10,7 +10,7 @@ export class RecordingHelper {
static toRecordingInfo(egressInfo: EgressInfo): MeetRecordingInfo { static toRecordingInfo(egressInfo: EgressInfo): MeetRecordingInfo {
const status = RecordingHelper.extractOpenViduStatus(egressInfo.status); const status = RecordingHelper.extractOpenViduStatus(egressInfo.status);
const size = RecordingHelper.extractSize(egressInfo); const size = RecordingHelper.extractSize(egressInfo);
const outputMode = RecordingHelper.extractOutputMode(egressInfo); // const outputMode = RecordingHelper.extractOutputMode(egressInfo);
const duration = RecordingHelper.extractDuration(egressInfo); const duration = RecordingHelper.extractDuration(egressInfo);
const startDateMs = RecordingHelper.extractStartDate(egressInfo); const startDateMs = RecordingHelper.extractStartDate(egressInfo);
const endDateMs = RecordingHelper.extractEndDate(egressInfo); const endDateMs = RecordingHelper.extractEndDate(egressInfo);
@ -20,16 +20,16 @@ export class RecordingHelper {
return { return {
recordingId: `${roomName}--${egressId}--${uid}`, recordingId: `${roomName}--${egressId}--${uid}`,
roomId: roomName, roomId: roomName,
outputMode, // outputMode,
status, status,
filename, filename,
startDate: startDateMs, startDate: startDateMs,
endDate: endDateMs, endDate: endDateMs,
duration, duration,
size, size,
errorCode, errorCode: errorCode ? Number(errorCode) : undefined,
error, error: error ? String(error) : undefined,
details: details details: details ? String(details) : undefined,
}; };
} }
@ -72,14 +72,14 @@ export class RecordingHelper {
* @param egressInfo - The egress information containing the roomComposite flag. * @param egressInfo - The egress information containing the roomComposite flag.
* @returns The extracted OpenVidu output mode. * @returns The extracted OpenVidu output mode.
*/ */
static extractOutputMode(egressInfo: EgressInfo): MeetRecordingOutputMode { // static extractOutputMode(egressInfo: EgressInfo): MeetRecordingOutputMode {
// if (egressInfo.request.case === 'roomComposite') { // // if (egressInfo.request.case === 'roomComposite') {
// return MeetRecordingOutputMode.COMPOSED; // // return MeetRecordingOutputMode.COMPOSED;
// } else { // // } else {
// return MeetRecordingOutputMode.INDIVIDUAL; // // return MeetRecordingOutputMode.INDIVIDUAL;
// } // // }
return MeetRecordingOutputMode.COMPOSED; // return MeetRecordingOutputMode.COMPOSED;
} // }
/** /**
* Extracts the filename/path for storing the recording. * Extracts the filename/path for storing the recording.
@ -133,8 +133,9 @@ export class RecordingHelper {
* @param egressInfo The egress information containing the file results. * @param egressInfo The egress information containing the file results.
* @returns The duration in milliseconds. * @returns The duration in milliseconds.
*/ */
static extractDuration(egressInfo: EgressInfo): number { static extractDuration(egressInfo: EgressInfo): number | undefined {
return this.toSeconds(Number(egressInfo.fileResults?.[0]?.duration ?? 0)); const duration = this.toSeconds(Number(egressInfo.fileResults?.[0]?.duration ?? 0));
return duration !== 0 ? duration : undefined;
} }
/** /**
@ -168,8 +169,9 @@ export class RecordingHelper {
* @param egressInfo - The EgressInfo object to extract the size from. * @param egressInfo - The EgressInfo object to extract the size from.
* @returns The size extracted from the EgressInfo object, or 0 if not available. * @returns The size extracted from the EgressInfo object, or 0 if not available.
*/ */
static extractSize(egressInfo: EgressInfo): number { static extractSize(egressInfo: EgressInfo): number | undefined {
return Number(egressInfo.fileResults?.[0]?.size ?? 0); const size = Number(egressInfo.fileResults?.[0]?.size ?? 0);
return size !== 0 ? size : undefined;
} }
private static toSeconds(nanoseconds: number): number { private static toSeconds(nanoseconds: number): number {