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:
application/json:
schema:
$ref: '#/components/schemas/MeetRecording'
$ref: '#/components/schemas/MeetRecordingStart'
'401':
description: Unauthorized — The API key is missing or invalid
content:
@ -558,7 +558,7 @@ paths:
recordings:
type: array
items:
$ref: '#/components/schemas/MeetRecording'
$ref: '#/components/schemas/MeetRecording'
pagination:
type: object
properties:
@ -1210,79 +1210,76 @@ components:
description: >
The URL for the viewer to join the room. The viewer has read-only permissions to watch the room
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:
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 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.
allOf:
- $ref: '#/components/schemas/MeetRecordingBase'
- type: object
properties:
endDate:
type: number
example: 1620000000000
description: >
The date when the recording was stopped in milliseconds since the Unix epoch.
type: number
example: 1620000000000
description: The date when the recording was stopped (milliseconds since the Unix epoch).
duration:
type: number
example: 3600
description: >
The duration of the recording in seconds.
type: number
example: 3600
description: The duration of the recording in seconds.
size:
type: number
example: 1024
description: >
The size of the recording file in bytes.
type: number
example: 1024
description: The size of the recording file in bytes.
errorCode:
type: number
example: 100
description: >
The error code of the recording.
type: number
example: 100
description: The error code of the recording.
error:
type: string
example: 'error'
description: >
The error message of the recording.
type: string
description: The error message of the recording.
nullable: true
details:
type: string
example: 'Stopped using API'
description: >
Additional details about the recording.
type: string
example: 'Stopped using API'
description: Additional details about the recording.
MeetRecordingStart:
$ref: '#/components/schemas/MeetRecordingBase'
Error:
type: object
required:

View File

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

View File

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