refactor: update LiveKit egress service and module structure

- Removed the `livekit.egress.ts` file and replaced it with `livekit.egress.service.ts` for better clarity and consistency in naming.
- Updated `livekit.module.ts` to reflect the new import path for the `LiveKitEgressService`.
- Enhanced `livekit.room.service.ts` to utilize the new egress service structure, including improved egress configuration for recording sessions with dynamic file output settings.
- Removed the `rootDir` property from `tsconfig.json` to streamline the TypeScript configuration.
This commit is contained in:
2024-12-05 19:35:17 +07:00
parent 7699a07d1d
commit 9d64a199e2
4 changed files with 62 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
import { Module, Global } from '@nestjs/common'
import { LiveKitService } from './livekit.service'
import { LiveKitRoomService } from './livekit.room.service'
import { LiveKitEgressService } from './livekit.egress'
import { LiveKitEgressService } from './livekit.egress.service'
@Global()
@Module({
providers: [LiveKitService, LiveKitRoomService, LiveKitEgressService],

View File

@@ -1,7 +1,17 @@
import { Injectable } from '@nestjs/common'
import {
Room,
RoomServiceClient,
RoomEgress,
AutoTrackEgress,
AutoParticipantEgress,
EncodedFileType,
EncodedFileOutput,
RoomCompositeEgressRequest,
EncodingOptionsPreset,
// @ts-expect-error
import { Room, RoomServiceClient, RoomEgress } from 'livekit-server-sdk'
import { LiveKitEgressService } from './livekit.egress'
} from 'livekit-server-sdk'
import { LiveKitEgressService } from './livekit.egress.service'
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
@Injectable()
@@ -27,7 +37,18 @@ export class LiveKitRoomService {
name: roomId,
maxParticipants: 2,
egress: new RoomEgress({
tracks: {
room: new RoomCompositeEgressRequest({
layout: 'grid',
options: {
case: 'preset',
value: EncodingOptionsPreset.H264_1080P_60,
},
audioOnly: false,
videoOnly: false,
fileOutputs: [
{
fileType: EncodedFileType.MP4,
filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`,
output: {
case: 's3',
value: {
@@ -38,10 +59,10 @@ export class LiveKitRoomService {
region: process.env.MINIO_REGION,
},
},
filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`,
},
],
}),
}),
departureTimeout: 1000 * 60 * 10, // 10 minutes
})
return room
}
@@ -51,7 +72,17 @@ export class LiveKitRoomService {
name: roomId,
maxParticipants,
egress: new RoomEgress({
tracks: {
room: new RoomCompositeEgressRequest({
layout: 'spotlight',
options: {
case: 'preset',
value: EncodingOptionsPreset.H264_1080P_60,
},
audioOnly: false,
videoOnly: false,
fileOutputs: [
{
fileType: EncodedFileType.MP4,
output: {
case: 's3',
value: {
@@ -64,6 +95,8 @@ export class LiveKitRoomService {
},
filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`,
},
],
}),
}),
})
return room

View File

@@ -10,7 +10,6 @@
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"rootDir": "./src",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,