diff --git a/src/LiveKit/livekit.egress.ts b/src/LiveKit/livekit.egress.service.ts similarity index 100% rename from src/LiveKit/livekit.egress.ts rename to src/LiveKit/livekit.egress.service.ts diff --git a/src/LiveKit/livekit.module.ts b/src/LiveKit/livekit.module.ts index 455345a..0eac863 100644 --- a/src/LiveKit/livekit.module.ts +++ b/src/LiveKit/livekit.module.ts @@ -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], diff --git a/src/LiveKit/livekit.room.service.ts b/src/LiveKit/livekit.room.service.ts index 4a207c9..2cd79c6 100644 --- a/src/LiveKit/livekit.room.service.ts +++ b/src/LiveKit/livekit.room.service.ts @@ -1,7 +1,17 @@ import { Injectable } from '@nestjs/common' -// @ts-expect-error -import { Room, RoomServiceClient, RoomEgress } from 'livekit-server-sdk' -import { LiveKitEgressService } from './livekit.egress' +import { + Room, + RoomServiceClient, + RoomEgress, + AutoTrackEgress, + AutoParticipantEgress, + EncodedFileType, + EncodedFileOutput, + RoomCompositeEgressRequest, + EncodingOptionsPreset, + // @ts-expect-error +} from 'livekit-server-sdk' +import { LiveKitEgressService } from './livekit.egress.service' import { DateTimeUtils } from 'src/common/utils/datetime.utils' @Injectable() @@ -27,21 +37,32 @@ export class LiveKitRoomService { name: roomId, maxParticipants: 2, egress: new RoomEgress({ - tracks: { - output: { - case: 's3', - value: { - bucket: 'objects', - accessKey: process.env.MINIO_ACCESS_KEY, - secret: process.env.MINIO_SECRET_KEY, - endpoint: process.env.BASE_URL, - region: process.env.MINIO_REGION, - }, + room: new RoomCompositeEgressRequest({ + layout: 'grid', + options: { + case: 'preset', + value: EncodingOptionsPreset.H264_1080P_60, }, - filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, - }, + audioOnly: false, + videoOnly: false, + fileOutputs: [ + { + fileType: EncodedFileType.MP4, + filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, + output: { + case: 's3', + value: { + bucket: 'objects', + accessKey: process.env.MINIO_ACCESS_KEY, + secret: process.env.MINIO_SECRET_KEY, + endpoint: process.env.BASE_URL, + region: process.env.MINIO_REGION, + }, + }, + }, + ], + }), }), - departureTimeout: 1000 * 60 * 10, // 10 minutes }) return room } @@ -51,19 +72,31 @@ export class LiveKitRoomService { name: roomId, maxParticipants, egress: new RoomEgress({ - tracks: { - output: { - case: 's3', - value: { - bucket: 'objects', - accessKey: process.env.MINIO_ACCESS_KEY, - secret: process.env.MINIO_SECRET_KEY, - endpoint: process.env.BASE_URL, - region: process.env.MINIO_REGION, - }, + room: new RoomCompositeEgressRequest({ + layout: 'spotlight', + options: { + case: 'preset', + value: EncodingOptionsPreset.H264_1080P_60, }, - filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, - }, + audioOnly: false, + videoOnly: false, + fileOutputs: [ + { + fileType: EncodedFileType.MP4, + output: { + case: 's3', + value: { + bucket: 'objects', + accessKey: process.env.MINIO_ACCESS_KEY, + secret: process.env.MINIO_SECRET_KEY, + endpoint: process.env.BASE_URL, + region: process.env.MINIO_REGION, + }, + }, + filepath: `epess/records/${roomId}/${roomId}-${DateTimeUtils.now().toISO()}`, + }, + ], + }), }), }) return room diff --git a/tsconfig.json b/tsconfig.json index 956221d..51de306 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ "sourceMap": true, "outDir": "./dist", "baseUrl": "./", - "rootDir": "./src", "incremental": true, "skipLibCheck": true, "strictNullChecks": true,